31.05.2024, 14:17
(31.05.2024, 07:15)admin Wrote: This will log all daily values with their respective offsets. If the whole list does not fit, you can change line 17 and add an extra offset. Just make sure that this extra offset is divisible by 8.
Code:infile = '/tmp/trends/t1.trend' values = {} ffi = require('ffi') function stringtodouble(chunk) local dbl = ffi.new('double[1]') ffi.copy(dbl, chunk, 8) return dbl[ 0 ] end info = require('rrd').info(infile) data = io.readfile(infile) offset = info.header_size + (info['rra[0].rows'] + info['rra[1].rows']) * 8 offset = offset + 0 * 8 while true do chunk = data:sub(offset + 1, offset + 8) if #chunk == 8 then value = stringtodouble(chunk) -- skip NaN (empty/undefined value) if value == value then values[ #values + 1 ] = string.format('%d %.1f', offset, value) end else break end offset = offset + 8 end text = table.concat(values, '\n') log(text)
Ok, using this one I've managed to update wrong values. Thanks!