Hi Sanghyun,

Sorry, it seems I messed up there a little.

This one should actually work! ;)

monitor2:~# patch -p0 < ganglia-web_showhosts.patch
patching file ganglia-3.0.0/web/cluster_view.php
patching file ganglia-3.0.0/web/conf.php
patching file ganglia-3.0.0/web/get_context.php
monitor2:~#

Let me know if you encounter any more problems.

Kind regards,
Ramon.

Hong sang hyun wrote:

>Hi, Ramon Bastiaans.
>
>Thanks for your patch file about web-frontend.
>But, some problem occured to me when applys the patch.
>
>Error msg follows that..
>
>[EMAIL PROTECTED] ibmmsx2]$ patch -p0 < ganglia-web_showhosts_no.patch
>(Stripping trailing CRs from patch.)
>patching file ganglia-3.0.0/web/cluster_view.php
>Hunk #2 FAILED at 37.
>1 out of 3 hunks FAILED -- saving rejects to file 
>ganglia-3.0.0/web/cluster_view
>.php.rej
>
>Could you send to me the new patch file about cluster_view.php?
>
>Thanks,
>Sanghyun
>
>
>----------  원본 메시지  ----------
>발신자 : Ramon Bastiaans <[EMAIL PROTECTED]>
>수신자 : 서버Gr 홍상현 연구원([EMAIL PROTECTED], 82-2-705-3468)
>날  짜 : 2005/02/16 7:53:50 PM
>제  목 : [Ganglia-developers] [Patch] default_showhosts option, load piechart on 
>showhosts off
>
>
>
>Well, here's the patch, couldn't wait :P
>
>This patch:
>
>- Adds a option in conf.php 'default_showhosts' which allows to specify if
>  hosts should be shown in cluster view by default
>- Removes the "Hosts up/down" pie chart for when showhosts is off, now it just
>  always shows the cluster load pie chart
>- Fixes a bug in get context, that occured when showhosts is off
>- Fixes a bug in cluster view load(sum) and cpunum values, that occured when
>  showhosts is off
>
>Kind regards,
>
>Ramon Bastiaans.
>
><PRE>diff -u ganglia-3.0.0/web/cluster_view.php 
>new.ganglia.web/cluster_view.php
>--- ganglia-3.0.0/web/cluster_view.php  2005-02-02 19:24:14.000000000 +0100
>+++ new.ganglia.web/cluster_view.php    2005-02-16 10:31:50.000000000 +0100
>@@ -6,11 +6,12 @@
>
> $tpl->assign("images","./templates/$template_name/images");
>
>-$cpu_num = !$showhosts ? $metrics["cpu_num"][SUM] : cluster_sum("cpu_num", 
>$metrics);
>-$load_one_sum = !$showhosts ? $metrics["load_one"][SUM] : 
>cluster_sum("load_one", $metrics);
>-$load_five_sum = !$showhosts ? $metrics["load_five"][SUM] : 
>cluster_sum("load_five", $metrics);
>-$load_fifteen_sum = !$showhosts ? $metrics["load_fifteen"][SUM] : 
>cluster_sum("load_fifteen", $metrics);
>-$units = !$showhosts ? $metrics[$metricname][UNITS] : 
>$metrics[key($metrics)][$metricname][UNITS];
>+$cpu_num = cluster_sum("cpu_num", $metrics);
>+$load_one_sum = cluster_sum("load_one", $metrics);
>+$load_five_sum = cluster_sum("load_five", $metrics);
>+$load_fifteen_sum = cluster_sum("load_fifteen", $metrics);
>+$units = $metrics[key($metrics)][$metricname][UNITS];
>+
>
> $tpl->assign("num_nodes", intval($cluster[HOSTS_UP]));
> $tpl->assign("num_dead_nodes", intval($cluster[HOSTS_DOWN]));
>@@ -36,51 +37,39 @@
> $tpl->assign("cols_menu", $cols_menu);
> $tpl->assign("checked$showhosts", "checked");
>
>-if ($showhosts)
>+foreach ($hosts_up as $host => $val)
>    {
>-      foreach ($hosts_up as $host => $val)
>-         {
>-            $cpus = $metrics[$host]["cpu_num"][VAL];
>-            if (!$cpus) $cpus=1;
>-            $load_one  = $metrics[$host]["load_one"][VAL];
>-            $load = ((float) $load_one)/$cpus;
>-            $host_load[$host] = $load;
>-            $percent_hosts[load_color($load)] += 1;
>-            if ($metricname=="load_one")
>-               $sorted_hosts[$host] = $load;
>-            else
>-               $sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
>-         }
>-
>-      foreach ($hosts_down as $host => $val)
>-         {
>-            $load = -1.0;
>-            $down_hosts[$host] = $load;
>-            $percent_hosts[load_color($load)] += 1;
>-         }
>-
>-      # Show pie chart of loads
>-      $pie_args = "title=" . rawurlencode("Cluster Load Percentages");
>-      $pie_args .= "&size=250x150";
>-      foreach($load_colors as $name=>$color)
>-         {
>-            if (!array_key_exists($color, $percent_hosts))
>-               continue;
>-            $n = $percent_hosts[$color];
>-            $name_url = rawurlencode($name);
>-            $pie_args .= "&$name_url=$n,$color";
>-         }
>+      $cpus = $metrics[$host]["cpu_num"][VAL];
>+      if (!$cpus) $cpus=1;
>+      $load_one  = $metrics[$host]["load_one"][VAL];
>+      $load = ((float) $load_one)/$cpus;
>+      $host_load[$host] = $load;
>+      $percent_hosts[load_color($load)] += 1;
>+      if ($metricname=="load_one")
>+         $sorted_hosts[$host] = $load;
>+      else
>+         $sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
>+   }
>+
>+foreach ($hosts_down as $host => $val)
>+   {
>+      $load = -1.0;
>+      $down_hosts[$host] = $load;
>+      $percent_hosts[load_color($load)] += 1;
>    }
>-else
>+
>+# Show pie chart of loads
>+$pie_args = "title=" . rawurlencode("Cluster Load Percentages");
>+$pie_args .= "&size=250x150";
>+foreach($load_colors as $name=>$color)
>    {
>-      # Show pie chart of hosts up/down
>-      $pie_args = "title=" . rawurlencode("Host Status");
>-      $pie_args .= "&size=250x150";
>-      $up_color = $load_colors["50-75"];
>-      $down_color = $load_colors["down"];
>-      $pie_args .= "&Up=$cluster[HOSTS_UP],$up_color";
>-      $pie_args .= "&Down=$cluster[HOSTS_DOWN],$down_color";
>+      if (!array_key_exists($color, $percent_hosts))
>+         continue;
>+      $n = $percent_hosts[$color];
>+      $name_url = rawurlencode($name);
>+      $pie_args .= "&$name_url=$n,$color";
>    }
>+
> $tpl->assign("pie_args", $pie_args);
>
> # No reason to go on if we have no up hosts.
>@@ -173,4 +162,3 @@
>
> $tpl->printToScreen();
> ?>
>-
>diff -u ganglia-3.0.0/web/conf.php new.ganglia.web/conf.php
>--- ganglia-3.0.0/web/conf.php  2005-02-02 19:24:14.000000000 +0100
>+++ new.ganglia.web/conf.php    2005-02-16 10:31:44.000000000 +0100
>@@ -63,6 +63,12 @@
> $default_refresh = 300;
>
> #
>+# Show all hosts in cluster view by default
>+# Default value: yes (1)
>+#
>+$default_showhosts = 1;
>+
>+#
> # Colors for the CPU report graph
> #
> $cpu_user_color = "3333bb";
>diff -u ganglia-3.0.0/web/get_context.php new.ganglia.web/get_context.php
>--- ganglia-3.0.0/web/get_context.php   2005-02-02 19:24:14.000000000 +0100
>+++ new.ganglia.web/get_context.php     2005-02-16 10:34:13.000000000 +0100
>@@ -35,7 +35,7 @@
>
> # Default values
> if (!is_numeric($hostcols)) $hostcols = 4;
>-if (!is_numeric($showhosts)) $showhosts = 1;
>+if (!is_numeric($showhosts)) $showhosts = $default_showhosts;
>
> # Set context.
> if(!$clustername && !$hostname && $controlroom)
>@@ -60,7 +60,7 @@
>    }
> else if ($clustername and !$hostname and !$showhosts)
>    {
>-      $context = "cluster-summary";
>+      $context = "cluster";
>    }
> else if($clustername and !$hostname)
>    {
></PRE>
>
>  
>
diff -u ganglia-3.0.0.old/web/cluster_view.php 
ganglia-3.0.0/web/cluster_view.php
--- ganglia-3.0.0.old/web/cluster_view.php      2005-02-02 19:24:14.000000000 
+0100
+++ ganglia-3.0.0/web/cluster_view.php  2005-02-17 07:54:27.000000000 +0100
@@ -6,11 +6,12 @@
 
 $tpl->assign("images","./templates/$template_name/images");
 
-$cpu_num = !$showhosts ? $metrics["cpu_num"][SUM] : cluster_sum("cpu_num", 
$metrics);
-$load_one_sum = !$showhosts ? $metrics["load_one"][SUM] : 
cluster_sum("load_one", $metrics);
-$load_five_sum = !$showhosts ? $metrics["load_five"][SUM] : 
cluster_sum("load_five", $metrics);
-$load_fifteen_sum = !$showhosts ? $metrics["load_fifteen"][SUM] : 
cluster_sum("load_fifteen", $metrics);
-$units = !$showhosts ? $metrics[$metricname][UNITS] : 
$metrics[key($metrics)][$metricname][UNITS];
+$cpu_num = cluster_sum("cpu_num", $metrics);
+$load_one_sum = cluster_sum("load_one", $metrics);
+$load_five_sum = cluster_sum("load_five", $metrics);
+$load_fifteen_sum = cluster_sum("load_fifteen", $metrics);
+$units = $metrics[key($metrics)][$metricname][UNITS];
+
 
 $tpl->assign("num_nodes", intval($cluster[HOSTS_UP]));
 $tpl->assign("num_dead_nodes", intval($cluster[HOSTS_DOWN]));
@@ -36,51 +37,39 @@
 $tpl->assign("cols_menu", $cols_menu);
 $tpl->assign("checked$showhosts", "checked");
 
-if ($showhosts)
+foreach ($hosts_up as $host => $val)
    {
-      foreach ($hosts_up as $host => $val)
-         {
-            $cpus = $metrics[$host]["cpu_num"][VAL];
-            if (!$cpus) $cpus=1;
-            $load_one  = $metrics[$host]["load_one"][VAL];
-            $load = ((float) $load_one)/$cpus;
-            $host_load[$host] = $load;
-            $percent_hosts[load_color($load)] += 1;
-            if ($metricname=="load_one")
-               $sorted_hosts[$host] = $load;
-            else 
-               $sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
-         }
-         
-      foreach ($hosts_down as $host => $val)
-         {
-            $load = -1.0;
-            $down_hosts[$host] = $load;
-            $percent_hosts[load_color($load)] += 1;
-         }
-      
-      # Show pie chart of loads
-      $pie_args = "title=" . rawurlencode("Cluster Load Percentages");
-      $pie_args .= "&size=250x150";
-      foreach($load_colors as $name=>$color)
-         {
-            if (!array_key_exists($color, $percent_hosts))
-               continue;
-            $n = $percent_hosts[$color];
-            $name_url = rawurlencode($name);
-            $pie_args .= "&$name_url=$n,$color";
-         }
+      $cpus = $metrics[$host]["cpu_num"][VAL];
+      if (!$cpus) $cpus=1;
+      $load_one  = $metrics[$host]["load_one"][VAL];
+      $load = ((float) $load_one)/$cpus;
+      $host_load[$host] = $load;
+      $percent_hosts[load_color($load)] += 1;
+      if ($metricname=="load_one")
+         $sorted_hosts[$host] = $load;
+      else 
+         $sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
+   }
+   
+foreach ($hosts_down as $host => $val)
+   {
+      $load = -1.0;
+      $down_hosts[$host] = $load;
+      $percent_hosts[load_color($load)] += 1;
    }
-else
+      
+# Show pie chart of loads
+$pie_args = "title=" . rawurlencode("Cluster Load Percentages");
+$pie_args .= "&size=250x150";
+foreach($load_colors as $name=>$color)
    {
-      # Show pie chart of hosts up/down
-      $pie_args = "title=" . rawurlencode("Host Status");
-      $pie_args .= "&size=250x150";
-      $up_color = $load_colors["50-75"];
-      $down_color = $load_colors["down"];
-      $pie_args .= "&Up=$cluster[HOSTS_UP],$up_color";
-      $pie_args .= "&Down=$cluster[HOSTS_DOWN],$down_color";
+      if (!array_key_exists($color, $percent_hosts))
+         continue;
+      $n = $percent_hosts[$color];
+      $name_url = rawurlencode($name);
+      $pie_args .= "&$name_url=$n,$color";
    }
+
 $tpl->assign("pie_args", $pie_args);
 
 # No reason to go on if we have no up hosts.
@@ -173,4 +162,3 @@
 
 $tpl->printToScreen();
 ?>
-
diff -u ganglia-3.0.0.old/web/conf.php ganglia-3.0.0/web/conf.php
--- ganglia-3.0.0.old/web/conf.php      2005-02-02 19:24:14.000000000 +0100
+++ ganglia-3.0.0/web/conf.php  2005-02-17 08:05:14.000000000 +0100
@@ -63,6 +63,12 @@
 $default_refresh = 300;
 
 #
+# Show all hosts in cluster view by default
+# Default value: yes (1)
+#
+#$default_showhosts = 1;
+
+#
 # Colors for the CPU report graph
 #
 $cpu_user_color = "3333bb";
diff -u ganglia-3.0.0.old/web/get_context.php ganglia-3.0.0/web/get_context.php
--- ganglia-3.0.0.old/web/get_context.php       2005-02-02 19:24:14.000000000 
+0100
+++ ganglia-3.0.0/web/get_context.php   2005-02-17 08:12:50.000000000 +0100
@@ -33,9 +33,21 @@
 if (!count($HTTP_GET_VARS) or !strstr($gridstack[0], "http://";))
       $initgrid=TRUE;
 
+
+
 # Default values
 if (!is_numeric($hostcols)) $hostcols = 4;
-if (!is_numeric($showhosts)) $showhosts = 1;
+if (!is_numeric($showhosts))
+   {
+      if (!is_numeric($default_showhosts))
+         {
+            $showhosts = 1;
+         }
+      else if (is_numeric($default_showhosts))
+         {
+            $showhosts = $default_showhosts;
+         }
+   }
 
 # Set context.
 if(!$clustername && !$hostname && $controlroom)
@@ -60,7 +72,7 @@
    }
 else if ($clustername and !$hostname and !$showhosts)
    {
-      $context = "cluster-summary";
+      $context = "cluster";
    }
 else if($clustername and !$hostname)
    {

Reply via email to