This patch comes from a colleague of mine (Jerome Lauret) who said he was getting a lot of noise in his apache logs from ganglia's php. I didn't test this myself, but it looks pretty harmless since it just does a few simple sanity checks on some variables before assigning values.
~Jason -- /------------------------------------------------------------------\ | Jason A. Smith Email: smit...@bnl.gov | | Atlas Computing Facility, Bldg. 510M Phone: +1-631-344-4226 | | Brookhaven National Lab, P.O. Box 5000 Fax: +1-631-344-7616 | | Upton, NY 11973-5000, U.S.A. | \------------------------------------------------------------------/
Index: monitor-core/web/cluster_view.php =================================================================== --- monitor-core/web/cluster_view.php (revision 1945) +++ monitor-core/web/cluster_view.php (working copy) @@ -91,9 +91,16 @@ { foreach ($hosts_up as $host => $val) { - $cpus = $metrics[$host]["cpu_num"]['VAL']; - if (!$cpus) $cpus=1; - $load_one = $metrics[$host]["load_one"]['VAL']; + if ( isset($metrics[$host]["cpu_num"]['VAL']) and $metrics[$host]["cpu_num"]['VAL'] != 0 ){ + $cpus = $metrics[$host]["cpu_num"]['VAL']; + } else { + $cpus = 1; + } + if ( isset($metrics[$host]["load_one"]['VAL']) ){ + $load_one = $metrics[$host]["load_one"]['VAL']; + } else { + $load_one = 0; + } $load = ((float) $load_one)/$cpus; $host_load[$host] = $load; if(isset($percent_hosts[load_color($load)])) { Index: monitor-core/web/functions.php =================================================================== --- monitor-core/web/functions.php (revision 1945) +++ monitor-core/web/functions.php (working copy) @@ -176,12 +176,16 @@ { global $hosts_down; - $cpu_num = $metrics["cpu_num"]['VAL']; - if(!$cpu_num || $cpu_num == 0) - { - $cpu_num = 1; - } - $load_one = $metrics["load_one"]['VAL']; + if ( isset($metrics["cpu_num"]['VAL']) and $metrics["cpu_num"]['VAL'] != 0 ) { + $cpu_num = $metrics["cpu_num"]['VAL']; + } else { + $cpu_num = 1; + } + if ( isset($metrics["load_one"]['VAL']) ) { + $load_one = $metrics["load_one"]['VAL']; + } else { + $load_one = 0; + } $value = $load_one / $cpu_num; # Check if the host is down Index: monitor-core/web/host_view.php =================================================================== --- monitor-core/web/host_view.php (revision 1945) +++ monitor-core/web/host_view.php (working copy) @@ -86,6 +86,10 @@ } } } + +# in case this is not defined, set to LOCALTIME so uptime will be 0 in the display +if ( !isset($metrics['boottime']['VAL']) ){ $metrics['boottime']['VAL'] = $cluster['LOCALTIME'];} + # Add the uptime metric for this host. Cannot be done in ganglia.php, # since it requires a fully-parsed XML tree. The classic contructor problem. $s_metrics['uptime']['TYPE'] = "string"; @@ -144,7 +148,7 @@ $tpl->assign("value", "$cluster_util%"); # Show constant metrics. -if (is_array($c_metrics)) +if (isset($c_metrics) and is_array($c_metrics)) { ksort($c_metrics); foreach ($c_metrics as $name => $v )
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________ Ganglia-developers mailing list Ganglia-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ganglia-developers