Rrdtool info
Jump to navigation
Jump to search
Landing point for RRD commands and examples
print the base info from an RRD database
- Looks like a cheap way to get last values from the database possibly to store for status dashboard without the graph generation
- This should be easily parsed in both bash and PHP for ds[NAME].last_ds
info
rrdtool info /opt/nmsApi/rrd/database.rrd filename = "/opt/nmsApi/rrd/database.rrd" rrd_version = "0003" step = 1 last_update = 1685326405 header_size = 1472 ds[temperature].index = 0 ds[temperature].type = "GAUGE" ds[temperature].minimal_heartbeat = 600 ds[temperature].min = 0.0000000000e+00 ds[temperature].max = 1.0000000000e+02 ds[temperature].last_ds = "31" ds[temperature].value = 1.4787341000e+01 ds[temperature].unknown_sec = 0 ds[humidity].index = 1 ds[humidity].type = "GAUGE" ds[humidity].minimal_heartbeat = 600 ds[humidity].min = 0.0000000000e+00 ds[humidity].max = 1.0000000000e+02 ds[humidity].last_ds = "65" ds[humidity].value = 3.1005715000e+01 ds[humidity].unknown_sec = 0 rra[0].cf = "AVERAGE" rra[0].rows = 3600 rra[0].cur_row = 3151 rra[0].pdp_per_row = 1 rra[0].xff = 5.0000000000e-01 rra[0].cdp_prep[0].value = NaN rra[0].cdp_prep[0].unknown_datapoints = 0 rra[0].cdp_prep[1].value = NaN rra[0].cdp_prep[1].unknown_datapoints = 0 rra[1].cf = "AVERAGE" rra[1].rows = 720 rra[1].cur_row = 501 rra[1].pdp_per_row = 60 rra[1].xff = 5.0000000000e-01 rra[1].cdp_prep[0].value = 7.7500000000e+02 rra[1].cdp_prep[0].unknown_datapoints = 0 rra[1].cdp_prep[1].value = 1.6250000000e+03 rra[1].cdp_prep[1].unknown_datapoints = 0 rra[2].cf = "AVERAGE" rra[2].rows = 24 rra[2].cur_row = 8 rra[2].pdp_per_row = 3600 rra[2].xff = 5.0000000000e-01 rra[2].cdp_prep[0].value = 2.4260961332e+04 rra[2].cdp_prep[0].unknown_datapoints = 0 rra[2].cdp_prep[1].value = 5.2791045244e+04 rra[2].cdp_prep[1].unknown_datapoints = 0
lastupdate
rrdtool lastupdate ../../rrd/database.rrd temperature humidity 1685328961: 31 65
last
Simply the last timestamp updated
rrdtool last ../../rrd/database.rrd 1685328961
Retrieve last set of metrics insrted
rrdtool lastupdate snmp/snmp-300.rrd Monitors Devices Time Memory 1685745404: 16 103 36 6291456 <.pre> == fetch == <pre> rrdtool fetch ../rrd/guyver-office.iwillfearnoevil.com/snmp/lm-sensors/temp.temp1_32.rrd AVERAGE -s "-1h" -e "now" -r 300 temp 1695225600: 3.0000000000e+01 1695225900: 3.0000000000e+01 1695226200: 3.0000000000e+01 1695226500: 3.0000000000e+01 1695226800: 3.0209333863e+01 1695227100: 3.1216119053e+01 1695227400: 3.1805992683e+01 1695227700: 3.0786713690e+01 1695228000: 3.0000000000e+01 1695228300: 3.0000000000e+01 1695228600: 3.0207707653e+01 1695228900: -nan 1695229200: -nan
Convert scientific to decimal
convert-scientific-notation-to-decimal-in-bash
printf "%.0f\n" 3.0207707653e+01 30
Convert fetch to csv
IFS=$'\n'; for x in $(rrdtool fetch ../rrd/guyver-office.iwillfearnoevil.com/snmp/lm-sensors/temp.temp1_32.rrd AVERAGE -s "-1h" -e "now" -r 300| grep ': '| grep -v 'nan'); do w=$(echo "$x" | awk -F ':' '{print $1}') ; y=$(echo "$x" | awk -F ':' '{print $2}') ; echo $w,$(printf "%.0f\n" $y) ; done 1695227400,32 1695227700,31 1695228000,30 1695228300,30 1695228600,30 1695228900,31 1695229200,31 1695229500,30 1695229800,31 1695230100,31 1695230400,31
IFS=$'\n'; for x in $(rrdtool fetch ../rrd/guyver-office.iwillfearnoevil.com/snmp/lm-sensors/temp.temp1_32.rrd AVERAGE -s "-1h" -e "now" -r 300| grep ': '| grep -v 'nan'); do w=$(echo "$x" | awk -F ':' '{print $1}') ; w=$(date -d @$w); y=$(echo "$x" | awk -F ':' '{print $2}') ; echo $w,$(printf "%.0f\n" $y) ; done Wed 20 Sep 2023 04:30:00 PM UTC,32 Wed 20 Sep 2023 04:35:00 PM UTC,31 Wed 20 Sep 2023 04:40:00 PM UTC,30 Wed 20 Sep 2023 04:45:00 PM UTC,30 Wed 20 Sep 2023 04:50:00 PM UTC,30 Wed 20 Sep 2023 04:55:00 PM UTC,31 Wed 20 Sep 2023 05:00:00 PM UTC,31 Wed 20 Sep 2023 05:05:00 PM UTC,30 Wed 20 Sep 2023 05:10:00 PM UTC,31 Wed 20 Sep 2023 05:15:00 PM UTC,31 Wed 20 Sep 2023 05:20:00 PM UTC,31