mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-11 10:58:17 +00:00
Moved active monitoring endpoints to am module and improved rest (#10239)
This commit is contained in:
parent
2d7512339a
commit
05ebf3bdeb
8 changed files with 364 additions and 275 deletions
40
scripts/lua/modules/interface_utils.lua
Normal file
40
scripts/lua/modules/interface_utils.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
--
|
||||
-- (C) 2013-26 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local json = require("dkjson")
|
||||
|
||||
local interface_utils = {}
|
||||
|
||||
function interface_utils.get_pingable_interfaces()
|
||||
local res = {}
|
||||
|
||||
local interfaces = ntop.getPingIfNames()
|
||||
|
||||
for id, ifname in pairs(interfaces) do
|
||||
local custom_name = getHumanReadableInterfaceName(ifname)
|
||||
|
||||
if isEmptyString(custom_name) then
|
||||
custom_name = nil
|
||||
end
|
||||
|
||||
-- Note: returning in a format compatible with /lua/rest/v2/get/ntopng/interfaces.lua
|
||||
res[#res + 1] = {
|
||||
ifid = tonumber(id),
|
||||
ifname = ifname,
|
||||
name = custom_name or ifname,
|
||||
is_packet_interface = true,
|
||||
is_pcap_interface = false,
|
||||
is_zmq_interface = false,
|
||||
}
|
||||
end
|
||||
return res
|
||||
|
||||
end
|
||||
|
||||
return interface_utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue