.
[corvix.git] / var / deb-package / cluster_raw_old / opt / cluster / lib / www / ganglia / host_gmetrics.php
blobdc662d4def2d87fd72893fe41a43f3a4befa6e95
1 <?php
2 /* $Id: host_gmetrics.php 905 2007-12-11 22:38:21Z bernardli $ */
4 # ATD - functions.php needs to be first, as it defines clean_string()
5 include_once "functions.php";
6 # ATD - these must be defined before including ganglia.php
7 $clustername = escapeshellcmd( clean_string( rawurldecode( $_GET["c"] ) ) );
8 $hostname = escapeshellcmd( clean_string( rawurldecode($_GET["h"] ) ) );
9 $context = "host";
10 # ATD - the order of the rest of these doesn't matter AFAIK.
11 include_once "conf.php";
12 include_once "ganglia.php";
13 include_once "get_ganglia.php";
14 include_once "./class.TemplatePower.inc.php";
16 # RFM - These lines prevent "undefined variable" error messages in
17 # the ssl_error_log file.
18 if(!isset($always_timestamp)) $always_timestamp = array();
20 # RFM - Quoted the array indices to suppress error messages in
21 # ssl_error_log file.
23 function byTN($a, $b)
25 $aTN = $a['TN'];
26 $bTN = $b['TN'];
27 if ($aTN == $bTN)
28 return 0;
29 return ($aTN < $bTN) ? -1 : 1;
32 $tpl = new TemplatePower( template("host_gmetrics.tpl") );
33 $tpl->prepare();
35 $tpl->assign("cluster", $clustername);
36 $tpl->assign("host", $hostname);
37 $tpl->assign("node_image", node_image($metrics));
39 if($hosts_up)
40 $tpl->assign("node_msg", "This host is up and running.");
41 else
42 $tpl->assign("node_msg", "This host is down.");
44 $cluster_url=rawurlencode($clustername);
45 $tpl->assign("cluster_url", $cluster_url);
47 # For the node view link.
48 $tpl->assign("host_view","./?c=$cluster_url&amp;h=$hostname");
50 foreach ($metrics as $name => $v)
52 # Show only user defined metrics.
53 if ($v['SOURCE'] == "gmetric") {
54 $g_metrics[$name] = $v;
58 # Show gmetrics
59 if (isset($g_metrics) and is_array($g_metrics))
61 uasort($g_metrics, "byTN");
62 foreach ($g_metrics as $name => $v )
64 # echo "Adding gmetric name $name<br>";
65 $tpl->newBlock("g_metric_info");
66 $tpl->assign("name", $name);
67 $tpl->assign("tn", $v['TN']);
68 $tpl->assign("tmax", $v['TMAX']);
69 $tpl->assign("dmax", $v['DMAX']);
70 # RFM - Added isset() call to avoid "undefined index" errors in
71 # the ssl_error_log file.
72 if( $v['TYPE']=="timestamp" or (isset($always_timestamp[$name]) and $always_timestamp[$name]))
74 $tpl->assign("value", date("r", $v['VAL']));
76 else
78 $tpl->assign("value", $v['VAL'] . " " . $v['UNITS']);
83 $tpl->printToScreen();