On Fri, Sep 12, 2008 at 13:33, Carlo Marcelo Arenas Belon
<[EMAIL PROTECTED]> wrote:
> Jessie,

"Jesse," actually. :-)

> the following commit (r1754 in ganglia's svn) seems to be patching the fix
> proposed by Jason as part of BUG37 and that was committed in r1595 and has
> been left unconsistent (as not all uses of this feature has been converted
> to use /dev/null).

Then the other instances should be converted, IMO.  I looked at this
one specifically since it was causing trouble on a local install
running trunk.  Specifically, the error was:

PHP Notice:  Undefined offset:  1 in
/home/beckerjes/ganglia/versions/trunk/monitor-core/web-working/functions.php
on line 266, referer:
http://saturn/ganglia-jb/?m=load_one&r=hour&s=descending&hc=4&mc=2

Tracing this back, you get this function:
   249  
#-------------------------------------------------------------------------------
   250  #
   251  # Finds the avg of the given cluster & metric from the summary rrds.
   252  #
   253  function find_avg($clustername, $hostname, $metricname)
   254  {
   255     global $rrds, $start, $end;
   256     $avg = 0;
   257
   258     if ($hostname)
   259       $sum_dir = "$rrds/$clustername/$hostname";
   260     else
   261       $sum_dir = "$rrds/$clustername/__SummaryInfo__";
   262     $command = RRDTOOL . " graph /dev/null --start $start --end $end ".
   263       "DEF:avg='$sum_dir/$metricname.rrd':'sum':AVERAGE ".
   264       "PRINT:avg:AVERAGE:%.2lf ";
   265     exec($command, $out);
   266     $avg = $out[1];
   267     #echo "$sum_dir: avg($metricname)=$avg<br>\n";
   268     return $avg;
   269  }

After adding a one-line print let me see exactly the rrdtool command
getting called (rrdtool 1.2.26):

  /usr/bin/rrdtool graph '' --start -3600 --end N
DEF:avg='/long/path/to/rrds/__SummaryInfo__/cpu_num.rrd':'sum':AVERAGE
PRINT:avg:AVERAGE:%.2lf

(Or something to that effect, the test system is at home, and I'm not.
 I'm building this on the fly from the code.)

Sure enough, no output at all, and this causes line 266 to throw the
error.  I can reproduce this using rrdtool 1.2.23 and 1.2.26.  This
was specifically in the meta-view, but not in the cluster- or
host-views.

> I had been unable to reproduce any problem with the original patch using
> several different versions of rrdtool, but your comment seems to imply you
> had observed the problem somehow, could you elaborate on that?

I tested three cases:
  rrdtool -
  rrdtool ''
  rrdtool /dev/null

The only one that I could get to work consistently was 'rrdtool
/dev/null'.  This "trick" of using /dev/null is actually suggested in
a number of rrdtool mailing list threads for situations where you want
rrdtool to calculate a value, but suppress the generation of a graph.
I'd also like to note that there are no difference in syscalls between
using /dev/null and "rrdtool ''", so there should be no additional
cost between the two methods.  There are some between using a dash and
the other two, but I think that's because nothing is written to STDOUT
at all.

Of course, in the case of graph.php, we want 'rrdtool -', since the
graphs are generated in-line.

> but the solution proposed by Jason has the advantage of being cross-platform
> (/dev/null doesn't exist in windows), so if you see no problem with the
> original patch I'd suggest you revert yours.

As I said, this was the only one of the three that I could get working
consistently.  I also happen to think that "rrdtool /dev/null <blah>"
is more obvious than "rrdtool '' <blah>".  So there's a minor argument
to be made in favor of that as well.  In the case of Windows, there is
an equivalent NUL file that could be used.

Regardless, I do *not* think that the patch should simply get
reverted.  Arguably, the problem stems from a lack of proper error
handling on the exec() call.  This exists in 1753 (and persists 1754,
for that matter), so a simple revert won't help matters any.  Instead,
having code to handle NULL output from exec(), in addition to an
rrdtool that can reliably suppress graph generation but still do the
computations we want.

-- 
Jesse Becker
GPG Fingerprint -- BD00 7AA4 4483 AFCC 82D0 2720 0083 0931 9A2B 06A2

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ganglia-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to