mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 01:10:10 +00:00
* Added unexpected new device plugin, needs review * Fixes #4709 unexpected new device plugin Co-authored-by: matteo <biscosi@ntop.org>
This commit is contained in:
parent
4990491d06
commit
a8cf3836d7
7 changed files with 222 additions and 24 deletions
|
|
@ -0,0 +1,63 @@
|
|||
--
|
||||
-- (C) 2020 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
local alert_keys = require "alert_keys"
|
||||
local alert_creators = require "alert_creators"
|
||||
|
||||
|
||||
-- #######################################################
|
||||
|
||||
local function formatUnexpectedNewDevice(ifid, alert, info)
|
||||
-- Pro description
|
||||
if(ntop.isPro()) then
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
||||
local snmp_location = require "snmp_location"
|
||||
|
||||
has_snmp_location = snmp_location.host_has_snmp_location(info.mac)
|
||||
-- The host has an snmp location
|
||||
if has_snmp_location then
|
||||
local access_port = snmp_location.get_host_access_port(info.mac)
|
||||
|
||||
if access_port then
|
||||
return(i18n("unexpected_new_device.status_unexpected_new_device_description_pro", {
|
||||
device = info.device,
|
||||
host_url = getMacUrl(alert.alert_entity_val),
|
||||
snmp_url = snmpDeviceUrl(access_port.snmp_device_ip),
|
||||
device_ip = access_port.snmp_device_ip,
|
||||
}))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Non enterprise software or the host hasn't an snmp location
|
||||
return(i18n("unexpected_new_device.status_unexpected_new_device_description", {
|
||||
device = info.device,
|
||||
url = getMacUrl(alert.alert_entity_val),
|
||||
}))
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function createUnexpectedNewDevice(alert_severity, device, mac)
|
||||
local unexpected_new_device_type = {
|
||||
alert_severity = alert_severity,
|
||||
alert_type_params = {
|
||||
device = device,
|
||||
mac = mac,
|
||||
},
|
||||
}
|
||||
|
||||
return unexpected_new_device_type
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return {
|
||||
alert_key = alert_keys.ntopng.alert_unexpected_new_device,
|
||||
i18n_title = "unexpected_new_device.alert_unexpected_new_device_title",
|
||||
i18n_description = formatUnexpectedNewDevice,
|
||||
icon = "fas fa-exclamation",
|
||||
creator = createUnexpectedNewDevice,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue