mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Adds SNMP information in flow_details.lua
This commit is contained in:
parent
cfe6ff86b7
commit
4ffa3e2ca7
4 changed files with 35 additions and 36 deletions
|
|
@ -1324,51 +1324,39 @@ function printFlowSNMPInfo(snmpdevice, input_idx, output_idx)
|
|||
return
|
||||
end
|
||||
|
||||
local snmp_utils = require "snmp_utils"
|
||||
local available_devices = snmp_utils.get_snmp_devices()
|
||||
if available_devices == nil then available_devices = {} end
|
||||
local snmp_cached_dev = require "snmp_cached_dev"
|
||||
local cached_device = snmp_cached_dev:create(snmpdevice)
|
||||
|
||||
for dev, _ in pairs(available_devices) do
|
||||
local snmp_device = require "snmp_device"
|
||||
snmp_device.init(dev)
|
||||
if cached_device and cached_device["interfaces"] then
|
||||
local snmpurl = "<A HREF='" .. ntop.getHttpPrefix() .. "/lua/pro/enterprise/snmp_device_details.lua?host="..snmpdevice.. "'>"..snmpdevice.."</A>"
|
||||
|
||||
if dev == snmpdevice then
|
||||
local community = snmp_utils.get_snmp_community(dev)
|
||||
local port_indexes = get_snmp_device_port_indexes(dev, community)
|
||||
if port_indexes == nil then port_indexes = {} end
|
||||
local snmp_interfaces = cached_device["interfaces"]
|
||||
local inputurl, outputurl
|
||||
|
||||
local snmpurl = "<A HREF='" .. ntop.getHttpPrefix() .. "/lua/pro/enterprise/snmp_device_details.lua?host="..dev.. "'>"..dev.."</A>"
|
||||
local function prepare_interface_url(idx, port)
|
||||
local ifurl
|
||||
|
||||
local snmp_interfaces = snmp_device.get_device()["interfaces"]
|
||||
local inputurl, outputurl
|
||||
if port then
|
||||
local label = port["index"]
|
||||
|
||||
local function prepare_interface_url(idx, port)
|
||||
local ifurl
|
||||
|
||||
if port then
|
||||
local label = port["index"]
|
||||
|
||||
if port["name"] and port["name"] ~= "" then
|
||||
label = shortenString(port["name"])
|
||||
end
|
||||
|
||||
ifurl = "<A HREF='" .. ntop.getHttpPrefix() .. "/lua/pro/enterprise/snmp_interface_details.lua?host="..dev.."&snmp_port_idx="..port["index"].."'>"..label.."</A>"
|
||||
else
|
||||
ifurl = idx
|
||||
if port["name"] and port["name"] ~= "" then
|
||||
label = shortenString(port["name"])
|
||||
end
|
||||
|
||||
return ifurl
|
||||
ifurl = "<A HREF='" .. ntop.getHttpPrefix() .. "/lua/pro/enterprise/snmp_interface_details.lua?host="..dev.."&snmp_port_idx="..port["index"].."'>"..label.."</A>"
|
||||
else
|
||||
ifurl = idx
|
||||
end
|
||||
|
||||
local inputurl = prepare_interface_url(input_idx, snmp_interfaces[input_idx])
|
||||
local outputurl = prepare_interface_url(output_idx, snmp_interfaces[output_idx])
|
||||
|
||||
print("<tr><th rowspan='2'>"..i18n("details.flow_snmp_localization").."</th><th>"..i18n("snmp.snmp_device").."</th><th>"..i18n("details.input_device_port").." / "..i18n("details.output_device_port").."</th></tr>")
|
||||
print("<tr><td>"..snmpurl.."</td><td>"..inputurl.." / "..outputurl.."</td></tr>")
|
||||
break
|
||||
return ifurl
|
||||
end
|
||||
end
|
||||
|
||||
local inputurl = prepare_interface_url(input_idx, snmp_interfaces[input_idx])
|
||||
local outputurl = prepare_interface_url(output_idx, snmp_interfaces[output_idx])
|
||||
|
||||
print("<tr><th rowspan='2'>"..i18n("details.flow_snmp_localization").."</th><th>"..i18n("snmp.snmp_device").."</th><th>"..i18n("details.input_device_port").." / "..i18n("details.output_device_port").."</th></tr>")
|
||||
print("<tr><td>"..snmpurl.."</td><td>"..inputurl.." / "..outputurl.."</td></tr>")
|
||||
end
|
||||
end
|
||||
|
||||
-- #######################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue