ntopng/scripts/plugins/rtt/alert_definitions/alert_ping_issues.lua
emanuele-f a3432e00e8 Implement ntopng plugins
Plugins are a convenient way to group together related lua scripts.
Their primary use case is to group user scripts and their alert/status
definition.
The builtin ntopng user scripts and definitions are now
packed into plugins directories. In future, we will support loading of
user created plugins.
Plugins are loaded at startup into some runtime directories and then
used. Other changes provided by this commit include:

- Add sample flow logger plugin
- Initial support for system user scripts
- Rename edge to threshold
- Migrate system probes to user scripts/plugins
- Migrate scripts to more explicit alerts_api.checkThresholdAlert api
2019-12-10 09:25:57 +01:00

42 lines
1.1 KiB
Lua

--
-- (C) 2019 - ntop.org
--
local format_utils = require("format_utils")
local function pingIssuesFormatter(ifid, alert, info)
local msg
-- example of an ip label:
-- google-public-dns-b.google.com@ipv4@icmp/216.239.38.120
local ip_label = (alert.alert_entity_val:split("@") or {alert.alert_entity_val})[1]
local numeric_ip = alert.ip
if numeric_ip and numeric_ip ~= ip_label then
numeric_ip = string.format("[%s]", numeric_ip)
else
numeric_ip = ""
end
if(info.value == 0) then -- host unreachable
msg = i18n("alert_messages.ping_host_unreachable",
{ip_label = ip_label,
numeric_ip = numeric_ip})
else -- host too slow
msg = i18n("alert_messages.ping_rtt_too_slow",
{ip_label = ip_label,
numeric_ip = numeric_ip,
rtt_value = format_utils.round(info.value, 2),
maximum_rtt = info.threshold})
end
return msg
end
-- #######################################################
return {
alert_id = 39,
i18n_title = "alerts_dashboard.ping_issues",
i18n_description = pingIssuesFormatter,
icon = "fa-exclamation",
}