prepare();
$tpl->assign( "cluster", $cluster );
$tpl->assign( "host", $host );
$tpl->assign( "node_image", node_image($cluster, $host) );
$tpl->assign("sort",$sort);
$tpl->assign("range",$range);
if($hosts[$cluster][$host])
{
$tpl->assign("node_msg", "This node is up and running");
}
else
{
$tpl->assign("node_msg", "This node is down");
}
# For the node view link.
$tpl->assign("node_view","./?p=2&c=$clusterURL&h=$host");
$clusterURL=rawurlencode($cluster);
$tpl->assign( "load_graph", "
");
$tpl->assign( "mem_graph", "
");
$tpl->assign( "cpu_graph", "
");
// Metrics is a bad data structure for this search... Note the double for loop.
if(is_array($metrics[$cluster]))
{
foreach ( $metrics[$cluster] as $metric => $v )
{
foreach($v as $node => $v1 )
{
if($node == $host )
{
if(is_array($v1))
{
$name = $v1[NAME];
if ($v1[TYPE] == "string" or $v1[TYPE]=="timestamp" or $always_timestamp[$name])
{
// Long gmetric name/values will disrupt the display here.
if ($v1[SOURCE] == "gmond") $s_metrics[$name] = $v1;
}
elseif ($v1[SLOPE] == "zero" or $always_constant[$name])
{
$c_metrics[$name] = $v1;
}
else
{
$graphargs = "c=$clusterURL&h=$host&v=$v1[VAL]&m=$name&r=$range&z=medium&jr=$jobrange&js=$jobstart";
// Adding units to graph 2003 by Jason Smith .
if ($v1[UNITS]) {
$encodeUnits = rawurlencode($v1[UNITS]);
$graphargs .= "&vl=$encodeUnits";
}
$g_metrics[$name][graph] = "
";
}
}
# 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";
$s_metrics[uptime][VAL] = uptime($host, $cluster);
}
}
}
}
if(is_array($s_metrics))
{
ksort($s_metrics);
foreach ($s_metrics as $name => $v )
{
$tpl->newBlock("string_metric_info");
$tpl->assign("name", $name);
if( $v[TYPE]=="timestamp" or $always_timestamp[$name])
{
$tpl->assign("value", date("r", $v[VAL]));
}
else
{
$tpl->assign("value", "$v[VAL] $v[UNITS]");
}
}
}
if(is_array($c_metrics))
{
ksort($c_metrics);
foreach ($c_metrics as $name => $v )
{
$tpl->newBlock("const_metric_info");
$tpl->assign("name", $name);
$tpl->assign("value", "$v[VAL] $v[UNITS]");
}
}
if(is_array($g_metrics))
{
ksort($g_metrics);
$i = 0;
foreach ( $g_metrics as $name => $v )
{
$tpl->newBlock("vol_metric_info");
$tpl->assign("graph", $v[graph]);
if($i++ %2)
$tpl->assign("br", "
");
}
}
$tpl->printToScreen();
?>