mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Fixes issues with ts
This commit is contained in:
parent
d27d94423f
commit
8c80fe895d
3 changed files with 67 additions and 34 deletions
|
|
@ -1,6 +1,9 @@
|
|||
--
|
||||
-- (C) 2021 - ntop.org
|
||||
--
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
|
||||
local driver = {}
|
||||
|
||||
-- NOTE: this script is required by second.lua, keep the imports minimal!
|
||||
|
|
@ -893,6 +896,28 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function driver:queryLastValues(options)
|
||||
local last_values = {}
|
||||
local rsp = self:timeseries_query(options)
|
||||
for _, data in pairs(rsp.series or {}) do
|
||||
local values = {}
|
||||
local max_val = ts_common.getMaxPointValue(options.schema_info, data.id, options.tags)
|
||||
for i = (#data.data), 1, -1 do
|
||||
if (#values == options.num_points) then
|
||||
break
|
||||
end
|
||||
-- nan check
|
||||
if data.data[i] == data.data[i] then
|
||||
values[#values + 1] = ts_common.normalizeVal(data.data[i], max_val, options)
|
||||
end
|
||||
end
|
||||
last_values[data.id] = values
|
||||
end
|
||||
return last_values
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function driver:timeseries_query(options)
|
||||
local metrics = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue