mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Implemement RTT monitoring configuration page
This commit is contained in:
parent
78e093af7f
commit
6aa72b53f7
12 changed files with 693 additions and 17 deletions
82
scripts/lua/modules/rtt_utils.lua
Normal file
82
scripts/lua/modules/rtt_utils.lua
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
--
|
||||
-- (C) 2019 - ntop.org
|
||||
--
|
||||
|
||||
local rtt_utils = {}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local rtt_hosts_key = "ntopng.prefs.system_rtt_hosts"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.host2key(host, iptype, probetype)
|
||||
return table.concat({host, iptype, probetype}, "@")
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.key2label(key)
|
||||
local parts = string.split(key, "@")
|
||||
|
||||
if((parts ~= nil) and (#parts == 3)) then
|
||||
-- TODO improve
|
||||
return(string.format("%s [%s] (%s)", parts[1], parts[2], string.upper(parts[3])))
|
||||
end
|
||||
|
||||
return key
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.deserializeHost(val)
|
||||
local parts = string.split(val, "|")
|
||||
|
||||
if((parts ~= nil) and (#parts == 4)) then
|
||||
local value = {
|
||||
host = parts[1],
|
||||
iptype = parts[2], -- ipv4 or ipv6
|
||||
probetype = parts[3],
|
||||
max_rtt = tonumber(parts[4]),
|
||||
}
|
||||
|
||||
return(value)
|
||||
end
|
||||
|
||||
return(nil)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.getHostsSerialized()
|
||||
return(ntop.getHashAllCache(rtt_hosts_key) or {})
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.getHosts()
|
||||
local hosts = rtt_utils.getHostsSerialized()
|
||||
local rv = {}
|
||||
|
||||
for host, val in pairs(hosts) do
|
||||
rv[host] = rtt_utils.deserializeHost(val)
|
||||
end
|
||||
|
||||
return(rv)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.addHost(host, value)
|
||||
ntop.setHashCache(rtt_hosts_key, host, value)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function rtt_utils.removeHost(host)
|
||||
ntop.delHashCache(rtt_hosts_key, host)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return(rtt_utils)
|
||||
Loading…
Add table
Add a link
Reference in a new issue