[rrd-users] rrdtool graph confusion
yiannis at vavouranakis.gr
Tue Jul 1 21:36:44 CEST 2008
> I'm having 2 issues with the rrdtool graph command.
> 1st I can't seem to get the new line command to work, this is what I
> have in my code 'GPRINT:avgN:"Avg %6.2lf%%\n"', and when graphed the /n
> gives a character that look like a box ,, and I don't know how to deal
> with this.
> 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
> I'm probably missing something very basic (oh and I'm using python so
> thats why everything is being passed as a string)
> Thanks for all your help so far, I've really appreciated it!!!
a) As regards the issue with \l and \n, my guess is that python is messing
with the strings. Probably it actually escapes \n within the string, so
instead of passing the literal "blablabla\n" to the rrdtool backend
library, it parses the string, replaces the sequence "\n" with the actual
newline character and passes "blabla[newline]". The rrdtool library, in
turn, receives "blabla[newline]", and renders it as such. The net result is
that you get an uninterpretable character (the box) instead of a newline.
Probably the same happens with \l. Try escaping the escapes, (so instead of
\n, write \\n). If that doesn't work, try using raw strings (prepend the
string with r, so that instead of "blabla\n" you'll have r"blabla\n" -
notice the r is OUTSIDE the quotes). For more on escape sequences and raw
strings in python, I suggest you study the python manuals (they come bundled
with python itself).
b) I can't seem to make out ehat you're trying to do. Maybe post a larger
snippet of the code, so that I can understand what you're trying to achieve?
More information about the rrd-users