Skip to content

Commit

Permalink
Add iface:traffic_rxtx_min with minute resolution on nEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Feb 13, 2025
1 parent fa6d098 commit 1ebb465
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/callbacks/5second/system/timeseries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ for i = 1, num_runs do
-- ########################################################

ntop.msleep(5000) -- 5 seconds frequency
end
end
23 changes: 9 additions & 14 deletions scripts/callbacks/second/system/timeseries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,29 @@ for i=1,num_runs do
-- We check for ifstats.stats.bytes to start writing only when there's data. This
-- prevents artificial and wrong peaks especially during the startup of ntopng.
if ifstats.stats.bytes > 0 then
ts_utils.append("iface:traffic", {ifid=ifstats.id, bytes=ifstats.stats.bytes}, when)
ts_utils.append("iface:throughput_bps", {ifid=ifstats.id, bps=ifstats.stats.throughput_bps}, when)
ts_utils.append("iface:throughput_pps", {ifid=ifstats.id, pps=ifstats.stats.throughput_pps}, when)
ts_utils.append("iface:packets_vs_drops",
{ifid=ifstats.id, packets=ifstats.stats.packets, drops=ifstats.stats.drops or 0}, when)

ts_utils.append("iface:traffic", {ifid=ifstats.id, bytes=ifstats.stats.bytes}, when)
ts_utils.append("iface:throughput_bps", {ifid=ifstats.id, bps=ifstats.stats.throughput_bps}, when)
ts_utils.append("iface:throughput_pps", {ifid=ifstats.id, pps=ifstats.stats.throughput_pps}, when)
ts_utils.append("iface:packets_vs_drops", {ifid=ifstats.id, packets=ifstats.stats.packets, drops=ifstats.stats.drops or 0}, when)
if ifstats.has_traffic_directions then
ts_utils.append("iface:traffic_rxtx",
{ifid=ifstats.id, bytes_sent=ifstats.eth.egress.bytes, bytes_rcvd=ifstats.eth.ingress.bytes}, when)

ts_utils.append("iface:traffic_rxtx", {ifid=ifstats.id, bytes_sent=ifstats.eth.egress.bytes, bytes_rcvd=ifstats.eth.ingress.bytes}, when)
end
ts_utils.append("iface:traffic_ip",
{ifid=ifstats.id, bytes_ipv4=ifstats.eth.IPv4_bytes, bytes_ipv6=ifstats.eth.IPv6_bytes}, when)
ts_utils.append("iface:traffic_ip", {ifid=ifstats.id, bytes_ipv4=ifstats.eth.IPv4_bytes, bytes_ipv6=ifstats.eth.IPv6_bytes}, when)
end

-- ZMQ stats (only for non-packet interfaces)
if ifstats.zmqRecvStats ~= nil and not interface.isPacketInterface() then
ts_utils.append("iface:zmq_recv_flows", {ifid = ifstats.id, flows = ifstats.zmqRecvStats.flows or 0}, when)
ts_utils.append("iface:zmq_rcvd_msgs", {ifid = ifstats.id, msgs = ifstats.zmqRecvStats.zmq_msg_rcvd or 0}, when)
ts_utils.append("iface:zmq_msg_drops", {ifid = ifstats.id, msgs = ifstats.zmqRecvStats.zmq_msg_drops or 0}, when)
ts_utils.append("iface:zmq_rcvd_msgs", {ifid = ifstats.id, msgs = ifstats.zmqRecvStats.zmq_msg_rcvd or 0}, when)
ts_utils.append("iface:zmq_msg_drops", {ifid = ifstats.id, msgs = ifstats.zmqRecvStats.zmq_msg_drops or 0}, when)
ts_utils.append("iface:zmq_flow_coll_drops", {ifid = ifstats.id, drops = ifstats["zmq.drops.flow_collection_drops"] or 0}, when)
ts_utils.append("iface:zmq_flow_coll_udp_drops", {ifid = ifstats.id, drops = ifstats["zmq.drops.flow_collection_udp_socket_drops"] or 0}, when)
end

-- Discarded probing stats
if ifstats.discarded_probing_packets then
ts_utils.append("iface:disc_prob_bytes", {ifid = ifstats.id, bytes = ifstats.discarded_probing_bytes}, when)
ts_utils.append("iface:disc_prob_pkts", {ifid = ifstats.id, packets = ifstats.discarded_probing_packets}, when)
ts_utils.append("iface:disc_prob_pkts", {ifid = ifstats.id, packets = ifstats.discarded_probing_packets}, when)
end
end, true --[[ update direction stats ]])

Expand Down
12 changes: 12 additions & 0 deletions scripts/lua/modules/timeseries/schemas/ts_minute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,25 @@ schema:addMetric("bytes")
-- nEDGE SCHEMAS
-------------------------------------------------------

-- Stats (rx/tx) for the analysed traffic (netfilter interface)
-- (same as traffic_rxtx, but with minute resolution)
schema = ts_utils.newSchema("iface:traffic_rxtx_min", {
step=60,
is_critical_ts=true
})
schema:addTag("ifid")
schema:addMetric("bytes_sent")
schema:addMetric("bytes_rcvd")

-- Stats per lan/wan interfaces
schema = ts_utils.newSchema("iface:nedge_traffic_rxtx", {
step = 60
})
schema:addTag("ifid")
schema:addMetric("bytes_sent")
schema:addMetric("bytes_rcvd")

-- Stats for the netfilter queue
schema = ts_utils.newSchema("iface:nedge_traffic_nfq", {
step = 60
})
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/dashboard/nedge-enterprise.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"ts_requests": {
"$ANY_IFID$" : {
"ts_query": "ifid:$IFID$",
"ts_schema": "iface:traffic_rxtx",
"ts_schema": "iface:traffic_rxtx_min",
"tskey": "$IFID$"
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/dashboard/nedge.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ts_requests": {
"$ANY_IFID$" : {
"ts_query": "ifid:$IFID$",
"ts_schema": "iface:traffic_rxtx",
"ts_schema": "iface:traffic_rxtx_min",
"tskey": "$IFID$"
}
}
Expand Down

0 comments on commit 1ebb465

Please sign in to comment.