Optimizes second.lua callback

This commit is contained in:
Simone Mainardi 2017-11-22 13:11:11 +01:00
parent 3f56c8f799
commit 6e3cb6324f
19 changed files with 181 additions and 207 deletions

View file

@ -7,6 +7,8 @@ package.path = dirs.installdir .. "/scripts/lua/modules/?/init.lua;" .. package.
local ntop_info = ntop.getInfo()
local os_utils = require "os_utils"
local host_pools_utils = {}
host_pools_utils.DEFAULT_POOL_ID = "0"
host_pools_utils.DEFAULT_ROUTING_POLICY_ID = "0"
@ -411,7 +413,7 @@ end
function host_pools_utils.getRRDBase(ifid, pool_id)
local dirs = ntop.getDirs()
return fixPath(dirs.workingdir .. "/" .. ifid .. "/host_pools/" .. pool_id)
return os_utils.fixPath(dirs.workingdir .. "/" .. ifid .. "/host_pools/" .. pool_id)
end
function host_pools_utils.updateRRDs(ifid, dump_ndpi, verbose)
@ -424,14 +426,14 @@ function host_pools_utils.updateRRDs(ifid, dump_ndpi, verbose)
end
-- Traffic stats
local rrdpath = fixPath(pool_base .. "/bytes.rrd")
local rrdpath = os_utils.fixPath(pool_base .. "/bytes.rrd")
createRRDcounter(rrdpath, 300, verbose)
ntop.rrd_update(rrdpath, nil, tolongint(pool_stats["bytes.sent"]), tolongint(pool_stats["bytes.rcvd"]))
-- nDPI stats
if dump_ndpi then
for proto,v in pairs(pool_stats["ndpi"] or {}) do
local ndpiname = fixPath(pool_base.."/"..proto..".rrd")
local ndpiname = os_utils.fixPath(pool_base.."/"..proto..".rrd")
createRRDcounter(ndpiname, 300, verbose)
ntop.rrd_update(ndpiname, nil, tolongint(v["bytes.sent"]), tolongint(v["bytes.rcvd"]))
end