Prevent possible timestamp-based rrd_update errors from occurring

This commit is contained in:
emanuele-f 2019-08-02 11:52:40 +02:00
parent ebc204b0cc
commit b365cd28df

View file

@ -322,6 +322,19 @@ local function update_rrd(schema, rrdfile, timestamp, data, dont_recover)
traceError(TRACE_NORMAL, TRACE_CONSOLE, string.format("Going to update %s [%s]", schema.name, rrdfile))
end
-- Verify last update time
local last_update = ntop.rrd_lastupdate(rrdfile)
if((last_update ~= nil) and (timestamp <= last_update)) then
if isDebugEnabled() then
traceError(TRACE_NORMAL, TRACE_CONSOLE,
string.format("Skip RRD update in the past: timestamp=%u but last_update=%u",
timestamp, last_update))
end
return false
end
for _, metric in ipairs(schema._metrics) do
params[#params + 1] = tolongint(data[metric])
end