-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnetfilter_summary_json.stp
More file actions
38 lines (32 loc) · 1.05 KB
/
netfilter_summary_json.stp
File metadata and controls
38 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env stap
global packets
// Set up the metrics
probe begin
{
// Set the prefix to be used instead of the module name (optional).
json_set_prefix("netfilter")
// Add the metrics
json_add_array("netfilter_data",
"Network data indexed by source and destination addresses.")
json_add_array_numeric_metric("netfilter_data", "packets",
"Number of packets transferred.", "")
json_add_array_numeric_metric("netfilter_data", "bytes","Bytes transferred.",
"bytes")
}
probe netfilter.ipv4.pre_routing {
// Using aggregates avoids contention from packets being sent in
// parallel from different processors:
packets[saddr, daddr] <<< length
}
probe json_data
{
@json_output_data_start
foreach ([saddr, daddr] in packets-) {
index = sprintf("%15s --> %15s", saddr, daddr)
@json_output_array_numeric_value("netfilter_data", index, "packets",
@count(packets[saddr,daddr]))
@json_output_array_numeric_value("netfilter_data", index, "bytes",
@sum(packets[saddr,daddr]))
}
@json_output_data_end
}