On 2/7/08, Bernard Li <[EMAIL PROTECTED]> wrote:

> I have modified the frontend such that the host metrics can be grouped
> by GROUP provided by the EXTRA_DATA tag.
>
> Question is -- do we want this to be the default, or allow user to
> choose whether to do the grouping or not?
>
> Metrics that do not belong to a group, will be put under a group
> called "no_group".
>
> I modified ganglia.php such that EXTRA_DATA data can now be propagated
> to the frontend -- this makes it possible for folks to arbitrarily
> hide certain metrics by group.  However, we probably need to think
> about how we want to implement this -- i.e. can I save a setting where
> I don't see certain metrics for all hosts, some hosts, etc...?

The attached patch does 2 things:

1) Sort host metric graphs by group -- if a metric does not belong to
any group, it will be displayed under "no_group"

2) Use the EXTRA_DATA TITLE field for the graph's title -- right now
it doesn't do much as TITLE = NAME

Comments welcome.

Cheers,

Bernard
Index: web/graph.php
===================================================================
--- web/graph.php	(revision 937)
+++ web/graph.php	(working copy)
@@ -298,7 +298,7 @@
     else if ($summary)
        $title = "$hostname";
     else
-       $title = $metricname;
+       $title = $metrictitle;
    }
 
 # Calculate time range.
Index: web/host_view.php
===================================================================
--- web/host_view.php	(revision 937)
+++ web/host_view.php	(working copy)
@@ -31,6 +31,7 @@
    }
 
 $tpl->assign("ip", $hosts_up['IP']);
+$g_metrics_group = array();
 
 foreach ($metrics as $name => $v)
    {
@@ -57,7 +58,23 @@
                 $encodeUnits = rawurlencode($v['UNITS']);
                 $graphargs .= "&vl=$encodeUnits";
              }
+             if ($v['TITLE']) {
+                $title = $v['TITLE'];
+                $graphargs .= "&ti=$title";
+             }
              $g_metrics[$name]['graph'] = $graphargs;
+
+             # Setup an array of groups that can be used for sorting in group view
+             if ( isset($metrics[$name]['GROUP']) ) {
+                $group = $metrics[$name]['GROUP'];
+             } else {
+                $group = "";
+             }
+             if ( isset($g_metrics_group[$group]) ) {
+                $g_metrics_group[$group] = array_merge($g_metrics_group[$group], $name);
+             } else {
+                $g_metrics_group[$group] = array($name);
+             }
           }
    }
 # Add the uptime metric for this host. Cannot be done in ganglia.php,
@@ -108,18 +125,27 @@
 # Show graphs.
 if (is_array($g_metrics))
    {
-      ksort($g_metrics);
+      ksort($g_metrics_group);
 
-      $i = 0;
-      foreach ( $g_metrics as $name => $v )
+      foreach ( $g_metrics_group as $group => $metric_array )
          {
-            $tpl->newBlock("vol_metric_info");
-            $tpl->assign("graphargs", $v['graph']);
-            $tpl->assign("alt", "$hostname $name");
-            if($i++ %2)
-               $tpl->assign("br", "<BR>");
+            if ( $group == "" ) {
+               $group = "no_group";
+	    }
+            $tpl->newBlock("vol_group_info");
+            $tpl->assign("group", $group);
+            $i = 0;
+            foreach ( $g_metrics as $name => $v )
+               {
+                  if ( in_array($name, $metric_array) ) {
+                     $tpl->newBlock("vol_metric_info");
+                     $tpl->assign("graphargs", $v['graph']);
+                     $tpl->assign("alt", "$hostname $name");
+                     if($i++ %2)
+                        $tpl->assign("br", "<BR>");
+                  }
+               }
          }
    }
-
 $tpl->printToScreen();
 ?>
Index: web/templates/default/host_view.tpl
===================================================================
--- web/templates/default/host_view.tpl	(revision 937)
+++ web/templates/default/host_view.tpl	(working copy)
@@ -91,11 +91,20 @@
 <TR>
  <TD>
 
+<!-- START BLOCK : vol_group_info -->
+<TABLE BORDER="0" WIDTH="100%">
+<TR>
+  <TD CLASS=title>
+  {group} metrics
+  </TD>
+</TR>
+</TABLE>
 <!-- START BLOCK : vol_metric_info -->
 <A HREF="./graph.php?&{graphargs}&z=large">
 <IMG BORDER=0 ALT="{alt}" SRC="./graph.php?{graphargs}">{br}
 </A>
 <!-- END BLOCK : vol_metric_info -->
+<!-- END BLOCK : vol_group_info -->
 
  </TD>
 </TR>
Index: web/get_context.php
===================================================================
--- web/get_context.php	(revision 937)
+++ web/get_context.php	(working copy)
@@ -17,6 +17,8 @@
   escapeshellcmd( rawurldecode($_GET["r"])) : NULL;
 $metricname = isset($_GET["m"]) ?
   escapeshellcmd( clean_string( rawurldecode($_GET["m"]) ) ) : NULL;
+$metrictitle = isset($_GET["ti"]) ?
+  escapeshellcmd( clean_string( rawurldecode($_GET["ti"]) ) ) : NULL;
 $sort = isset($_GET["s"]) ?
   escapeshellcmd( clean_string( rawurldecode($_GET["s"]) ) ) : NULL;
 $controlroom = isset($_GET["cr"]) ?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to