Hi Bernard,

Sorry I forgot to mention that it is a patch for 3.1.2.
Regards

Sebastien

On Tue, Dec 15, 2009 at 7:51 PM, Bernard Li <bern...@vanhpc.org> wrote:

> Hi Sebastien:
>
> First of all, thanks for the patch!
>
> I just have a quick question for you right now -- is your patch
> against a particular version of Ganglia or is it against the code in
> trunk?
>
> Thanks!
>
> Bernard
>
> On Tue, Dec 15, 2009 at 5:32 AM, Sebastien Termeau <s...@mobilepeople.com>
> wrote:
> > Dear Ganglia Developers,
> >
> > Please find below a patch that brings trends to Ganglia.
> > It uses RRD's LSLSLOPE, LSLINT and PREDICT (requires RRD >= 1.4.0 ) to
> > provide two kinds of trends.
> > Trends can be disabled by modifying conf.php ($with_trends).
> > I also modified the host_view template to use tables instead of sending a
> > <BR> after "n" metrics.
> > Using PREDICT with linear datas does not give a really good result. Maybe
> it
> > is related to the parameters I am using.
> > This patch also requires 2 new pictures to be put in
> > templates/default/images/ but I don't think I can attach them to this
> email.
> > Your remarks and suggestions are most welcome.
> > Best regards
> >
> > -----------
> > diff -ur ganglia.ori/conf.php ganglia/conf.php
> > --- ganglia.ori/conf.php    2009-12-14 15:19:23.000000000 +0100
> > +++ ganglia/conf.php    2009-12-15 12:05:49.000000000 +0100
> > @@ -64,6 +64,18 @@
> >  #
> >  $show_meta_snapshot = "yes";
> >
> > +#
> > +# Show trends icons next to each single metric graph
> > +#
> > +$with_trends = "yes";
> > +
> > +#
> > +# Parameters used for prediction trends
> > +#
> > +# shift_divisions must be > 1
> > +$shift_divisions="5";
> > +$sigma_multiplier="5";
> > +
> >  #
> >  # The default refresh frequency on pages.
> >  #
> > diff -ur ganglia.ori/graph.php ganglia/graph.php
> > --- ganglia.ori/graph.php    2009-12-14 15:19:23.000000000 +0100
> > +++ ganglia/graph.php    2009-12-15 14:17:54.000000000 +0100
> > @@ -1,6 +1,7 @@
> >  <?php
> >  /* $Id: graph.php 1816 2008-09-17 09:42:40Z carenas $ */
> >  include_once "./conf.php";
> > +include_once "./ganglia.php";
> >  include_once "./get_context.php";
> >  include_once "./functions.php";
> >
> > @@ -29,6 +30,7 @@
> >
> >  $summary    = isset( $_GET["su"] )    ? 1 : 0;
> >  $debug      = isset( $_GET['debug'] ) ? clean_number ( sanitize(
> > $_GET["debug"] ) ) : 0;
> > +$trend_type = isset($_GET["tr"]) ?  sanitize ( $_GET["tr"] )  : '';
> >  $command    = '';
> >
> >  # Assumes we have a $start variable (set in get_context.php).
> > @@ -140,6 +142,12 @@
> >        # Get_context makes start negative.
> >        $start = $sourcetime + $start;
> >     }
> > +
> > +# For trends, we double the time range
> > +if ($trend_type != ''){
> > +  $rrdtool_graph['end']=$end + ($end-$start);
> > +}
> > +
> >  # Fix from Phil Radden, but step is not always 15 anymore.
> >  if ($range=="month")
> >     $rrdtool_graph['end'] = floor($rrdtool_graph['end'] / 672) * 672;
> > @@ -209,6 +217,18 @@
> >  $command .= array_key_exists('extras', $rrdtool_graph) ? '
> > '.$rrdtool_graph['extras'].' ' : '';
> >  $command .= " $rrdtool_graph[series]";
> >
> > +
> > +if ($trend_type == 'linear'){
> > +  $command .= " VDEF:D=sum,LSLSLOPE VDEF:H=sum,LSLINT
> > CDEF:projection=sum,POP,D,COUNT,*,H,+
> LINE1:projection#00ff00:'Projection'";
> > +}
> > +elseif ($trend_type == 'predict'){
> > +  $shift=abs($rrdtool_graph['start']/$shift_divisions);
> > +  $command .= "
> >
> CDEF:predict=".$shift.",".-1*$shift_divisions.",".abs($rrdtool_graph['start']).",sum,PREDICT";
> > +  $command .= "
> >
> CDEF:sigma=".$shift.",".-1*$shift_divisions.",".abs($rrdtool_graph['start']).",sum,PREDICTSIGMA";
> > +  $command .= " CDEF:upper=predict,sigma,".$sigma_multiplier.",*,+
> > CDEF:lower=predict,sigma,".$sigma_multiplier.",*,-";
> > +  $command .= " LINE1:predict#00ff00:prediction
> LINE1:upper#ff0000:upper
> > LINE1:lower#0000ff:lower";
> > +}
> > +
> >  //error_log("Final command:  $command");
> >
> >  # Did we generate a command?   Run it.
> > diff -ur ganglia.ori/host_view.php ganglia/host_view.php
> > --- ganglia.ori/host_view.php    2009-12-14 15:19:23.000000000 +0100
> > +++ ganglia/host_view.php    2009-12-15 14:16:46.000000000 +0100
> > @@ -161,10 +161,26 @@
> >                       $tpl->newBlock("vol_metric_info");
> >                       $tpl->assign("graphargs", $v['graph']);
> >                       $tpl->assign("alt", "$hostname $name");
> > +
> >                       if (isset($v['description']))
> >                         $tpl->assign("desc", $v['description']);
> > -                     if ( !(++$i % $metriccols) )
> > -                        $tpl->assign("br", "<BR>");
> > +             # PREDICT supported in 1.4.0
> > +               if ($with_trends == 'yes'){
> > +             if( version_compare($version["rrdtool"], '1.4.5') >= 0) {
> > +               $tpl->newBlock("trend_predict");
> > +               $tpl->assign("graphargs", $v['graph']);
> > +
> $tpl->assign("images","./templates/$template_name/images");
> > +             }
> > +             else {
> > +               $tpl->newBlock("trend");
> > +               $tpl->assign("graphargs", $v['graph']);
> > +
> $tpl->assign("images","./templates/$template_name/images");
> > +             }
> > +               }
> > +                     if ( !(++$i % $metriccols) ){
> > +               $tpl->gotoBlock ("vol_metric_info");
> > +                        $tpl->assign("new_row", "</TR><TR>");
> > +             }
> >                    }
> >                 }
> >           }
> > Only in ganglia: prediction.png
> > diff -ur ganglia.ori/templates/default/host_view.tpl
> > ganglia/templates/default/host_view.tpl
> > --- ganglia.ori/templates/default/host_view.tpl    2009-12-14
> > 15:19:23.000000000 +0100
> > +++ ganglia/templates/default/host_view.tpl    2009-12-15
> 14:15:33.000000000
> > +0100
> > @@ -117,11 +117,24 @@
> >  </TABLE>
> >  </A>
> >  <DIV ID="{group}">
> > +<table><tr>
> >  <!-- START BLOCK : vol_metric_info -->
> > -<A HREF="./graph.php?&{graphargs}&z=large">
> > -<IMG BORDER=0 ALT="{alt}" SRC="./graph.php?{graphargs}"
> TITLE="{desc}">{br}
> > -</A>
> > +<TD><A HREF="./graph.php?&{graphargs}&z=large"><IMG BORDER=0 ALT="{alt}"
> > SRC="./graph.php?{graphargs}" TITLE="{desc}"></A></TD>
> > +<!-- START BLOCK : trend -->
> > +<TD>
> > +<A HREF="./graph.php?&{graphargs}&z=large&tr=linear"><IMG
> > SRC="{images}/trend_linear.gif" BORDER="0"/></A>
> > +</TD>
> > +<!-- END BLOCK : trend -->
> > +<!-- START BLOCK : trend_predict -->
> > +<TD>
> > +<TABLE><TR><TD><A HREF="./graph.php?&{graphargs}&z=large&tr=linear"><IMG
> > SRC="{images}/trend_linear.gif" BORDER="0"/></A><TD></TR>
> > +<TD><A HREF="./graph.php?&{graphargs}&z=large&tr=predict"><IMG
> > SRC="{images}/trend_predict.gif" BORDER="0"/></A></TD></TR></TABLE>
> > +</TD>
> > +<!-- END BLOCK : trend_predict -->
> > +{new_row}
> >  <!-- END BLOCK : vol_metric_info -->
> > +</tr>
> > +</table>
> >  </DIV>
> >  <!-- END BLOCK : vol_group_info -->
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Return on Information:
> > Google Enterprise Search pays you back
> > Get the facts.
> > http://p.sf.net/sfu/google-dev2dev
> >
> > _______________________________________________
> > Ganglia-developers mailing list
> > Ganglia-developers@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ganglia-developers
> >
>
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to