mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-02 00:40:10 +00:00
Support filtering by Interface name/index using interface mapping from nprobe
This commit is contained in:
parent
f479071dd3
commit
cb4a100b3b
1 changed files with 23 additions and 10 deletions
|
|
@ -5,10 +5,6 @@
|
|||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
-- Enable trace with "redis-cli set ntopng.debug.do_trace 1"
|
||||
-- Disablee trace with "redis-cli del ntopng.debug.do_trace"
|
||||
local do_trace = ntop.getPref("ntopng.debug.do_trace")
|
||||
|
||||
require "lua_utils"
|
||||
local alert_entities = require "alert_entities"
|
||||
local alert_consts = require "alert_consts"
|
||||
|
|
@ -670,7 +666,6 @@ function tag_utils.get_tag_info(id, entity)
|
|||
end
|
||||
|
||||
elseif tag.value_type == "snmp_interface" then
|
||||
if do_trace == "1" then traceError(TRACE_NORMAL, TRACE_CONSOLE, "Trace A") end
|
||||
|
||||
if ntop.isPro() then
|
||||
filter.value_type = 'array'
|
||||
|
|
@ -680,16 +675,23 @@ function tag_utils.get_tag_info(id, entity)
|
|||
else
|
||||
filter.options = {}
|
||||
|
||||
-- Active flow devices
|
||||
local flow_devices = interface.getFlowDevices()
|
||||
|
||||
-- SNMP devices
|
||||
local snmp_config = require "snmp_config"
|
||||
local devices = snmp_config.get_all_configured_devices()
|
||||
if do_trace == "1" then traceError(TRACE_NORMAL, TRACE_CONSOLE, "Trace B") end
|
||||
|
||||
local snmp_cached_dev = require "snmp_cached_dev"
|
||||
|
||||
if do_trace == "1" then traceError(TRACE_NORMAL, TRACE_CONSOLE, "Trace C") end
|
||||
|
||||
-- use pairsByKeys to impose order
|
||||
for probe_ip, _ in pairsByKeys(devices) do
|
||||
|
||||
if flow_devices[probe_ip] then
|
||||
-- Use SNMP info, remove from flow devices list
|
||||
flow_devices[probe_ip] = nil
|
||||
end
|
||||
|
||||
local cached_device = snmp_cached_dev:get_interface_names(probe_ip)
|
||||
|
||||
local probe_label
|
||||
|
|
@ -715,8 +717,19 @@ function tag_utils.get_tag_info(id, entity)
|
|||
|
||||
end
|
||||
end
|
||||
if do_trace == "1" then traceError(TRACE_NORMAL, TRACE_CONSOLE, "Trace D") end
|
||||
|
||||
|
||||
-- Add interfaces for flow devices which are not polled by SNMP
|
||||
for probe_ip, info in pairs(flow_devices) do
|
||||
local interfaces = interface.getFlowDeviceInfo(probe_ip)
|
||||
for interface_id, interface_info in pairs(interfaces) do
|
||||
local label = probe_ip .. ' · ' .. format_portidx_name(probe_ip, interface_id, true, true)
|
||||
filter.options[#filter.options+1] = {
|
||||
value = probe_ip .. "_" ..interface_id,
|
||||
label = label,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
snmp_filter_options_cache = filter.options
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue