[rrd-users] Re: printing last update and last values in web pages via rrdcgi?

Tobias Oetiker oetiker at ee.ethz.ch
Tue Sep 28 23:20:14 MEST 1999


Today you sent me mail regarding Re: [rrd-users] Re: printing last update...:

*>  > *> Like Bryce as root <root at zen.ics.uwe.ac.uk> asked the other day,
*>  > *> can rrdcgi to generate *HTML* like the following?  If so, how?
*>  > *> 
*>  > *>  The statistics were last updated <B>Tuesday, 28 Sep 1999 at 13:25</B>
*>  > *>  [...]
*>  > *>  <TD ALIGN=right>
*>  > *>    <SMALL>Average<FONT COLOR=#00cc00>&nbsp;In:</FONT></SMALL>
*>  > *>  </TD>
*>  > *>  <TD ALIGN=right>
*>  > *>    <SMALL>1012.1 kbits/s</SMALL>
*>  > *>  </TD>
*>  
*>  > From: Tobias Oetiker
*>  > sure ... jsut replace GPRINT by PRINT
*> 
*> Well, I tried that of course!  It doesn't work.  So I glanced
*> at the Source and, quite by accident, found that the following
*> works: 
*> 
*>  <RRD::PRINT DEF:myspeed=test.rrd:speed:AVERAGE
*>    PRINT:realspeed:AVERAGE:"ave %.2lf %Sb/s">
*> 
*> Then, on a hunch, I tried
*> 
*>  <RRD::GRAPH test.gif
*>   DEF:myspeed=test.rrd:speed:AVERAGE CDEF:realspeed=myspeed,1000,*
*>   LINE2:realspeed#FF0000
*>   PRINT:realspeed:AVERAGE:"ave %.2lf %Sb/s"
*>  >
*>  <RRD::PRINT realspeed>
*> 
*> which also works.
*> 
*> The doc for the rrdcgi <RRD::PRINT> tag is, with all due respect
*> (to the RRDtool guru), simply not in sync with reality.  Perhaps it
*> should read
*> 
*>  RRD::PRINT vname
*> 
*>  If the preceding RRD::GRAPH tag contained one or more PRINT
*>  arguments, then you can use this tag to print the output of 
*>  the PRINT argument for the variable named "vname".

no it should not ... the code responsible for printing is

char* drawprint(long argc, char **args){
  if (argc>=1 && calcpr != NULL){
    long i=0;
    while (calcpr[i] != NULL) i++; /*determine number lines in calcpr*/
    if (atol(args[0])<i-1)
      return calcpr[atol(args[0])+1];    
  }
  return stralloc("[ERROR: RRD::PRINT argument error]");
}

its a purly positional thing ... 

as it hapens a string gets translated into 0 by atol so if you use

<RRD::PRINT 0> as explained in the documentation you should get the correct
result ... again, improvements to the docs are more than welcome ...

cheers
tobi

*> later
*> steve
*> - - -
*> systems guy
*> wiscnet.net
*> 

-- 
 ______    __   _
/_  __/_  / /  (_) Oetiker, Timelord & SysMgr @ EE-Dept ETH-Zurich
 / // _ \/ _ \/ / TEL: +41(0)1-6325286  FAX:...1517  ICQ: 10419518 
/_/ \.__/_.__/_/ oetiker at ee.ethz.ch http://ee-staff.ethz.ch/~oetiker

--
* To unsubscribe from the rrd-users mailing list, send a message with the
  subject: unsubscribe to rrd-users-request at list.ee.ethz.ch



More information about the rrd-users mailing list