mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Add filters on SNMP Device and Interface (by name) #5978
This commit is contained in:
parent
5e1725a256
commit
ed3b49779f
3 changed files with 57 additions and 28 deletions
|
|
@ -5041,7 +5041,7 @@ end
|
|||
function format_device_name(device_ip, short_version)
|
||||
local device_name = device_ip
|
||||
|
||||
if ntop.isPro() then
|
||||
if ntop.isPro() then
|
||||
device_name = hostinfo2label(hostkey2hostinfo(device_ip))
|
||||
|
||||
if device_name ~= device_ip then
|
||||
|
|
@ -5061,36 +5061,36 @@ end
|
|||
-- @params device_ip: snmp device ip
|
||||
-- portidx: number or string, interface index to format
|
||||
-- short_version: boolean, long formatting version (e.g. flow info) or short version (e.g. dropdown menu)
|
||||
function format_portidx_name(device_ip, portidx, short_version)
|
||||
local idx_name = portidx
|
||||
-- SNMP is available only with Pro version at least
|
||||
if ntop.isPro() then
|
||||
local snmp_cached_dev = require "snmp_cached_dev"
|
||||
function format_portidx_name(device_ip, portidx, short_version)
|
||||
local idx_name = portidx
|
||||
-- SNMP is available only with Pro version at least
|
||||
if ntop.isPro() then
|
||||
local snmp_cached_dev = require "snmp_cached_dev"
|
||||
local cached_dev = snmp_cached_dev:create(device_ip)
|
||||
|
||||
if (cached_dev) and (cached_dev["interfaces"]) then
|
||||
local port_info = cached_dev["interfaces"][tostring(portidx)]
|
||||
|
||||
if port_info then
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
||||
snmp_location = require "snmp_location"
|
||||
|
||||
if not port_info["id"] then
|
||||
port_info["id"] = port_info["index"]
|
||||
port_info["snmp_device_ip"] = cached_dev["host_ip"]
|
||||
end
|
||||
|
||||
if (cached_dev) and (cached_dev["interfaces"]) then
|
||||
local port_info = cached_dev["interfaces"][tostring(portidx)]
|
||||
|
||||
if port_info then
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
||||
snmp_location = require "snmp_location"
|
||||
|
||||
if not port_info["id"] then
|
||||
port_info["id"] = port_info["index"]
|
||||
port_info["snmp_device_ip"] = cached_dev["host_ip"]
|
||||
end
|
||||
|
||||
if short_version then
|
||||
idx_name = string.format('%s [%s]', port_info["index"], port_info["name"])
|
||||
else
|
||||
idx_name = string.format('%s', i18n("snmp.interface_device_2", {interface=snmp_location.snmp_port_link(port_info, true), device=snmp_location.snmp_device_link(cached_dev["host_ip"])}))
|
||||
end
|
||||
idx_name = string.format('%s', i18n("snmp.interface_device_2", {interface=snmp_location.snmp_port_link(port_info, true), device=snmp_location.snmp_device_link(cached_dev["host_ip"])}))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return idx_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return idx_name
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue