function get_cluster_overview($showhosts, $metrics, $cluster, $range, $clustername, $data) { $cpu_num = !$showhosts ? $metrics["cpu_num"]['SUM'] : cluster_sum("cpu_num", $metrics); $data->assign("cpu_num", $cpu_num); if (isset($cluster['HOSTS_UP'])) { $data->assign("num_nodes", intval($cluster['HOSTS_UP'])); } else { $data->assign("num_nodes", 0); } if (isset($cluster['HOSTS_DOWN'])) { $data->assign("num_dead_nodes", intval($cluster['HOSTS_DOWN'])); } else { $data->assign("num_dead_nodes", 0); } $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); if (!$cpu_num) { $cpu_num = 1; } $cluster_load15 = sprintf("%.0f", (double) $load_fifteen_sum / $cpu_num * 100); $cluster_load5 = sprintf("%.0f", (double) $load_five_sum / $cpu_num * 100); $cluster_load1 = sprintf("%.0f", (double) $load_one_sum / $cpu_num * 100); $data->assign("cluster_load", "{$cluster_load15}%, {$cluster_load5}%, {$cluster_load1}%"); $avg_cpu_num = find_avg($clustername, "", "cpu_num"); if ($avg_cpu_num == 0) { $avg_cpu_num = 1; } $cluster_util = sprintf("%.0f", (double) find_avg($clustername, "", "load_one") / $avg_cpu_num * 100); $data->assign("cluster_util", "{$cluster_util}%"); $data->assign("range", $range); }
<?php /* $Id$ */ $tpl = new Dwoo_Template_File(template("cluster_view.tpl")); $data = new Dwoo_Data(); $data->assign("extra", template("cluster_extra.tpl")); $data->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); # # Correct handling of *_report metrics # if (!$showhosts) { if (array_key_exists($metricname, $metrics)) { $units = $metrics[$metricname]['UNITS']; } } else { if (array_key_exists($metricname, $metrics[key($metrics)])) { if (isset($metrics[key($metrics)][$metricname]['UNITS'])) { $units = $metrics[key($metrics)][$metricname]['UNITS']; } else { $units = ''; } } } if (isset($cluster['HOSTS_UP'])) { $data->assign("num_nodes", intval($cluster['HOSTS_UP'])); } else { $data->assign("num_nodes", 0);
$data = new Dwoo_Data(); $data->assign("cluster", $clustername); $cluster_url = rawurlencode($clustername); $data->assign("cluster_url", $cluster_url); $verbosity_levels = array('3' => "", '2' => "", '1' => ""); # Assign the verbosity level. Can take the value of the 'p' CGI variable. $verbose = $physical ? $physical : 2; $verbosity_levels[$verbose] = "checked"; $data->assign("verbosity_levels", $verbosity_levels); # # Give the capacities of this cluster: total #CPUs, Memory, Disk, etc. # $CPUs = cluster_sum("cpu_num", $metrics); # Divide by 1024^2 to get Memory in GB. $Memory = sprintf("%.1f GB", cluster_sum("mem_total", $metrics) / (double) 1048576); $Disk = cluster_sum("disk_total", $metrics); $Disk = $Disk ? sprintf("%.1f GB", $Disk) : "Unknown"; list($most_full, $most_full_host) = cluster_max("part_max_used", $metrics); $data->assign("CPUs", $CPUs); $data->assign("Memory", $Memory); $data->assign("Disk", $Disk); # Show which node has the most full disk. $most_full_hosturl = rawurlencode($most_full_host); $most_full = $most_full ? "<a href=\"./?p=1&c={$cluster_url}&h={$most_full_host}\">" . "{$most_full_host} ({$most_full}% Used)</a>" : "Unknown"; $data->assign("most_full", $most_full); $data->assign("cols_menu", $cols_menu); #------------------------------------------------------------------------------- # Displays a rack and all its nodes. function showrack($ID) { global $verbose, $racks, $racks_data, $metrics, $cluster, $hosts_up, $hosts_down;
<?php /* $Id: cluster_view.php 1710 2008-08-21 16:44:54Z bernardli $ */ $tpl = new TemplatePower(template("cluster_view.tpl")); $tpl->assignInclude("extra", template("cluster_extra.tpl")); $tpl->prepare(); $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); $roxies_up = !$showhosts ? $metrics["roxie_instances"]['SUM'] : cluster_sum("roxie_instances", $metrics); # # Correct handling of *_report metrics # if (!$showhosts) { if (array_key_exists($metricname, $metrics)) { $units = $metrics[$metricname]['UNITS']; } } else { if (array_key_exists($metricname, $metrics[key($metrics)])) { $units = $metrics[key($metrics)][$metricname]['UNITS']; } } if (isset($cluster['HOSTS_UP'])) { $tpl->assign("num_nodes", intval($cluster['HOSTS_UP'])); } else { $tpl->assign("num_nodes", 0); } if (isset($cluster['HOSTS_DOWN'])) { $tpl->assign("num_dead_nodes", intval($cluster['HOSTS_DOWN']));