Moved active monitoring endpoints to am module and improved rest (#10239)

This commit is contained in:
GabrieleDeri 2026-04-01 15:50:39 +02:00 committed by GitHub
parent 2d7512339a
commit 05ebf3bdeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 364 additions and 275 deletions

View 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