mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Added checks on remote flow collection
- check clock drift and report it as alert - fix flow time drift
This commit is contained in:
parent
8684916788
commit
3ba1cc622e
8 changed files with 192 additions and 87 deletions
|
|
@ -12,16 +12,22 @@ local alert_notification = require("alert_notification")
|
|||
local ALARM_THRESHOLD_LOW = 60
|
||||
local ALARM_THRESHOLD_HIGH = 90
|
||||
|
||||
local function create_geo_ip_alert_notification()
|
||||
--
|
||||
-- NOTE
|
||||
-- scripts/lua/modules/menu_alert_notifications.lua will call all NON-LOCAL functions in this file in sequence
|
||||
-- each function will displaya badge if required
|
||||
--
|
||||
|
||||
local function create_geo_ip_alert_notification()
|
||||
local title = i18n("geolocation_unavailable_title")
|
||||
local description = i18n("geolocation_unavailable", {url = "https://github.com/ntop/ntopng/blob/dev/doc/README.geolocation.md", target = "_blank", icon = "fas fa-external-link-alt"})
|
||||
|
||||
return alert_notification:create("geoip_alert", title, description, "warning", nil, "nedge/system_setup/")
|
||||
end
|
||||
|
||||
local function create_contribute_alert_notification()
|
||||
-- ###############################################################
|
||||
|
||||
local function create_contribute_alert_notification()
|
||||
local title = i18n("about.contribute_to_project")
|
||||
local description = i18n("about.telemetry_data_opt_out_msg", {tel_url=ntop.getHttpPrefix().."/lua/telemetry.lua", ntop_org="https://www.ntop.org/"})
|
||||
local action = {
|
||||
|
|
@ -32,8 +38,9 @@ local function create_contribute_alert_notification()
|
|||
return alert_notification:create("contribute_alert", title, description, "info", action, "/lua/admin/prefs.lua")
|
||||
end
|
||||
|
||||
local function create_tempdir_alert_notification()
|
||||
-- ###############################################################
|
||||
|
||||
local function create_tempdir_alert_notification()
|
||||
local title = i18n("warning")
|
||||
local description = i18n("about.datadir_warning")
|
||||
local action = {
|
||||
|
|
@ -43,64 +50,71 @@ local function create_tempdir_alert_notification()
|
|||
return alert_notification:create("tempdir_alert", title, description, "warning", action)
|
||||
end
|
||||
|
||||
local function create_update_ntopng_notification(body)
|
||||
-- ###############################################################
|
||||
|
||||
local function create_update_ntopng_notification(body)
|
||||
local title = i18n("update")
|
||||
return alert_notification:create("update_alert", title, body, "info")
|
||||
end
|
||||
|
||||
local function create_too_many_flows_notification(level)
|
||||
-- ###############################################################
|
||||
|
||||
local function create_too_many_flows_notification(level)
|
||||
local title = i18n("too_many_flows")
|
||||
local desc = i18n("about.you_have_too_many_flows", {product=info["product"]})
|
||||
|
||||
return alert_notification:create("toomanyflows_alert", title, desc, level)
|
||||
end
|
||||
|
||||
local function create_too_many_hosts_notification(level)
|
||||
-- ###############################################################
|
||||
|
||||
local function create_too_many_hosts_notification(level)
|
||||
local title = i18n("too_many_hosts")
|
||||
local desc = i18n("about.you_have_too_many_hosts", {product=info["product"]})
|
||||
|
||||
return alert_notification:create("toomanyhosts_alert", title, desc, level)
|
||||
end
|
||||
|
||||
-- ###############################################################
|
||||
|
||||
local function create_remote_probe_clock_drift_notification(level)
|
||||
local title = i18n("remote_probe_clock_drift")
|
||||
local desc = i18n("about.you_need_to_sync_remote_probe_time", {url=ntop.getHttpPrefix().."/lua/if_stats.lua"})
|
||||
|
||||
return alert_notification:create("remoteprobleclockdrift_alert", title, desc, level)
|
||||
end
|
||||
|
||||
-- ##################################################################
|
||||
|
||||
--- Create an instance for the geoip alert notification
|
||||
--- if the user doesn't have geoIP installed
|
||||
--- @param container table The table where the notification will be inserted
|
||||
function defined_alert_notifications.geo_ip(container)
|
||||
|
||||
if isAdministrator() and not ntop.hasGeoIP() then
|
||||
table.insert(container, create_geo_ip_alert_notification())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Create an instance for the temp working directory alert
|
||||
--- if ntopng is running inside /var/tmp
|
||||
--- @param container table The table where the notification will be inserted
|
||||
function defined_alert_notifications.temp_working_dir(container)
|
||||
|
||||
if (dirs.workingdir == "/var/tmp/ntopng") then
|
||||
table.insert(container, create_tempdir_alert_notification())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Create an instance for contribute alert notification
|
||||
--- @param container table The table where the notification will be inserted
|
||||
function defined_alert_notifications.contribute(container)
|
||||
|
||||
if (not info.oem) and (not telemetry_utils.dismiss_notice()) then
|
||||
table.insert(container, create_contribute_alert_notification())
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function defined_alert_notifications.update_ntopng(container)
|
||||
-- ###############################################################
|
||||
|
||||
function defined_alert_notifications.update_ntopng(container)
|
||||
-- check if ntopng is oem and the user is an Administrator
|
||||
local is_not_oem_and_administrator = isAdministrator() and not info.oem
|
||||
local message = check_latest_major_release()
|
||||
|
|
@ -108,11 +122,11 @@ function defined_alert_notifications.update_ntopng(container)
|
|||
if is_not_oem_and_administrator and not isEmptyString(message) then
|
||||
table.insert(container, create_update_ntopng_notification(message))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function defined_alert_notifications.too_many_hosts(container)
|
||||
-- ###############################################################
|
||||
|
||||
function defined_alert_notifications.too_many_hosts(container)
|
||||
local level = nil
|
||||
local hosts = interface.getNumHosts()
|
||||
local hosts_pctg = math.floor(1 + ((hosts * 100) / prefs.max_num_hosts))
|
||||
|
|
@ -128,8 +142,9 @@ function defined_alert_notifications.too_many_hosts(container)
|
|||
end
|
||||
end
|
||||
|
||||
function defined_alert_notifications.too_many_flows(container)
|
||||
-- ###############################################################
|
||||
|
||||
function defined_alert_notifications.too_many_flows(container)
|
||||
local level = nil
|
||||
local flows = interface.getNumFlows()
|
||||
local flows_pctg = math.floor(1 + ((flows * 100) / prefs.max_num_flows))
|
||||
|
|
@ -143,8 +158,30 @@ function defined_alert_notifications.too_many_flows(container)
|
|||
if (level ~= nil) then
|
||||
table.insert(container, create_too_many_flows_notification(level))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- ###############################################################
|
||||
|
||||
function defined_alert_notifications.remote_probe_clock_drift(container)
|
||||
local ifstats = interface.getStats()
|
||||
|
||||
if(ifstats["probe.remote_time"] ~= nil) then
|
||||
local tdiff = math.abs(os.time()-ifstats["probe.remote_time"])
|
||||
local level = nil
|
||||
|
||||
if (tdiff >= 10 and tdiff <= 30) then
|
||||
level = "warning"
|
||||
elseif (tdiff > 30) then
|
||||
level = "danger"
|
||||
end
|
||||
|
||||
if (level ~= nil) then
|
||||
table.insert(container, create_remote_probe_clock_drift_notification(level))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ###############################################################
|
||||
|
||||
return defined_alert_notifications
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue