mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Add experimental support for 5sec granularity for host timeseries
To enable it (only on *InfluxDB* right now): - uncomment HOST_NUM_TIMESERIES_POINTS in ntop_defines.h - run `redis-cli set ntopng.prefs.30_sec_dump 1` and restart ntopng
This commit is contained in:
parent
413c265ecb
commit
0004e08191
24 changed files with 354 additions and 106 deletions
|
|
@ -3,54 +3,15 @@ require "graph_utils"
|
|||
require "alert_utils"
|
||||
local host_pools_utils = require "host_pools_utils"
|
||||
local callback_utils = require "callback_utils"
|
||||
local os_utils = require "os_utils"
|
||||
local ts_utils = require "ts_utils_core"
|
||||
require "ts_5min"
|
||||
local host_rrd_dump = require("rrd_30sec_dump_utils")
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
local rrd_dump = {}
|
||||
|
||||
-- ########################################################
|
||||
|
||||
function rrd_dump.host_update_stats_rrds(when, hostname, host, ifstats, verbose)
|
||||
ts_utils.append("host:traffic", {ifid=ifstats.id, host=hostname,
|
||||
bytes_sent=host["bytes.sent"], bytes_rcvd=host["bytes.rcvd"]}, when, verbose)
|
||||
|
||||
-- Number of flows
|
||||
ts_utils.append("host:flows", {ifid=ifstats.id, host=hostname,
|
||||
num_flows=host["active_flows.as_client"] + host["active_flows.as_server"]}, when, verbose)
|
||||
|
||||
-- L4 Protocols
|
||||
for id, _ in ipairs(l4_keys) do
|
||||
k = l4_keys[id][2]
|
||||
if((host[k..".bytes.sent"] ~= nil) and (host[k..".bytes.rcvd"] ~= nil)) then
|
||||
ts_utils.append("host:l4protos", {ifid=ifstats.id, host=hostname,
|
||||
l4proto=tostring(k), bytes_sent=host[k..".bytes.sent"], bytes_rcvd=host[k..".bytes.rcvd"]}, when, verbose)
|
||||
else
|
||||
-- L2 host
|
||||
--io.write("Discarding "..k.."@"..hostname.."\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function rrd_dump.host_update_ndpi_rrds(when, hostname, host, ifstats, verbose)
|
||||
-- nDPI Protocols
|
||||
for k in pairs(host["ndpi"] or {}) do
|
||||
ts_utils.append("host:ndpi", {ifid=ifstats.id, host=hostname, protocol=k,
|
||||
bytes_sent=host["ndpi"][k]["bytes.sent"], bytes_rcvd=host["ndpi"][k]["bytes.rcvd"]}, when, verbose)
|
||||
end
|
||||
end
|
||||
|
||||
function rrd_dump.host_update_categories_rrds(when, hostname, host, ifstats, verbose)
|
||||
-- nDPI Protocol CATEGORIES
|
||||
for k, cat in pairs(host["ndpi_categories"] or {}) do
|
||||
ts_utils.append("host:ndpi_categories", {ifid=ifstats.id, host=hostname, category=k,
|
||||
bytes=cat["bytes"]}, when, verbose)
|
||||
end
|
||||
end
|
||||
|
||||
-- ########################################################
|
||||
|
||||
function rrd_dump.l2_device_update_categories_rrds(when, devicename, device, ifstats, verbose)
|
||||
-- nDPI Protocol CATEGORIES
|
||||
for k, cat in pairs(device["ndpi_categories"] or {}) do
|
||||
|
|
@ -206,6 +167,7 @@ end
|
|||
function rrd_dump.run_5min_dump(_ifname, ifstats, config, when, time_threshold, verbose)
|
||||
local working_status = nil
|
||||
local is_rrd_creation_enabled = (ntop.getPref("ntopng.prefs.ifid_"..ifstats.id..".interface_rrd_creation") ~= "false")
|
||||
local is_5min_host_dump_enabled = is_rrd_creation_enabled and not callback_utils.is30SecDumpEnabled()
|
||||
local are_alerts_enabled = mustScanAlerts(ifstats)
|
||||
|
||||
-- alerts stuff
|
||||
|
|
@ -219,29 +181,15 @@ function rrd_dump.run_5min_dump(_ifname, ifstats, config, when, time_threshold,
|
|||
end
|
||||
|
||||
-- Save hosts stats (if enabled from the preferences)
|
||||
if is_rrd_creation_enabled or are_alerts_enabled then
|
||||
if is_5min_host_dump_enabled or are_alerts_enabled then
|
||||
local in_time = callback_utils.foreachLocalRRDHost(_ifname, time_threshold, function (hostname, host)
|
||||
if are_alerts_enabled then
|
||||
-- Check alerts first
|
||||
check_host_alerts(ifstats.id, working_status, hostname)
|
||||
end
|
||||
|
||||
if is_rrd_creation_enabled then
|
||||
-- Crunch additional stats for local hosts only
|
||||
if config.host_rrd_creation ~= "0" then
|
||||
-- Traffic stats
|
||||
if(config.host_rrd_creation == "1") then
|
||||
rrd_dump.host_update_stats_rrds(when, hostname, host, ifstats, verbose)
|
||||
end
|
||||
|
||||
if(config.host_ndpi_timeseries_creation == "per_protocol" or config.host_ndpi_timeseries_creation == "both") then
|
||||
rrd_dump.host_update_ndpi_rrds(when, hostname, host, ifstats, verbose)
|
||||
end
|
||||
|
||||
if(config.host_ndpi_timeseries_creation == "per_category" or config.host_ndpi_timeseries_creation == "both") then
|
||||
rrd_dump.host_update_categories_rrds(when, hostname, host, ifstats, verbose)
|
||||
end
|
||||
end
|
||||
if is_5min_host_dump_enabled then
|
||||
host_rrd_dump.host_update_rrd(when, hostname, host, ifstats, verbose, config)
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue