ntopng/scripts/plugins/rtt/alert_definitions/alert_ping_issues.lua
emanuele-f 5b05b06c96 Use extended icon classes.
Also fixes mining alert icon
2020-01-10 17:02:11 +01:00

42 lines
1.1 KiB
Lua

--
-- (C) 2019-20 - 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 = "fas fa-exclamation",
}