mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Refactors alerts and flow statuses in builtin and plugins
Implements #3811 Implements #3812 Refactors builtin alerts Refactors builtin flow statuses
This commit is contained in:
parent
1c76667b21
commit
78b334e4eb
89 changed files with 680 additions and 39 deletions
|
|
@ -0,0 +1,64 @@
|
|||
--
|
||||
-- (C) 2019-20 - ntop.org
|
||||
--
|
||||
|
||||
local alert_keys = require "alert_keys"
|
||||
|
||||
local format_utils = require("format_utils")
|
||||
local json = require "dkjson"
|
||||
|
||||
local function thresholdCrossFormatter(ifid, alert, info)
|
||||
local alert_json = json.decode(alert.alert_json)
|
||||
|
||||
local msg
|
||||
local host = alert_json.host
|
||||
local numeric_ip = info.ip
|
||||
local ip_label = host and host.label or numeric_ip
|
||||
|
||||
if 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_v3",
|
||||
{host = ip_label,
|
||||
numeric_ip = numeric_ip})
|
||||
else -- host too slow
|
||||
if alert_json.operator == "lt" then
|
||||
i18n_s = "alert_messages.measurement_too_low_msg"
|
||||
else
|
||||
i18n_s = "alert_messages.measurement_too_high_msg"
|
||||
end
|
||||
|
||||
local unit = "active_monitoring_stats.msec"
|
||||
|
||||
if alert_json.unit then
|
||||
unit = alert_json.unit
|
||||
end
|
||||
|
||||
unit = i18n(unit) or unit
|
||||
|
||||
local msg_table = {
|
||||
host = ip_label,
|
||||
numeric_ip = numeric_ip,
|
||||
am_value = format_utils.round(info.value, 2),
|
||||
threshold = info.threshold,
|
||||
unit = unit,
|
||||
}
|
||||
|
||||
msg = i18n(i18n_s, msg_table)
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return {
|
||||
alert_key = alert_keys.ntopng.alert_am_threshold_cross,
|
||||
i18n_title = "graphs.active_monitoring",
|
||||
i18n_description = thresholdCrossFormatter,
|
||||
icon = "fas fa-exclamation",
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue