mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 02:16:39 +00:00
Fixes filters sorting (#8361)
This commit is contained in:
parent
5e3143600f
commit
00cb3604b1
5 changed files with 335 additions and 203 deletions
|
|
@ -10,7 +10,7 @@ require "http_lint"
|
|||
require "lua_utils_get"
|
||||
require "flow_utils"
|
||||
local tcp_flow_state_utils = require("tcp_flow_state_utils")
|
||||
local format_utils = require "format_utils"
|
||||
local format_utils = require "format_utils"
|
||||
local alert_consts = require "alert_consts"
|
||||
local rest_utils = require "rest_utils"
|
||||
|
||||
|
|
@ -24,7 +24,6 @@ local flowstats = interface.getActiveFlowsStats(host, nil, false, talking_with,
|
|||
|
||||
local rsp = {}
|
||||
|
||||
|
||||
if interface.isView() then
|
||||
local interfaces_filter = {{
|
||||
key = "interface_filter",
|
||||
|
|
@ -42,8 +41,8 @@ if interface.isView() then
|
|||
key = "interface_filter",
|
||||
value = id,
|
||||
label = getInterfaceName(id)
|
||||
}
|
||||
::continue::
|
||||
}
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -72,7 +71,7 @@ if not host then
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local hosts_type_filters2 = {{
|
||||
key = "flowhosts_type",
|
||||
value = "ip_version_4",
|
||||
|
|
@ -122,15 +121,21 @@ local protocol_filters = {{
|
|||
}}
|
||||
|
||||
if flowstats["l4_protocols"] then
|
||||
for key, value in pairsByKeys(flowstats["l4_protocols"], asc) do
|
||||
local tmp_list = {}
|
||||
for key, value in pairs(flowstats["l4_protocols"], asc) do
|
||||
local num_proto = tonumber(key)
|
||||
local proto_name = l4_proto_to_string(key)
|
||||
|
||||
protocol_filters[#protocol_filters + 1] = {
|
||||
tmp_list[proto_name] = {
|
||||
key = "l4proto",
|
||||
value = num_proto,
|
||||
label = l4_proto_to_string(key)
|
||||
label = proto_name
|
||||
}
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
protocol_filters[#protocol_filters + 1] = value
|
||||
end
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
|
|
@ -147,15 +152,21 @@ local application_filters = {{
|
|||
}}
|
||||
|
||||
local ndpicatstats = ifstats["ndpi_categories"]
|
||||
for key, value in pairsByKeys(ndpicatstats, asc) do
|
||||
application_filters[#application_filters + 1] = {
|
||||
local tmp_list = {}
|
||||
for key, value in pairs(ndpicatstats) do
|
||||
local name = getCategoryLabel(key, value.category)
|
||||
tmp_list[name] = {
|
||||
key = "application",
|
||||
value = "cat_" .. value.category,
|
||||
label = getCategoryLabel(key, value.category),
|
||||
label = name,
|
||||
group = i18n("category")
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
application_filters[#application_filters + 1] = value
|
||||
end
|
||||
|
||||
for key, value in pairsByKeys(flowstats["ndpi"], asc) do
|
||||
application_filters[#application_filters + 1] = {
|
||||
key = "application",
|
||||
|
|
@ -178,18 +189,23 @@ if not isEmptyString(host) then
|
|||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
|
||||
tmp_list = {}
|
||||
for talk_to_host, num_flows in pairs(flowstats["talking_with"] or {}) do
|
||||
if talk_to_host ~= host then
|
||||
local hinfo = hostkey2hostinfo(talk_to_host)
|
||||
talking_with[#talking_with + 1] = {
|
||||
local name = hostinfo2label(hinfo)
|
||||
tmp_list[name] = {
|
||||
key = "talking_with",
|
||||
value = talk_to_host,
|
||||
label = hostinfo2label(hinfo) .. '(' .. num_flows .. ')',
|
||||
label = name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
talking_with[#talking_with + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "talking_with",
|
||||
label = i18n("flows_page.talking_with"),
|
||||
|
|
@ -218,7 +234,6 @@ if not isEmptyString(_GET["port"]) then
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
local status_filters = {{
|
||||
key = "alert_type",
|
||||
value = "",
|
||||
|
|
@ -249,18 +264,24 @@ for s, severity_details in pairsByField(alert_consts.severity_groups, "severity_
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
tmp_list = {}
|
||||
for status_key, status in pairs(flowstats["status"]) do
|
||||
if status.count > 0 then
|
||||
status_filters[#status_filters + 1] = {
|
||||
local name = alert_consts.alertTypeLabel(status_key, true --[[ no html --]] )
|
||||
tmp_list[name] = {
|
||||
group = i18n('flow_details.alerted_flows'),
|
||||
key = "alert_type",
|
||||
value = status_key,
|
||||
label = (alert_consts.alertTypeLabel(status_key, true --[[ no html --]] )) .. " (" ..
|
||||
format_utils.formatValue(status.count) .. ")"
|
||||
label = name .. " (" .. format_utils.formatValue(status.count) .. ")"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
status_filters[#status_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "alert_type",
|
||||
label = i18n("status"),
|
||||
|
|
@ -273,7 +294,7 @@ local tcp_state_filters = {{
|
|||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for _, entry in pairs({"established", "connecting", "closed", "reset"}) do
|
||||
for _, entry in pairs({"connecting", "closed", "established", "reset"}) do
|
||||
tcp_state_filters[#tcp_state_filters + 1] = {
|
||||
key = "tcp_flow_state",
|
||||
value = entry,
|
||||
|
|
@ -349,19 +370,24 @@ local host_pools = require "host_pools"
|
|||
local host_pools_instance = host_pools:create()
|
||||
local pools = host_pools_instance:get_all_pools()
|
||||
if (table.len(pools) > 1) then
|
||||
tmp_list = {}
|
||||
local pool_filters = {{
|
||||
key = "host_pool_id",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for _, pool in pairs(pools) do
|
||||
pool_filters[#pool_filters + 1] = {
|
||||
tmp_list[pool.name] = {
|
||||
key = "host_pool_id",
|
||||
value = pool.pool_id,
|
||||
label = pool.name
|
||||
}
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
pool_filters[#pool_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "host_pool_id",
|
||||
label = i18n("if_stats_config.add_rules_type_host_pool"),
|
||||
|
|
@ -378,14 +404,20 @@ if table.len(networks_stats) > 1 then
|
|||
label = i18n("all")
|
||||
}}
|
||||
|
||||
tmp_list = {}
|
||||
for n, local_network in pairs(networks_stats) do
|
||||
networks_filter[#networks_filter + 1] = {
|
||||
local name = getFullLocalNetworkName(local_network["network_key"])
|
||||
tmp_list[name] = {
|
||||
key = "network",
|
||||
value = local_network["network_id"],
|
||||
label = getFullLocalNetworkName(local_network["network_key"])
|
||||
label = name
|
||||
}
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
networks_filter[#networks_filter + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "network",
|
||||
label = i18n("flows_page.networks"),
|
||||
|
|
@ -404,13 +436,14 @@ if ntop.isPro() and interface.isPacketInterface() == false then
|
|||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
tmp_list = {}
|
||||
for _, device_list in pairs(devips or {}) do
|
||||
for dev_ip, dev_resolved_name in pairsByValues(device_list, asc) do
|
||||
local dev_name = dev_ip
|
||||
if not isEmptyString(dev_resolved_name) and dev_resolved_name ~= dev_name then
|
||||
dev_name = dev_resolved_name
|
||||
end
|
||||
exporter_filters[#exporter_filters + 1] = {
|
||||
tmp_list[dev_name] = {
|
||||
key = "deviceIP",
|
||||
value = dev_ip,
|
||||
label = dev_name
|
||||
|
|
@ -418,6 +451,10 @@ if ntop.isPro() and interface.isPacketInterface() == false then
|
|||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
exporter_filters[#exporter_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "deviceIP",
|
||||
label = i18n("flows_page.device_ip"),
|
||||
|
|
@ -427,26 +464,32 @@ if ntop.isPro() and interface.isPacketInterface() == false then
|
|||
end
|
||||
end
|
||||
|
||||
if ntop.isPro() and not isEmptyString(_GET["deviceIP"]) then
|
||||
local dev_ip = _GET["deviceIP"]
|
||||
if ntop.isPro() and not isEmptyString(_GET["deviceIP"]) then
|
||||
local dev_ip = _GET["deviceIP"]
|
||||
-- Flow exporter requested
|
||||
local in_ports = {{
|
||||
key = "inIfIdx",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local ports_table = interface.getFlowDeviceInfo(dev_ip, true --[[ Show minimal info ]])
|
||||
local ports_table = interface.getFlowDeviceInfo(dev_ip, true --[[ Show minimal info ]] )
|
||||
|
||||
tmp_list = {}
|
||||
for _, ports in pairs(ports_table) do
|
||||
for portidx, _ in pairsByKeys(ports, asc) do
|
||||
in_ports[#in_ports + 1] = {
|
||||
local name = format_portidx_name(dev_ip, portidx)
|
||||
tmp_list[name] = {
|
||||
key = "inIfIdx",
|
||||
value = portidx,
|
||||
label = format_portidx_name(dev_ip, portidx)
|
||||
label = name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
in_ports[#in_ports + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "inIfIdx",
|
||||
label = i18n("db_search.input_snmp"),
|
||||
|
|
@ -462,25 +505,31 @@ if ntop.isPro() and not isEmptyString(_GET["deviceIP"]) then
|
|||
label = i18n("all")
|
||||
}}
|
||||
local ports_table = interface.getFlowDeviceInfo(dev_ip, false)
|
||||
|
||||
|
||||
tmp_list = {}
|
||||
for _, ports in pairs(ports_table) do
|
||||
for portidx, _ in pairsByKeys(ports, asc) do
|
||||
out_ports[#out_ports + 1] = {
|
||||
local name = format_portidx_name(dev_ip, portidx)
|
||||
tmp_list[name] = {
|
||||
key = "outIfIdx",
|
||||
value = portidx,
|
||||
label = format_portidx_name(dev_ip, portidx)
|
||||
label = name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
out_ports[#out_ports + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "outIfIdx",
|
||||
label = i18n("db_search.output_snmp"),
|
||||
name = "outIfIdx",
|
||||
value = out_ports,
|
||||
value = out_ports,
|
||||
show_with_value = dev_ip,
|
||||
show_with_key = "deviceIP"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
rest_utils.answer(rest_utils.consts.success.ok, rsp)
|
||||
|
|
|
|||
|
|
@ -6,160 +6,165 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|||
package.path = dirs.installdir .. "/scripts/lua/modules/pools/?.lua;" .. package.path
|
||||
|
||||
require "label_utils"
|
||||
require "lua_utils_gui"
|
||||
require "http_lint"
|
||||
require "lua_utils_get"
|
||||
local rest_utils = require "rest_utils"
|
||||
local rsp = {}
|
||||
|
||||
local ip_version_filters = {{
|
||||
key = "version",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
key = "version",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}, {
|
||||
key = "version",
|
||||
value = "4",
|
||||
label = i18n("flows_page.ipv4_only")
|
||||
key = "version",
|
||||
value = "4",
|
||||
label = i18n("flows_page.ipv4_only")
|
||||
}, {
|
||||
key = "version",
|
||||
value = "6",
|
||||
label = i18n("flows_page.ipv6_only")
|
||||
key = "version",
|
||||
value = "6",
|
||||
label = i18n("flows_page.ipv6_only")
|
||||
}}
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "version",
|
||||
label = i18n("flows_page.ip_version"),
|
||||
name = "version",
|
||||
value = ip_version_filters
|
||||
action = "version",
|
||||
label = i18n("flows_page.ip_version"),
|
||||
name = "version",
|
||||
value = ip_version_filters
|
||||
}
|
||||
|
||||
local networks_stats = interface.getNetworksStats() or {}
|
||||
if table.len(networks_stats) > 1 then
|
||||
local network_filters = {{
|
||||
key = "network",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for n, local_network in pairs(networks_stats) do
|
||||
local network_name = getFullLocalNetworkName(local_network["network_key"])
|
||||
network_filters[#network_filters + 1] = {
|
||||
key = "network",
|
||||
value = local_network["network_id"],
|
||||
label = network_name
|
||||
}
|
||||
end
|
||||
local network_filters = {{
|
||||
key = "network",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local tmp_list = {}
|
||||
for n, local_network in pairs(networks_stats) do
|
||||
local network_name = getFullLocalNetworkName(local_network["network_key"])
|
||||
tmp_list[network_name] = {
|
||||
key = "network",
|
||||
value = local_network["network_id"],
|
||||
label = network_name
|
||||
}
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "network",
|
||||
label = i18n("pools.pool_name.local_network"),
|
||||
name = "network",
|
||||
value = network_filters
|
||||
}
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
network_filters[#network_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "network",
|
||||
label = i18n("pools.pool_name.local_network"),
|
||||
name = "network",
|
||||
value = network_filters
|
||||
}
|
||||
end
|
||||
|
||||
local vlans = interface.getVLANsList()
|
||||
if vlans then
|
||||
local vlan_filters = {{
|
||||
key = "vlan",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for _, vlan in pairs(vlans.VLANs) do
|
||||
local vlan_name = tostring(getFullVlanName(vlan["vlan_id"]))
|
||||
if isEmptyString(vlan_name) then
|
||||
vlan_name = i18n('no_vlan')
|
||||
end
|
||||
vlan_filters[#vlan_filters + 1] = {
|
||||
key = "vlan",
|
||||
value = vlan["vlan_id"],
|
||||
label = vlan_name
|
||||
}
|
||||
end
|
||||
local vlan_filters = {{
|
||||
key = "vlan",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for _, vlan in pairs(vlans.VLANs) do
|
||||
local vlan_name = tostring(getFullVlanName(vlan["vlan_id"]))
|
||||
if isEmptyString(vlan_name) then
|
||||
vlan_name = i18n('no_vlan')
|
||||
end
|
||||
vlan_filters[#vlan_filters + 1] = {
|
||||
key = "vlan",
|
||||
value = vlan["vlan_id"],
|
||||
label = vlan_name
|
||||
}
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "vlan",
|
||||
label = i18n("flows_page.vlan"),
|
||||
name = "vlan",
|
||||
value = vlan_filters
|
||||
}
|
||||
rsp[#rsp + 1] = {
|
||||
action = "vlan",
|
||||
label = i18n("flows_page.vlan"),
|
||||
name = "vlan",
|
||||
value = vlan_filters
|
||||
}
|
||||
end
|
||||
|
||||
local direction_filters = {{
|
||||
key = "traffic_type",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
key = "traffic_type",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}, {
|
||||
key = "traffic_type",
|
||||
value = "one_way",
|
||||
label = i18n("hosts_stats.traffic_type_one_way")
|
||||
key = "traffic_type",
|
||||
value = "one_way",
|
||||
label = i18n("hosts_stats.traffic_type_one_way")
|
||||
}, {
|
||||
key = "traffic_type",
|
||||
value = "bidirectional",
|
||||
label = i18n("hosts_stats.traffic_type_two_ways")
|
||||
key = "traffic_type",
|
||||
value = "bidirectional",
|
||||
label = i18n("hosts_stats.traffic_type_two_ways")
|
||||
}}
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "traffic_type",
|
||||
label = i18n("flows_page.direction"),
|
||||
name = "traffic_type",
|
||||
value = direction_filters
|
||||
action = "traffic_type",
|
||||
label = i18n("flows_page.direction"),
|
||||
name = "traffic_type",
|
||||
value = direction_filters
|
||||
}
|
||||
|
||||
local hosts_filters = {{
|
||||
key = "mode",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
key = "mode",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "blacklisted",
|
||||
label = i18n("hosts_stats.blacklisted_hosts_only")
|
||||
key = "mode",
|
||||
value = "blacklisted",
|
||||
label = i18n("hosts_stats.blacklisted_hosts_only")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "broadcast_multicast",
|
||||
label = i18n("hosts_stats.broadcast_and_multicast")
|
||||
key = "mode",
|
||||
value = "broadcast_multicast",
|
||||
label = i18n("hosts_stats.broadcast_and_multicast")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "local",
|
||||
label = i18n("hosts_stats.local_hosts_only")
|
||||
key = "mode",
|
||||
value = "local",
|
||||
label = i18n("hosts_stats.local_hosts_only")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "local_no_tx",
|
||||
label = i18n("hosts_stats.local_no_tx")
|
||||
key = "mode",
|
||||
value = "local_no_tx",
|
||||
label = i18n("hosts_stats.local_no_tx")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "local_no_tcp_tx",
|
||||
label = i18n("hosts_stats.local_no_tcp_tx")
|
||||
key = "mode",
|
||||
value = "local_no_tcp_tx",
|
||||
label = i18n("hosts_stats.local_no_tcp_tx")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "remote",
|
||||
label = i18n("hosts_stats.remote_hosts_only")
|
||||
key = "mode",
|
||||
value = "remote",
|
||||
label = i18n("hosts_stats.remote_hosts_only")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "remote_no_tx",
|
||||
label = i18n("hosts_stats.remote_no_tx")
|
||||
key = "mode",
|
||||
value = "remote_no_tx",
|
||||
label = i18n("hosts_stats.remote_no_tx")
|
||||
}, {
|
||||
key = "mode",
|
||||
value = "remote_no_tcp_tx",
|
||||
label = i18n("hosts_stats.remote_no_tcp_tx")
|
||||
key = "mode",
|
||||
value = "remote_no_tcp_tx",
|
||||
label = i18n("hosts_stats.remote_no_tcp_tx")
|
||||
}}
|
||||
|
||||
if interface.isPacketInterface() and not interface.isPcapDumpInterface() then
|
||||
hosts_filters[#hosts_filters + 1] = {
|
||||
key = "mode",
|
||||
value = "broadcast_domain",
|
||||
label = i18n("hosts_stats.broadcast_domain_hosts_only")
|
||||
}
|
||||
hosts_filters[#hosts_filters + 1] = {
|
||||
key = "mode",
|
||||
value = "dhcp",
|
||||
label = i18n("mac_stats.dhcp_only")
|
||||
}
|
||||
hosts_filters[#hosts_filters + 1] = {
|
||||
key = "mode",
|
||||
value = "broadcast_domain",
|
||||
label = i18n("hosts_stats.broadcast_domain_hosts_only")
|
||||
}
|
||||
hosts_filters[#hosts_filters + 1] = {
|
||||
key = "mode",
|
||||
value = "dhcp",
|
||||
label = i18n("mac_stats.dhcp_only")
|
||||
}
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "mode",
|
||||
label = i18n("hosts_stats.filter_hosts"),
|
||||
name = "mode",
|
||||
value = hosts_filters
|
||||
action = "mode",
|
||||
label = i18n("hosts_stats.filter_hosts"),
|
||||
name = "mode",
|
||||
value = hosts_filters
|
||||
}
|
||||
|
||||
-- Host pools
|
||||
|
|
@ -167,57 +172,135 @@ local host_pools = require "host_pools"
|
|||
local host_pools_instance = host_pools:create()
|
||||
local pools = host_pools_instance:get_all_pools()
|
||||
if (table.len(pools) > 1) then
|
||||
local pool_filters = {{
|
||||
key = "pool",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for _, pool in pairs(pools) do
|
||||
pool_filters[#pool_filters + 1] = {
|
||||
key = "pool",
|
||||
value = pool.pool_id,
|
||||
label = pool.name
|
||||
}
|
||||
end
|
||||
local pool_filters = {{
|
||||
key = "pool",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local tmp_list = {}
|
||||
for _, pool in pairs(pools) do
|
||||
tmp_list[pool.name] = {
|
||||
key = "pool",
|
||||
value = pool.pool_id,
|
||||
label = pool.name
|
||||
}
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "pool",
|
||||
label = i18n("if_stats_config.add_rules_type_host_pool"),
|
||||
name = "pool",
|
||||
value = pool_filters
|
||||
}
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
pool_filters[#pool_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "pool",
|
||||
label = i18n("if_stats_config.add_rules_type_host_pool"),
|
||||
name = "pool",
|
||||
value = pool_filters
|
||||
}
|
||||
end
|
||||
|
||||
if ntop.isPro() then
|
||||
local flowdevs = interface.getFlowDevices() or {}
|
||||
local devips = getProbesName(flowdevs)
|
||||
if table.len(devips) > 0 then
|
||||
local exporter_filters = {{
|
||||
key = "deviceIP",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
for interface, device_list in pairs(devips or {}) do
|
||||
for dev_ip, dev_resolved_name in pairsByValues(device_list, asc) do
|
||||
local dev_name = dev_ip
|
||||
if not isEmptyString(dev_resolved_name) and dev_resolved_name ~= dev_name then
|
||||
dev_name = dev_resolved_name
|
||||
local flowdevs = interface.getFlowDevices() or {}
|
||||
local devips = getProbesName(flowdevs)
|
||||
if table.len(devips) > 0 then
|
||||
local exporter_filters = {{
|
||||
key = "deviceIP",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local tmp_list = {}
|
||||
for interface, device_list in pairs(devips or {}) do
|
||||
for dev_ip, dev_resolved_name in pairsByValues(device_list, asc) do
|
||||
local dev_name = dev_ip
|
||||
if not isEmptyString(dev_resolved_name) and dev_resolved_name ~= dev_name then
|
||||
dev_name = dev_resolved_name
|
||||
end
|
||||
tmp_list[dev_name] = {
|
||||
key = "deviceIP",
|
||||
value = dev_ip,
|
||||
label = dev_name
|
||||
}
|
||||
end
|
||||
exporter_filters[#exporter_filters + 1] = {
|
||||
key = "deviceIP",
|
||||
value = dev_ip,
|
||||
label = dev_name
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "deviceIP",
|
||||
label = i18n("flows_page.device_ip"),
|
||||
name = "deviceIP",
|
||||
value = exporter_filters
|
||||
}
|
||||
end
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
exporter_filters[#exporter_filters + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "deviceIP",
|
||||
label = i18n("flows_page.device_ip"),
|
||||
name = "deviceIP",
|
||||
value = exporter_filters
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
if ntop.isPro() and not isEmptyString(_GET["deviceIP"]) then
|
||||
local dev_ip = _GET["deviceIP"]
|
||||
-- Flow exporter requested
|
||||
local in_ports = {{
|
||||
key = "inIfIdx",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local ports_table = interface.getFlowDeviceInfo(dev_ip, true --[[ Show minimal info ]] )
|
||||
|
||||
local tmp_list = {}
|
||||
for _, ports in pairs(ports_table) do
|
||||
for portidx, _ in pairsByKeys(ports, asc) do
|
||||
local name = format_portidx_name(dev_ip, portidx)
|
||||
tmp_list[name] = {
|
||||
key = "inIfIdx",
|
||||
value = portidx,
|
||||
label = name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
in_ports[#in_ports + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "inIfIdx",
|
||||
label = i18n("db_search.input_snmp"),
|
||||
name = "inIfIdx",
|
||||
value = in_ports,
|
||||
show_with_value = dev_ip,
|
||||
show_with_key = "deviceIP"
|
||||
}
|
||||
|
||||
local out_ports = {{
|
||||
key = "outIfIdx",
|
||||
value = "",
|
||||
label = i18n("all")
|
||||
}}
|
||||
local ports_table = interface.getFlowDeviceInfo(dev_ip, false)
|
||||
|
||||
tmp_list = {}
|
||||
for _, ports in pairs(ports_table) do
|
||||
for portidx, _ in pairsByKeys(ports, asc) do
|
||||
local name = format_portidx_name(dev_ip, portidx)
|
||||
tmp_list[name] = {
|
||||
key = "outIfIdx",
|
||||
value = portidx,
|
||||
label = name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for _, value in pairsByKeys(tmp_list, asc) do
|
||||
out_ports[#out_ports + 1] = value
|
||||
end
|
||||
|
||||
rsp[#rsp + 1] = {
|
||||
action = "outIfIdx",
|
||||
label = i18n("db_search.output_snmp"),
|
||||
name = "outIfIdx",
|
||||
value = out_ports,
|
||||
show_with_value = dev_ip,
|
||||
show_with_key = "deviceIP"
|
||||
}
|
||||
end
|
||||
|
||||
rest_utils.answer(rest_utils.consts.success.ok, rsp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue