Add last RTT, IP and update time for RTT monitored hosts

This commit is contained in:
emanuele-f 2019-06-12 12:07:55 +02:00
parent 8a7487d868
commit 976de25de6
5 changed files with 86 additions and 6 deletions

View file

@ -10,12 +10,44 @@ local rtt_hosts_key = "ntopng.prefs.system_rtt_hosts"
-- ##############################################
local function rtt_last_updates_key(key)
return("ntopng.cache.system_rtt_hosts.last_update." .. key)
end
-- ##############################################
function rtt_utils.host2key(host, iptype, probetype)
return table.concat({host, iptype, probetype}, "@")
end
-- ##############################################
function rtt_utils.setLastRttUpdate(key, when, rtt, ipaddress)
ntop.setCache(rtt_last_updates_key(key), string.format("%u@%.2f@%s", when, rtt, ipaddress))
end
-- ##############################################
function rtt_utils.getLastRttUpdate(key)
local val = ntop.getCache(rtt_last_updates_key(key))
if(val ~= nil)then
local parts = string.split(val, "@")
if((parts ~= nil) and (#parts == 3)) then
return {
when = parts[1],
value = parts[2],
ip = parts[3],
}
end
end
return(nil)
end
-- ##############################################
function rtt_utils.key2label(key)
local parts = string.split(key, "@")