rrdtool tricks / tips

There are various different ways to generate rrdtool images. And most people will probably be generating elaborate ones out of perl or php scripts. The ones I am currently generating are built in a shell script (bash) and I was really having a problem with quotes and white space here for a while. If you generate the query and save it in a variable, the quotes go to hell and your white space (e.g. a space in a COMMENT) starts causing problems. my solution may not be the best, but it works without any trouble: Throw the whole command line into a temporary file and then use eval to create the graph. The following is not a complete statement, just a few lines as an example.

Select All Code:
1
2
3
4
TmpFile="$(mktemp)"
echo -n "--vertical-label example --title \"Title with spaces\"  " >> ${TmpFile}
echo -n 'COMMENT:"           Comment with spaces\l" ' >> ${TmpFile}
eval "/usr/bin/rrdtool graph output.png $(cat ${TmpFile}) >/dev/null"

Trackback URL

,

One Comment on "rrdtool tricks / tips"

  1. Novo
    03/05/2011 at 12:54 am Permalink

    Tjo, die Dinge können so simpel sein. Danke ;-)

Hi, leave a comment:


ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe to Comments