Skip to content

Instantly share code, notes, and snippets.

@sirleech
Created May 4, 2012 05:19
Show Gist options
  • Save sirleech/2592215 to your computer and use it in GitHub Desktop.
Save sirleech/2592215 to your computer and use it in GitHub Desktop.
RRDdata Temperature Database Example

Use this command to get the UNIX time

date +%s

Create a gauge RRD with a 60 second heartbeat

rrdtool create temperature.rrd --step 60 \
  DS:temp:GAUGE:600:-273:5000 \
  RRA:AVERAGE:0.5:1:1200 \
  RRA:MIN:0.5:12:2400 \
  RRA:MAX:0.5:12:2400 \
  RRA:AVERAGE:0.5:12:2400

Update the temperature with "NOW" and 26 degrees

rrdtool update temperature.rrd  N:26

Fetch the data

rrdtool fetch temperature.rrd AVERAGE --start 1336108660 --end 1336109700

Graph the data

rrdtool graph output.png                                 \
         --start 1336108660 --end 1336109700               \
         DEF:myspeed=temperature.rrd:temp:AVERAGE              \
         LINE2:myspeed#FF0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment