mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Added probes filter to host page (#5157)
This commit is contained in:
parent
df906622eb
commit
4e693dc9f1
9 changed files with 109 additions and 28 deletions
|
|
@ -618,6 +618,78 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function getProbesName(flowdevs)
|
||||
local devips = {}
|
||||
|
||||
for dip, _ in pairsByValues(flowdevs, asc) do
|
||||
local cached_device_name = snmp_cached_dev:create(dip)
|
||||
|
||||
if cached_device_name then
|
||||
cached_device_name = cached_device_name["name"]
|
||||
else
|
||||
local hinfo = hostkey2hostinfo(dip)
|
||||
local resname = hostinfo2label(hinfo)
|
||||
|
||||
if not isEmptyString(resname) then
|
||||
cached_device_name = resname
|
||||
end
|
||||
end
|
||||
|
||||
devips[dip] = cached_device_name
|
||||
end
|
||||
|
||||
return devips
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function printHostsDeviceFilterDropdown(base_url, page_params)
|
||||
local snmp_cached_dev = require "snmp_cached_dev"
|
||||
-- Getting probes
|
||||
local flowdevs = interface.getFlowDevices() or {}
|
||||
local ordering_fun = pairsByKeys
|
||||
local cur_dev = _GET["deviceIP"]
|
||||
local cur_dev_filter = ''
|
||||
-- table.clone needed to modify some parameters while keeping the original unchanged
|
||||
local dev_params = table.clone(page_params)
|
||||
local devips = getProbesName(flowdevs)
|
||||
local devips_order = ntop.getPref("ntopng.prefs.flow_table_probe_order") == "1" -- Order by Probe Name
|
||||
|
||||
if devips_order then
|
||||
ordering_fun = pairsByValues
|
||||
end
|
||||
|
||||
if not isEmptyString(cur_dev) then
|
||||
cur_dev_filter = '<span class="fas fa-filter"></span>'
|
||||
end
|
||||
|
||||
dev_params["deviceIP"] = nil
|
||||
|
||||
print[[
|
||||
<button class="btn btn-link dropdown-toggle" data-bs-toggle="dropdown">]] print(i18n("flows_page.device_ip")) print[[]] print(cur_dev_filter) print[[<span class="caret"></span></button>\
|
||||
<ul class="dropdown-menu dropdown-menu-end scrollable-dropdown" role="menu" id="flow_dropdown">\
|
||||
<li><a class="dropdown-item" href="]] print(getPageUrl(base_url, dev_params)) print[[">]] print(i18n("flows_page.all_devices")) print[[</a></li>\]]
|
||||
|
||||
for dev_ip, dev_resolved_name in ordering_fun(devips, asc) do
|
||||
local dev_name = dev_ip
|
||||
|
||||
dev_params["deviceIP"] = dev_name
|
||||
|
||||
if not isEmptyString(dev_resolved_name) and dev_resolved_name ~= dev_name then
|
||||
dev_name = dev_name .. " ["..shortenString(dev_resolved_name).."]"
|
||||
end
|
||||
|
||||
print[[
|
||||
<li><a class="dropdown-item ]] print(dev_ip == cur_dev and 'active' or '') print[[" href="]] print(getPageUrl(base_url, dev_params)) print[[">]] print(i18n("flows_page.device_ip").." "..dev_name) print[[</a></li>\]]
|
||||
end
|
||||
|
||||
print[[
|
||||
</ul>\
|
||||
]]
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--
|
||||
-- Returns indexes to be used for string shortening. The portion of to_shorten between
|
||||
-- middle_start and middle_end will be inside the bounds.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue