1

Going off of this question: Print time of recording for LAST value

It appears possible to have rrdtool compute the timestamp of the last update in a rrd. How do you use this in a command as the "end" time?

i.e. I want to do something like this:

rrdtool graph img.png -a PNG -s e-600 -e LASTUPDATETIME -v "CPU Usage" \
  --title "CPU Utilization" DEF:ds0a=node.rrd:ds0:AVERAGE \  
  DEF:ds1a=node.rrd:ds1:AVERAGE AREA:ds0a#35b73d:"User" \
  LINE1:ds1a#0400ff:"System"

I tried mucking about the DEF, CDEF and VDEF things to no avail:

rrdtool graph img.png -a PNG -v "CPU Usage" --title "CPU Utilization" \
  DEF:data=node.rrd:x:AVERAGE CDEF:count=data,UN,UNKN,COUNT,IF  \
  VDEF:last=count,MAXIMUM \
  DEF:ds0a=node.rrd:ds0:AVERAGE:start=end-600:end=last \
  DEF:ds1a=node.rrd:ds1:AVERAGE:start=end-600:end=last \
  AREA:ds0a#35b73d:"User" LINE1:ds1a#0400ff:"System" 

This results in:

ERROR: end time: unparsable time: last

Any ideas?

Community
  • 1
  • 1
jpreed00
  • 893
  • 8
  • 25

1 Answers1

2

on the command line, you could do

rrdtool graph img.png -a PNG -s e-600 -e `date +%s node.rrd` -v "CPU Usage" \
  --title "CPU Utilization" DEF:ds0a=node.rrd:ds0:AVERAGE \  
  DEF:ds1a=node.rrd:ds1:AVERAGE AREA:ds0a#35b73d:User \
  LINE1:ds1a#0400ff:System
Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23
  • Minor flaw in the command line, there needs to be a -r for the date command, but otherwise it works fine! Thanks very much! (`date +%s -r node.rrd`) – jpreed00 Jan 30 '16 at 21:43