mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
rrd extraction converts bytes to bits, but leaves unchanged packets, drops, and counters
This commit is contained in:
parent
54d1a11b39
commit
fe334c908f
1 changed files with 14 additions and 4 deletions
|
|
@ -1248,12 +1248,22 @@ function singlerrd2json(ifid, host, rrdFile, start_time, end_time, rickshaw_json
|
|||
local names_cache = {}
|
||||
local series = {}
|
||||
local prefixLabel = l4Label(string.gsub(rrdFile, ".rrd", ""))
|
||||
-- with a scaling factor we can stretch or shrink rrd values
|
||||
-- by default we set this to a value of 8, in order to convert bytes
|
||||
-- rrds into bits.
|
||||
local scaling_factor = 8
|
||||
|
||||
-- io.write(prefixLabel.."\n")
|
||||
if(prefixLabel == "Bytes") then
|
||||
prefixLabel = "Traffic"
|
||||
end
|
||||
|
||||
if(string.contains(rrdFile, "num_") or string.contains(rrdFile, "packets") or string.contains(rrdFile, "drops"))
|
||||
then
|
||||
-- do not scale number, packets, and drops
|
||||
scaling_factor = 1
|
||||
end
|
||||
|
||||
if(not ntop.notEmptyFile(rrdname)) then return '{}' end
|
||||
|
||||
local fstart, fstep, fnames, fdata = ntop.rrd_fetch(rrdname, 'AVERAGE', start_time, end_time)
|
||||
|
|
@ -1291,9 +1301,7 @@ function singlerrd2json(ifid, host, rrdFile, start_time, end_time, rickshaw_json
|
|||
end
|
||||
end
|
||||
|
||||
if(prefixLabel == "Traffic") then
|
||||
w = w * 8
|
||||
end -- convery bytes in bits
|
||||
w = w * scaling_factor
|
||||
|
||||
if (s[elemId] == nil) then s[elemId] = 0 end
|
||||
s[elemId] = s[elemId] + w
|
||||
|
|
@ -1355,7 +1363,9 @@ function singlerrd2json(ifid, host, rrdFile, start_time, end_time, rickshaw_json
|
|||
totalval = totalval + tot
|
||||
end
|
||||
|
||||
if(prefixLabel == "Traffic") then totalval = totalval/8. end -- convert bits to bytes
|
||||
-- total val is always returned without any scaling. for this reason
|
||||
-- this time we divide by the (previously multiplied) scaling factor
|
||||
totalval = totalval / scaling_factor
|
||||
|
||||
local percentile = 0.95*maxval
|
||||
local average = totalval / num_points
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue