[rrd-users] ERROR: 'T' is not a valid function name - issue with spaces between double quotes?

stphnwallace whizbang.wallace at gmail.com
Tue Mar 20 08:46:57 CET 2012


Strong cup of coffee required before proceeding 

I have rrd setup as a service on a remote box using xinetd. I have been able
to echo command to this piping thru netcat, and been able to do creates,
updates, info, last, etc.

My end goal is to use rrdgraph against a remote rrdrsv, and show the
resulting graph in web interface thru PHP code.

I think I've uncovered a related bug whereby one cannot use spaces between
double quotes. Examples as follow;

This works;
[root at nagios httpd]# echo `cat /tmp/rrdgraph` | nc 192.168.122.32 13900

[root at nagios httpd]# cat /tmp/rrdgraph
graph sjw.png DEF:var1=localhost/_HOST_.rrd:1:AVERAGE
"CDEF:sp1=var1,100,/,12,*" "CDEF:sp2=var1,100,/,30,*"
"CDEF:sp3=var1,100,/,50,*" "CDEF:sp4=var1,100,/,70,*"
AREA:var1#FF5C00:"Round Trip Times " AREA:sp4#FF7C00: AREA:sp3#FF9C00:
AREA:sp2#FFBC00: AREA:sp1#FFDC00: GPRINT:var1:LAST:"%6.2lf ms last "
GPRINT:var1:MAX:"%6.2lf ms max " GPRINT:var1:AVERAGE:"%6.2lf ms avg \n"
LINE1:var1#000000:""

This does not work directly from command line, although it's exactly the
same code from /tmp/rrdgraph;

[root at nagios httpd]# echo "graph sjw.png
DEF:var1=localhost/_HOST_.rrd:1:AVERAGE "CDEF:sp1=var1,100,/,12,*"
"CDEF:sp2=var1,100,/,30,*" "CDEF:sp3=var1,100,/,50,*"
"CDEF:sp4=var1,100,/,70,*" AREA:var1#FF5C00:"Round* T*rip Times "
AREA:sp4#FF7C00: AREA:sp3#FF9C00: AREA:sp2#FFBC00: AREA:sp1#FFDC00:
GPRINT:var1:LAST:"%6.2lf ms last " GPRINT:var1:MAX:"%6.2lf ms max "
GPRINT:var1:AVERAGE:"%6.2lf ms avg \n" LINE1:var1#000000:""" | nc
192.168.122.32 13900
***snip****
*ERROR: 'T' is not a valid function name*

I've made the T in the command BOLD above to make it stand out. It's the
first letter of "Trip"

Now, when I remove the spaces from between the double quotes, it works;

[root at nagios httpd]# echo "graph sjw.png
DEF:var1=localhost/_HOST_.rrd:1:AVERAGE "CDEF:sp1=var1,100,/,12,*"
"CDEF:sp2=var1,100,/,30,*" "CDEF:sp3=var1,100,/,50,*"
"CDEF:sp4=var1,100,/,70,*" AREA:var1#FF5C00:"Round_Trip_Times "
AREA:sp4#FF7C00: AREA:sp3#FF9C00: AREA:sp2#FFBC00: AREA:sp1#FFDC00:
GPRINT:var1:LAST:"%6.2lf " GPRINT:var1:MAX:"%6.2lf "
GPRINT:var1:AVERAGE:"%6.2lf" LINE1:var1#000000:""" | nc 192.168.122.32 13900

....so, maybe I've found a bug here???

So, when I use the command line above, sjw.png gets created on the remote
server. If I change the sjw.png for a -, I see PNG style splat on the screen
as I would hope for. Now to sew this into a PHP script;
********
<?php

//set the document header so that this renders as an image
header("Content-type: image/png");

//this is the shell command that you want to execute
// $cmdString = 'echo `cat /tmp/rrdgraph` | /usr/bin/nc 192.168.122.32
13900';
//$cmdString = '`cat /tmp/rrdgraph` | /usr/bin/nc 192.168.122.32 13900';    
<******** If I store the rrd "graph" commands in a file, I get a 0 back, but
no PNG is created, nor any errors.
$cmdString = ' echo "graph - DEF:var1=localhost/_HOST_.rrd:1:AVERAGE
"CDEF:sp1=var1,100,/,12,*" "CDEF:sp2=var1,100,/,30,*"
"CDEF:sp3=var1,100,/,50,*" "CDEF:sp4=var1,100,/,70,*"
AREA:var1#FF5C00:"Round_Trip_Times " AREA:sp4#FF7C00: AREA:sp3#FF9C00:
AREA:sp2#FFBC00: AREA:sp1#FFDC00: GPRINT:var1:LAST:"%6.2lf "
GPRINT:var1:MAX:"%6.2lf " GPRINT:var1:AVERAGE:"%6.2lf" LINE1:var1#000000:"""
| nc 192.168.122.32 13900 ';        <*******This one is closest to working I
think

// $cmdString = 'echo "graph - DEF:var1=localhost/_HOST_.rrd:1:AVERAGE
CDEF:sp1=var1,100,/,12,* CDEF:sp2=var1,100,/,30,* CDEF:sp3=var1,100,/,50,*
CDEF:sp4=var1,100,/,70,* AREA:var1#FF5C00:"Round Trip Times "
AREA:sp4#FF7C00: AREA:sp3#FF9C00: AREA:sp2#FFBC00: AREA:sp1#FFDC00:
GPRINT:var1:LAST:"%6.2lf ms last " GPRINT:var1:MAX:"%6.2lf ms max "
GPRINT:var1:AVERAGE:"%6.2lf ms avg \n" LINE1:var1#000000:"""|/usr/bin/nc
192.168.122.32 13900';

//if I can see a hard-coded test that works, I can add the support that
would be needed on our end

//execute command and direct output to browser
passthru($cmdString,$bool);

$debugstring = "CMD: $cmdString RETURNCODE: $bool \n";

//lets create a simple log for debugging, keep a running tail on this.
file_put_contents('/tmp/debugger.log',$debugstring,FILE_APPEND);
//file_put_contents('/tmp/debugger.log',$debugstring,'a');      <*****
changed the "a" to FILE_APPEND :)

?>
*****

...when I check my PHP debug log, I see a zero, meaning everything is
"good"....but I see no graph displayed in my browser, nor any
/var/log/httpd/error_log message.

CMD:  echo "graph - DEF:var1=localhost/_HOST_.rrd:1:AVERAGE
"CDEF:sp1=var1,100,/,12,*" "CDEF:sp2=var1,100,/,30,*"
"CDEF:sp3=var1,100,/,50,*" "CDEF:sp4=var1,100,/,70,*"
AREA:var1#FF5C00:"Round_Trip_Times " AREA:sp4#FF7C00: AREA:sp3#FF9C00:
AREA:sp2#FFBC00: AREA:sp1#FFDC00: GPRINT:var1:LAST:"%6.2lf "
GPRINT:var1:MAX:"%6.2lf " GPRINT:var1:AVERAGE:"%6.2lf" LINE1:var1#000000:"""
| nc 192.168.122.32 13900  *RETURNCODE: 0 *

Perplexing. Anybody had any luck with getting around my "bug, and/or remote
PHP graph display????

Regs,

Stephen

--
View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/ERROR-T-is-not-a-valid-function-name-issue-with-spaces-between-double-quotes-tp7388328p7388328.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.



More information about the rrd-users mailing list