.
[corvix.git] / var / deb-package / corvix-cluster / opt / cluster / lib / www / ganglia / physical_view.php
blobe83f74482b6e4472cd2248d16d50c2d69b759924
1 <?php
2 /* $Id: physical_view.php 583 2005-10-04 18:45:16Z knobi1 $ */
4 # Displays the cluster in a physical view. Cluster nodes in
5 # this view are located by Rack, Rank, and Plane in the physical
6 # cluster.
8 # Originally written by Federico Sacerdoti <fds@sdsc.edu>
9 # Part of the Ganglia Project, All Rights Reserved.
12 # Called from index.php, so cluster and xml tree vars
13 # ($metrics, $clusters, $hosts) are set, and header.php
14 # already called.
16 $tpl = new TemplatePower( template("physical_view.tpl") );
17 $tpl->prepare();
18 $tpl->assign("cluster",$clustername);
19 $cluster_url=rawurlencode($clustername);
20 $tpl->assign("cluster_url",$cluster_url);
22 # Assign the verbosity level. Can take the value of the 'p' CGI variable.
23 $verbose = $physical ? $physical : 2;
25 # The name of the variable changes based on the level. Nice.
26 $tpl->assign("checked$verbose","checked");
29 # Give the capacities of this cluster: total #CPUs, Memory, Disk, etc.
31 $CPUs = cluster_sum("cpu_num", $metrics);
32 # Divide by 1024^2 to get Memory in GB.
33 $Memory = sprintf("%.1f GB", cluster_sum("mem_total", $metrics)/(float)1048576);
34 $Disk = cluster_sum("disk_total", $metrics);
35 $Disk = $Disk ? sprintf("%.1f GB", $Disk) : "Unknown";
36 list($most_full, $most_full_host) = cluster_min("part_max_used", $metrics);
37 $tpl->assign("CPUs", $CPUs);
38 $tpl->assign("Memory", $Memory);
39 $tpl->assign("Disk", $Disk);
41 # Show which node has the most full disk.
42 $most_full_hosturl=rawurlencode($most_full_host);
43 $most_full = $most_full ? "<a href=\"./?p=1&amp;c=$cluster_url&amp;h=$most_full_host\">".
44 "$most_full_host ($most_full% Used)</a>" : "Unknown";
45 $tpl->assign("most_full", $most_full);
46 $tpl->assign("cols_menu", $cols_menu);
49 #-------------------------------------------------------------------------------
50 # Displays a rack and all its nodes.
51 function showrack($ID)
53 global $verbose, $racks, $metrics, $cluster, $hosts_up, $hosts_down;
54 global $cluster_url, $tpl, $clusters;
56 if ($ID>=0) {
57 $tpl->assign("RackID","<tr><th>Rack $ID</th></tr>");
60 # A string of node HTML for the template.
61 $nodes="";
63 foreach ($racks[$ID] as $name)
65 $nodes .= nodebox($name, $verbose);
68 return $nodes;
71 #-------------------------------------------------------------------------------
73 # My Main
76 # 2Key = "Rack ID / Rank (order in rack)" = [hostname, UP|DOWN]
77 $racks = physical_racks();
79 # Make a $cols-wide table of Racks.
80 $i=1;
81 foreach ($racks as $rack=>$v)
83 $tpl->newBlock("racks");
85 $racknodes = showrack($rack);
87 $tpl->assign("nodes", $racknodes);
89 if (! ($i++ % $hostcols)) {
90 $tpl->assign("tr","</tr><tr>");
94 $tpl->printToScreen();