[rrd-users] Getting a single row of data

mark mark at itbox.co.za
Fri Jun 12 12:12:14 CEST 2020


Hi,

I want to retrieve the latest one minute average from an rrd.


8<-------------------------------------------------------------------

root at store-power:~# cat createrrd
#!/bin/ash
rrdtool create /tmp/powermon.rrd                      \
--start `date +%s` --step 1                           \
DS:p1v:GAUGE:3:0:27000                                \
DS:p2v:GAUGE:3:0:27000                                \
DS:p3v:GAUGE:3:0:27000                                \
DS:p1p1:GAUGE:3:-20000:20000                          \
DS:p1p2:GAUGE:3:-20000:20000                          \
DS:p2p1:GAUGE:3:-20000:20000                          \
DS:p2p2:GAUGE:3:-20000:20000                          \
DS:p3p1:GAUGE:3:-20000:20000                          \
DS:p3p2:GAUGE:3:-20000:20000                          \
RRA:AVERAGE:0.5:1:300                                 \
RRA:AVERAGE:0.5:60:60

root at store-power:~# cat rrdfetch
#!/bin/sh
time=$(date +%s)
res=60
end=$(($time/$res*$res))
start=$(($end-60))
/usr/bin/rrdtool fetch /tmp/powermon.rrd AVERAGE -r $res -e $end -s $start

8<-------------------------------------------------------------------

That gets me two rows:

root at store-power:~# ./rrdfetch
timestamp    p1v               p2v               p3v p1p1              
p1p2              p2p1 p2p2              p3p1              p3p2

1591956180:  2.3100000000e+03  7.0010000000e+03  9.0010000000e+03 
2.3200000000e+03  7.0020000000e+03  9.0020000000e+03 2.3300000000e+03  
7.0030000000e+03  9.0030000000e+03
1591956240:  2.3100000000e+03  7.0010000000e+03  9.0010000000e+03 
2.3200000000e+03  7.0020000000e+03  9.0020000000e+03 2.3300000000e+03  
7.0030000000e+03  9.0030000000e+03

How do I just get the latest row?

-- 
Mark Ter Morshuizen



More information about the rrd-users mailing list