prepare(); // Maintain our path through the grid tree. $me = $self . "@" . $grids[$self][AUTHORITY]; if ($initgrid) { $gridstack = array(); $gridstack[] = $me; } else if ($gridwalk=="fwd") { // push our info on gridstack, format is "name@url name2@url". if (end($gridstack) != $me) { $gridstack[] = $me; } } else if ($gridwalk=="back") { // pop a single grid off stack. if (end($gridstack) != $me) { array_pop($gridstack); } } $Gridstack = join(">", $gridstack); $GridstackURL = rawurlencode($Gridstack); if ($initgrid or $gridwalk) { // Use cookie so we dont have to pass gridstack around within this site. // Cookie values are automatically urlencoded. Expires in a day. setcookie("gs", $Gridstack, time() + 86400); } // Invariant: back pointer is second-to-last element of gridstack. Grid stack never // has duplicate entries. list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]); // Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell // destination server that we're walking foward in the grid tree. if (strstr($cluster, "http://")) { $tpl->assign("refresh", "0"); $tpl->assign("redirect", ";URL=$cluster?gw=fwd&gs=$GridstackURL"); echo "

Redirecting, please wait...

"; $tpl->printToScreen(); exit; } $tpl->assign("refresh", $default_refresh); /* D h:i:s a */ $tpl->assign( "date", date("r")); $tpl->assign( "page_title", $title ); // The page to go to when "Get Fresh Data" is pressed. if (isset($page)) { $tpl->assign("page",$page); } else { $tpl->assign("page","./"); } // Templated Logo image $tpl->assign("images","./templates/$template_name/images"); // // Used when making graphs via graph.php. Included in most URLs // $sortURL=rawurlencode($sort); $get_metric_string = "m=$metric&r=$range&s=$sortURL"; if ($jobrange and $jobstart) $get_metric_string .= "&jr=$jobrange&js=$jobstart"; // Set the Alternate view link. $clusterURL=rawurlencode($cluster); $nodeURL=rawurlencode($host); if ($context=="cluster") { $tpl->assign("alt_view", "Physical View"); // Enable jobs link for this cluster, if present. $tpl->newBlock("jobs"); $tpl->assign("images","./templates/$template_name/images"); $tpl->assign("cluster", $clusterURL); $tpl->gotoBlock("_ROOT"); } elseif ($context=="physical") { $tpl->assign("alt_view", "Full View"); } elseif ($context=="node") { $tpl->assign("alt_view", "Host View"); } elseif ($context=="host") { $tpl->assign("alt_view", "Node View"); } // Build the node_menu $node_menu = ""; if ($parentgrid) { $node_menu .= "". "$parentgrid $meta_designator "; $node_menu .= ">\n"; } # Show grid. if (!$standalone) { $node_menu .= "$self $meta_designator "; $node_menu .= ">\n"; } if ($physical) $node_menu .= hiddenvar("p", $physical); if ( $cluster ) { $url = rawurlencode($cluster); $node_menu .= "$cluster "; $node_menu .= ">\n"; $node_menu .= hiddenvar("c", $cluster); } else { // No cluster has been specified, so drop in a list $node_menu .= "\n"; } if ( $cluster && !$host ) { // Drop in a host list if we have hosts if(is_array($hosts) || is_array($hosts_down)) { $node_menu .= "\n"; } else { $node_menu .= "No Hosts\n"; } } else { $node_menu .= "$host\n"; $node_menu .= hiddenvar("h", $host); } # Save other CGI variables $node_menu .= hiddenvar("cr", $controlroom); $node_menu .= hiddenvar("js", $jobstart); $node_menu .= hiddenvar("jr", $jobrange); $tpl->assign("node_menu", $node_menu); ////////////////////// Build the metric menu //////////////////////////////////// /* Let's get the metrics available for the given context */ if( $context == "meta" || $context == "control" ) { foreach ( $metrics as $c => $foo ) { foreach( $metrics[$c] as $m => $foo ) { $context_metrics[$m]=""; } } } else if( $context == "cluster" ) { if (!$metrics[$cluster]) { echo "

Cannot find any metrics for selected cluster \"$cluster\", exiting.

\n"; echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n"; exit; } foreach( $metrics[$cluster] as $m => $foo) { $context_metrics[$m]=""; } } else if( $context == "host" ) { // This is uglier but luckily it's not as common if(is_array($metrics[$cluster])) { foreach( $metrics[$cluster] as $m => $h ) { foreach( $h as $k => $v ) { if ($k == $host) { $context_metrics[$m]=""; } } } } } // // If there are context metrics, show ranges. // if (is_array($context_metrics)) { $context_ranges[]="hour"; $context_ranges[]="day"; $context_ranges[]="week"; $context_ranges[]="month"; $context_ranges[]="year"; if ($jobrange) $context_ranges[]="job"; $range_menu="Last  \n"; ksort($context_metrics); foreach( $context_metrics as $k => $v ) { $url = rawurlencode($k); $metric_menu .= "