Implements SNMP iterfaces status change alerts

This commit is contained in:
Simone Mainardi 2018-05-15 15:19:09 +02:00
parent c1c3c49b45
commit 9dd2ae14a8
3 changed files with 22 additions and 1 deletions

View file

@ -2818,6 +2818,25 @@ local function notify_ntopng_status(started)
ntop.rpushCache(alert_process_queue, json.encode(obj))
end
function notify_snmp_device_interface_status_change(snmp_host, snmp_interface)
local msg = i18n("alerts_dashboard.snmp_port_changed_status_from_to",
{device = snmp_host,
port = snmp_interface["name"] or snmp_interface["index"],
url = ntop.getHttpPrefix()..string.format("/lua/pro/enterprise/snmp_device_details.lua?host=%s", snmp_host),
port_url = ntop.getHttpPrefix()..string.format("/lua/pro/enterprise/snmp_interface_details.lua?host=%s&snmp_port_idx=%d", snmp_host, snmp_interface["index"]),
old_op = snmp_ifstatus(snmp_interface["prev_status"]),
new_op = snmp_ifstatus(snmp_interface["status"])})
local entity_value = string.format("%s_ifidx%d", snmp_host, snmp_interface["index"])
local obj = {entity_type = alertEntity("snmp_device"),
entity_value = entity_value,
type = alertType("port_status_change"),
severity = alertSeverity("info"),
message = msg, when = os.time()
}
ntop.rpushCache(alert_process_queue, json.encode(obj))
end
function notify_ntopng_start() notify_ntopng_status(true) end
function notify_ntopng_stop() notify_ntopng_status(false) end