jpreed00
jpreed00

Reputation: 893

What's the command line for rrdtool to create a graph using the last update time as the end time?

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?

Upvotes: 1

Views: 876

Answers (1)

Tobi Oetiker
Tobi Oetiker

Reputation: 5450

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

Upvotes: 2

Related Questions