Improved storage utilization bar

This commit is contained in:
Alfredo Cardigliano 2019-06-26 17:57:49 +02:00
parent b7da5b2840
commit b29894d9bb
4 changed files with 78 additions and 37 deletions

View file

@ -21,7 +21,7 @@ local storage_utils = {}
-- #################################
function storage_utils.interfaceStorageInfo(ifid)
local info = { total = 0}
local info = { total = 0 }
local key = "ntopng.cache."..ifid..".storage_info"
local info_json = ntop.getCache(key)
@ -47,7 +47,9 @@ function storage_utils.interfaceStorageInfo(ifid)
local pcap_storage_info = recording_utils.storageInfo(ifid)
local total_pcap_dump_used = (pcap_storage_info.if_used + pcap_storage_info.extraction_used)
info["pcap"] = total_pcap_dump_used
info["total"] = info["total"] + total_pcap_dump_used
if dirs.pcapdir == dirs.workingdir then
info["total"] = info["total"] + total_pcap_dump_used
end
end
-- end
@ -61,15 +63,25 @@ end
function storage_utils.storageInfo()
local ifnames = interface.getIfNames()
local info = { total = 0, interfaces = {} }
local info = { total = 0, pcap_total = 0, interfaces = {} }
for id, name in pairs(ifnames) do
local ifid = tonumber(id)
local if_info = storage_utils.interfaceStorageInfo(ifid)
info.interfaces[ifid] = if_info
info.total = info.total + if_info.total
if if_info.pcap ~= nil then
info.pcap_total = info.pcap_total + if_info.pcap
end
end
local volume_info = recording_utils.volumeInfo(dirs.workingdir)
info.system = volume_info.used - info.total
info.avail = volume_info.avail
info.volume_size = volume_info.total
info.volume_mount = volume_info.mount
info.volume_dev = volume_info.dev
return info
end