mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Optimizes rrd updates
This commit is contained in:
parent
f956f84236
commit
658f272cd5
2 changed files with 24 additions and 6 deletions
|
|
@ -849,13 +849,15 @@ end
|
|||
-- ########################################################
|
||||
|
||||
function create_rrd(name, step, ds)
|
||||
step = tonumber(step)
|
||||
if step == nil or step <= 1 then step = 1 end
|
||||
if(not(ntop.exists(name))) then
|
||||
if(enable_second_debug == 1) then io.write('Creating RRD ', name, '\n') end
|
||||
local prefs = ntop.getPrefs()
|
||||
ntop.rrd_create(
|
||||
name,
|
||||
step, -- step
|
||||
'DS:' .. ds .. ':DERIVE:5:U:U',
|
||||
'DS:' .. ds .. ':DERIVE:'.. step * 5 .. ':U:U',
|
||||
'RRA:AVERAGE:0.5:1:'..tostring(prefs.intf_rrd_raw_days*24*60*60), -- raw: 1 day = 86400
|
||||
'RRA:AVERAGE:0.5:60:'..tostring(prefs.intf_rrd_1min_days*24*60), -- 1 min resolution = 1 month
|
||||
'RRA:AVERAGE:0.5:3600:'..tostring(prefs.intf_rrd_1h_days*24), -- 1h resolution (3600 points) 2400 hours = 100 days
|
||||
|
|
@ -865,14 +867,16 @@ function create_rrd(name, step, ds)
|
|||
end
|
||||
end
|
||||
|
||||
function create_rrd_num(name, ds)
|
||||
function create_rrd_num(name, ds, step)
|
||||
step = tonumber(step)
|
||||
if step == nil or step <= 1 then step = 1 end
|
||||
if(not(ntop.exists(name))) then
|
||||
if(enable_second_debug == 1) then io.write('Creating RRD ', name, '\n') end
|
||||
local prefs = ntop.getPrefs()
|
||||
ntop.rrd_create(
|
||||
name,
|
||||
1, -- step
|
||||
'DS:' .. ds .. ':GAUGE:5:0:U',
|
||||
step, -- step
|
||||
'DS:' .. ds .. ':GAUGE:' .. step * 5 .. ':0:U',
|
||||
'RRA:AVERAGE:0.5:1:'..tostring(prefs.intf_rrd_raw_days*24*60*60), -- raw: 1 day = 86400
|
||||
'RRA:AVERAGE:0.5:3600:'..tostring(prefs.intf_rrd_1h_days*24), -- 1h resolution (3600 points) 2400 hours = 100 days
|
||||
'RRA:AVERAGE:0.5:86400:'..tostring(prefs.intf_rrd_1d_days) -- 1d resolution (86400 points) 365 days
|
||||
|
|
@ -885,9 +889,9 @@ function makeRRD(basedir, ifname, rrdname, step, value)
|
|||
local name = fixPath(basedir .. "/" .. rrdname .. ".rrd")
|
||||
|
||||
if(string.contains(rrdname, "num_")) then
|
||||
create_rrd_num(name, rrdname)
|
||||
create_rrd_num(name, rrdname, step)
|
||||
else
|
||||
create_rrd(name, 1, rrdname)
|
||||
create_rrd(name, step, rrdname)
|
||||
end
|
||||
ntop.rrd_update(name, "N:".. tolongint(value))
|
||||
if(enable_second_debug) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue