rrdtool

Some notes I wish existed in my rrdtool journey

rrdtool docs

dumping min/max values from a time range with python


  import rrdtool

  temps = rrdtool.fetch("-s -24h","temperature.rrd","AVERAGE")
  mintemp = min(i[0] for i in temps[2] if i[0] is not None)
  maxtemp = max(i[0] for i in temps[2] if i[0] is not None)

graph / xport mess

setup a rrd without data names, the default becomes 'value'

VDEF can't be output with XPORT

making a pretty graph


  rrdtool graph \
  "$1" \
  --start end-$4 \
  --width 1200 \
  --height 600 \
  --step "$5" \
  --title "$3 sensors- $4" \
  --vertical-label "degrees C / Humidity %/2 " \
  --alt-autoscale \
  --right-axis-label "Pressure hPa" \
  --right-axis 1:988 \
  --left-axis-format %.1lf \
  --right-axis-format %.0lf \
  --color "BACK#303030" \
  --color "FONT#CCCCCC" \
  --color "CANVAS#111111" \
  "TEXTALIGN:left" \
  "DEF:temperature=$2/temperature.rrd:value:AVERAGE" \
  "DEF:humidity=$2/humidity.rrd:value:AVERAGE" \
  "DEF:pressure=$2/pressure.rrd:value:AVERAGE" \
  "DEF:dewpoint=$2/dewpoint.rrd:value:AVERAGE" \
  "AREA:temperature#00bc8c:temperature C" \
  "AREA:dewpoint#3498db:dewpoint C" \
  "CDEF:presplot=pressure,988,-"\
  "CDEF:halfhumid=humidity,.5,*"\
  "LINE2:presplot#e74c3c:Pressure hPa" \
  "LINE2:halfhumid#f39c12:Humidity %/2" \
  "VDEF:pmax=pressure,MAXIMUM" \
  "VDEF:pavg=pressure,AVERAGE" \
  "VDEF:pmin=pressure,MINIMUM" \
  "VDEF:ppmax=presplot,MAXIMUM" \
  "VDEF:ppavg=presplot,AVERAGE" \
  "VDEF:ppmin=presplot,MINIMUM" \
  "LINE1:ppmax#e74c3c:max pressure\\::dashes" \
  "GPRINT:pressure:MAX:%4.1lf" \
  "LINE1:ppmin#6610f2:min pressure\\::dashes" \
  "GPRINT:pressure:MIN:%4.1lf" \
  "VDEF:hmax=halfhumid,MAXIMUM" \
  "VDEF:havg=halfhumid,AVERAGE" \
  "VDEF:hmin=halfhumid,MINIMUM" \
  "LINE1:hmax#e74c3c:max humidity\\::dashes" \
  "GPRINT:humidity:MAX:%4.1lf" \
  "LINE1:hmin#6610f2:min humidity\\::dashes" \
  "GPRINT:humidity:MIN:%4.1lf" \
  "VDEF:tmax=temperature,MAXIMUM" \
  "VDEF:tavg=temperature,AVERAGE" \
  "VDEF:tmin=temperature,MINIMUM" \
  "LINE2:tmax#e74c3c:max temp\\::dashes" \
  "GPRINT:temperature:MAX:%4.1lf" \
  "LINE2:tmin#6610f2:min temp\\::dashes" \
  "GPRINT:temperature:MIN:%4.1lf" \
  --watermark "Drawn: $nowlit";
}