Dear Ganglia developers,
Some time ago, I submitted a patch to add 'trends' to ganglia but it
was not very user friendly.
Here is the new version.
With a combo box on the host view, you can choose to add either the
Min/Max/Avg lines or the 'least square line' to each single metric
graph.
The patch can be applied to the source code trunk.
I haven't added the TREND or PREDICT feature available in rrdgraph
because I don't think they are relevant but they can be added quite
easily.
Please let me know what you think about it.
Regards
Sebastien Termeau
diff -ru ganglia.ori/monitor-core/web/get_context.php ganglia/monitor-core/web/get_context.php
--- ganglia.ori/monitor-core/web/get_context.php 2010-06-22 15:46:43.000000000 +0200
+++ ganglia/monitor-core/web/get_context.php 2010-06-22 15:48:05.000000000 +0200
@@ -63,6 +63,9 @@
$gridstack = explode( ">", rawurldecode( $_GET["gs"] ) );
else if ( isset($_COOKIE['gs']) and $_COOKIE['gs'])
$gridstack = explode( ">", $_COOKIE["gs"] );
+# Extra Info
+$ex=isset($_GET["ex"]) ?
+ escapeshellcmd($_GET["ex"]) : NULL;
if (isset($gridstack) and $gridstack) {
foreach( $gridstack as $key=>$value )
diff -ru ganglia.ori/monitor-core/web/graph.d/metric.php ganglia/monitor-core/web/graph.d/metric.php
--- ganglia.ori/monitor-core/web/graph.d/metric.php 2010-06-22 15:46:44.000000000 +0200
+++ ganglia/monitor-core/web/graph.d/metric.php 2010-06-22 15:48:05.000000000 +0200
@@ -23,7 +23,8 @@
$value,
$vlabel,
$strip_domainname,
- $graphreport_stats;
+ $graphreport_stats,
+ $ex;
if ($strip_domainname) {
$hostname = strip_domainname($hostname);
@@ -119,8 +120,18 @@
//# the actual graph...
$series = "DEF:'sum'='$rrd_dir/$metricname.rrd:sum':AVERAGE ";
- $series .= "AREA:'sum'#$default_metric_color:'$subtitle_one\\n'";
+ if( $ex == NULL || $ex == '' || $ex == 'None' ){
+ $series .= "AREA:'sum'#$default_metric_color:'$subtitle_one\\n'";
+ }
+ elseif ( $ex == 'LSLine'){
+ $series .= "AREA:'sum'#$default_metric_color:'$subtitle_one'";
+ $series .= " VDEF:D=sum,LSLSLOPE VDEF:H=sum,LSLINT CDEF:projection=sum,POP,D,COUNT,*,H,+ LINE1:projection#ff0000:'LSLine\\n' ";
+ }
+ elseif ( $ex == 'MinMaxAvg'){
+ $series .= "AREA:'sum'#$default_metric_color:'$subtitle_one'";
+ $series .= " VDEF:Min=sum,MINIMUM VDEF:Max=sum,MAXIMUM VDEF:Avg=sum,AVERAGE LINE1:Min#0000ff:'Min' LINE1:Max#ff0000:'Max' LINE1:Avg#00ff00:'Avg\\n'";
+ }
if ($graphreport_stats == false) {
$series .= ":STACK: COMMENT:'$subtitle_two\\l'";
}
diff -ru ganglia.ori/monitor-core/web/graph.php ganglia/monitor-core/web/graph.php
--- ganglia.ori/monitor-core/web/graph.php 2010-06-22 15:46:44.000000000 +0200
+++ ganglia/monitor-core/web/graph.php 2010-06-22 15:48:05.000000000 +0200
@@ -29,6 +29,7 @@
$summary = isset( $_GET["su"] ) ? 1 : 0;
$debug = isset( $_GET['debug'] ) ? clean_number ( sanitize( $_GET["debug"] ) ) : 0;
+$ex = isset( $_GET["ex"] ) ? sanitize ( rawurldecode( $_GET[ 'ex' ] ) ) : NULL;
$command = '';
# Assumes we have a $start variable (set in get_context.php).
diff -ru ganglia.ori/monitor-core/web/header.php ganglia/monitor-core/web/header.php
--- ganglia.ori/monitor-core/web/header.php 2010-06-22 15:46:44.000000000 +0200
+++ ganglia/monitor-core/web/header.php 2010-06-22 15:50:45.000000000 +0200
@@ -315,6 +315,32 @@
$tpl->assign("sort_menu", $sort_menu );
}
+#
+# Only show extra_info list if are in host context.
+#
+if ( $context == "host")
+ {
+ $extra_info[]="None";
+ $extra_info[]="MinMaxAvg";
+ $extra_info[]="LSLine";
+
+ $extrainfo_menu="<B>ExtraInfo</B> "
+ ."<SELECT NAME=\"ex\" OnChange=\"ganglia_form.submit();\">\n";
+
+ foreach ( $extra_info as $v )
+ {
+ $url = rawurlencode($v);
+ $extrainfo_menu .= "<OPTION VALUE=\"$url\" ";
+ if ($v == $ex )
+ $extrainfo_menu .= "SELECTED";
+
+ $extrainfo_menu .= ">$v\n";
+ }
+
+ $extrainfo_menu .= "</SELECT>\n";
+ $tpl->assign("extrainfo_menu", $extrainfo_menu );
+ }
+
if ($context == "physical" or $context == "cluster" or $context == 'host' )
{
# Present a width list
diff -ru ganglia.ori/monitor-core/web/host_view.php ganglia/monitor-core/web/host_view.php
--- ganglia.ori/monitor-core/web/host_view.php 2010-06-22 15:46:44.000000000 +0200
+++ ganglia/monitor-core/web/host_view.php 2010-06-22 15:48:06.000000000 +0200
@@ -56,7 +56,7 @@
$size = $size == 'medium' ? 'default' : $size; //set to 'default' to preserve old behavior
$graphargs = "c=$cluster_url&h=$hostname&v=$v[VAL]"
."&m=$name&r=$range&z=$size&jr=$jobrange"
- ."&js=$jobstart&st=$cluster[LOCALTIME]";
+ ."&js=$jobstart&st=$cluster[LOCALTIME]&ex=$ex";
if ($cs)
$graphargs .= "&cs=" . rawurlencode($cs);
if ($ce)
diff -ru ganglia.ori/monitor-core/web/templates/default/header.tpl ganglia/monitor-core/web/templates/default/header.tpl
--- ganglia.ori/monitor-core/web/templates/default/header.tpl 2010-06-22 15:46:43.000000000 +0200
+++ ganglia/monitor-core/web/templates/default/header.tpl 2010-06-22 15:48:06.000000000 +0200
@@ -31,7 +31,8 @@
<TR>
<TD COLSPAN="1">
{range_menu}
- {custom_time}<br>
+ {custom_time}
+ {extrainfo_menu}<br>
{metric_menu}
{sort_menu}
</TD>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers