[rrd-users] rrdtool graph confusion

Simon Hobson linux at thehobsons.co.uk
Tue Jul 1 21:18:39 CEST 2008


Emily Chouinard wrote:

>2nd I'm trying to comment the current date at the bottom of my graph but
>am so far unsuccessful. I've tried  COMMENT:"%m/%d/%Y %H\:%M\:%S",  and
>I tried declaring cur_date = '%m/%d/%Y %H\:%M\:%S' and then commenting
>cur_date COMMENT:"' + cur_date + '" and neither are working for me.  I
>get the following error:
>
>  Traceback (most recent call last):
>   File "cpu_usage.py", line 78, in ?
>  ' COMMENT:"' + cur_date + '"')
>rrdtool.error: Could not make sense out of ' COMMENT:"%m/%d/%Y %H\:%M\:%S"'

Well in my scripts (Bash) I use these statements to get the date on 
the graphs :

Early in the bash script :
   Etime=`/bin/date +%s`
   Etime=$(( ${Etime} / ${Step} * ${Step} ))
   PrintedTime=$(/bin/date -d "19700101 00:00 +0000 ${Etime}sec" 
+"%H\:%M %a %d %b %Y")

Then in the graph definition :
   COMMENT:"    Data to ${PrintedTime}\n"

What is happening here is that I get the current time in seconds 
since epoch, round it down to the last whole multiple of the step 
size, then get date to convert this to a textual representation. Note 
that "%H\:%M %a %d %b %Y" is converted by date to a text string like 
"20\:10 Tue 01 Jul 2008", it is NOT processed by the rrd tools.

The end result id my graph has a string like "20:10 Tue 01 Jul 2008" on it.

It looks like you are trying to get rrd to interpret the date string, 
something I don't think I managed to get exactly right IIRC - it's a 
long time now since I wrote my first script, and newer ones have been 
"copy and adapt" derivatives.



More information about the rrd-users mailing list