mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 17:30:11 +00:00
Implements slow and not executed periodic activity alerts
This commit is contained in:
parent
4944556992
commit
d1f11c7de7
11 changed files with 197 additions and 51 deletions
|
|
@ -0,0 +1,66 @@
|
|||
--
|
||||
-- (C) 2019-20 - ntop.org
|
||||
--
|
||||
|
||||
local alert_consts = require("alert_consts")
|
||||
local alerts_api = require("alerts_api")
|
||||
local user_scripts = require("user_scripts")
|
||||
|
||||
local script
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function alert_info(ps_name, last_queued_time)
|
||||
return({
|
||||
alert_type = alert_consts.alert_types.alert_periodic_activity_not_executed,
|
||||
alert_severity = alert_consts.alert_severities.warning,
|
||||
alert_granularity = alert_consts.alerts_granularities.min,
|
||||
alert_subtype = ps_name,
|
||||
alert_type_params = {
|
||||
ps_name = ps_name,
|
||||
last_queued_time = last_queued_time
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
local function check_periodic_activity_not_executed(params)
|
||||
local scripts_stats = interface.getPeriodicActivitiesStats()
|
||||
|
||||
for ps_name, ps_stats in pairs(scripts_stats) do
|
||||
local delta = alerts_api.interface_delta_val(script.key..ps_name --[[ metric name --]], params.granularity, ps_stats["num_not_executed"] or 0)
|
||||
local info = alert_info(ps_name, ps_stats["last_queued_time"] or 0)
|
||||
|
||||
if delta > 0 then
|
||||
-- tprint({ps_name = ps_name, s = ">>>>>>>>>>>>>>>>>>>>>> TRIGGER"})
|
||||
alerts_api.trigger(params.alert_entity, info, nil, params.cur_alerts)
|
||||
else
|
||||
-- tprint({ps_name = ps_name, s = "---------------------- RELEASE"})
|
||||
alerts_api.release(params.alert_entity, info, nil, params.cur_alerts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
script = {
|
||||
-- Script category
|
||||
category = user_scripts.script_categories.internals,
|
||||
|
||||
-- This script is only for alerts generation
|
||||
is_alert = true,
|
||||
|
||||
hooks = {
|
||||
min = check_periodic_activity_not_executed,
|
||||
},
|
||||
|
||||
gui = {
|
||||
i18n_title = "alerts_dashboard.periodic_activity_not_executed",
|
||||
i18n_description = "alerts_dashboard.periodic_activity_not_executed_descr",
|
||||
}
|
||||
}
|
||||
|
||||
-- #################################################################
|
||||
|
||||
return script
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
--
|
||||
-- (C) 2019-20 - ntop.org
|
||||
--
|
||||
|
||||
local alert_consts = require("alert_consts")
|
||||
local alerts_api = require("alerts_api")
|
||||
local user_scripts = require("user_scripts")
|
||||
|
||||
local script
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function alert_info(ps_name, max_duration_ms)
|
||||
return({
|
||||
alert_type = alert_consts.alert_types.alert_slow_periodic_activity,
|
||||
alert_severity = alert_consts.alert_severities.warning,
|
||||
alert_granularity = alert_consts.alerts_granularities.min,
|
||||
alert_subtype = ps_name,
|
||||
alert_type_params = {
|
||||
ps_name = ps_name,
|
||||
max_duration_ms = max_duration_ms,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
local function check_slow_periodic_activity(params)
|
||||
local scripts_stats = interface.getPeriodicActivitiesStats()
|
||||
|
||||
for ps_name, ps_stats in pairs(scripts_stats) do
|
||||
local delta = alerts_api.interface_delta_val(script.key..ps_name --[[ metric name --]], params.granularity, ps_stats["num_is_slow"] or 0)
|
||||
|
||||
local info = alert_info(ps_name, (ps_stats["periodicity"] or 0) * 1000)
|
||||
|
||||
if delta > 0 then
|
||||
-- tprint({ps_name = ps_name, s = ">>>>>>>>>>>>>>>>>>>>>> TRIGGER"})
|
||||
alerts_api.trigger(params.alert_entity, info, nil, params.cur_alerts)
|
||||
else
|
||||
-- tprint({ps_name = ps_name, s = "---------------------- RELEASE"})
|
||||
alerts_api.release(params.alert_entity, info, nil, params.cur_alerts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
script = {
|
||||
-- Script category
|
||||
category = user_scripts.script_categories.internals,
|
||||
|
||||
-- This script is only for alerts generation
|
||||
is_alert = true,
|
||||
|
||||
hooks = {
|
||||
min = check_slow_periodic_activity,
|
||||
},
|
||||
|
||||
gui = {
|
||||
i18n_title = "alerts_dashboard.slow_periodic_activity",
|
||||
i18n_description = "alerts_dashboard.slow_periodic_activity_descr",
|
||||
}
|
||||
}
|
||||
|
||||
-- #################################################################
|
||||
|
||||
return script
|
||||
Loading…
Add table
Add a link
Reference in a new issue