Index: branches/0.4/web/addons/job_monarch/index.php
===================================================================
--- branches/0.4/web/addons/job_monarch/index.php (revision 714)
+++ branches/0.4/web/addons/job_monarch/index.php (revision 715)
@@ -33,6 +33,7 @@
include_once "./libtoga.php";
-if ( !empty( $_GET ) ) {
- extract( $_GET );
+if ( !empty( $_GET ) )
+{
+ extract( $_GET );
}
@@ -52,365 +53,411 @@
if( !isset($sortby) ) $sortby = "id";
-if( isset( $filterorder ) && ($filterorder!='') ) {
- $myfilter_fields = explode( ",", $filterorder );
-} else {
- if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
- if( isset($state) && ($state!='')) $filter['state']=$state;
- if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
- if( isset($id) && ($id!='')) $filter['id']=$id;
+if( isset( $filterorder ) && ($filterorder!='') )
+{
+ $myfilter_fields = explode( ",", $filterorder );
+}
+else
+{
+ if( isset($queue) && ($queue!='')) $filter['queue']=$queue;
+ if( isset($state) && ($state!='')) $filter['state']=$state;
+ if( isset($owner) && ($owner!='')) $filter['owner']=$owner;
+ if( isset($id) && ($id!='')) $filter['id']=$id;
}
// Fill filter array in order they were picked by user
-if( isset($myfilter_fields) ) {
-
- foreach( $myfilter_fields as $myfilter ) {
-
- switch( $myfilter ) {
-
- case "queue":
- $filter['queue']=$queue;
- break;
- case "state":
- $filter['state']=$state;
- break;
- case "owner":
- $filter['owner']=$owner;
- break;
- case "id":
- $filter['id']=$id;
- break;
- }
- }
-}
-
-function epochToDatetime( $epoch ) {
+if( isset($myfilter_fields) )
+{
+
+ foreach( $myfilter_fields as $myfilter )
+ {
+
+ switch( $myfilter )
+ {
+
+ case "queue":
+ $filter['queue']=$queue;
+ break;
+ case "state":
+ $filter['state']=$state;
+ break;
+ case "owner":
+ $filter['owner']=$owner;
+ break;
+ case "id":
+ $filter['id']=$id;
+ break;
+ }
+ }
+}
+
+function epochToDatetime( $epoch )
+{
return strftime( "%d-%m-%Y %H:%M:%S", $epoch );
}
-function makeHeader( $page_call, $title, $longtitle ) {
-
- global $tpl, $grid, $context, $initgrid;
- global $jobrange, $jobstart;
- global $page, $gridwalk, $clustername;
- global $parentgrid, $physical, $hostname;
- global $self, $filter, $cluster_url, $get_metric_string;
- global $metrics, $reports, $m, $default_metric;
- global $default_refresh, $filterorder, $view;
- global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id;
- global $job_start, $job_stop, $range, $r, $metricname;
-
- if( isset($default_metric) and !isset($m) )
- $metricname = $default_metric;
- else
- if( isset( $m ) )
- $metricname = $m;
- else
- $metricname = "load_one";
-
- $header = "header";
-
- # Maintain our path through the grid tree.
- $me = $self . "@" . $grid[$self][AUTHORITY];
-
- $gridstack = array();
- $gridstack[] = $me;
-
- 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_str = join(">", $gridstack);
- $gridstack_url = rawurlencode($gridstack_str);
-
- 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_str, 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($clustername, "http://")) {
- $tpl->assign("refresh", "0");
- $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");
- echo "
Redirecting, please wait...
";
- $tpl->printToScreen();
- exit;
- }
- $tpl->gotoBlock( "_ROOT" );
-
- if( $view != "search" )
- $tpl->assign( "refresh", $default_refresh );
-
- $tpl->assign( "date", date("r") );
- $tpl->assign( "longpage_title", $longtitle );
- $tpl->assign( "page_title", $title );
-
- # The page to go to when "Get Fresh Data" is pressed.
- $tpl->assign("page","./");
-
- # Templated Logo image
- $tpl->assign("images","./templates/$template_name/images");
-
- #
- # Used when making graphs via graph.php. Included in most URLs
- #
- $sort_url=rawurlencode($sort);
- $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";
-
- if ($jobrange and $jobstart)
- $get_metric_string .= "&jr=$jobrange&js=$jobstart";
-
- # Set the Alternate view link.
- $cluster_url=rawurlencode($clustername);
- $node_url=rawurlencode($hostname);
-
- # Make some information available to templates.
- $tpl->assign("cluster_url", $cluster_url);
- # Build the node_menu
- $node_menu = "";
-
- if ($parentgrid) {
- $node_menu .= "$parentgrid $meta_designator ";
- $node_menu .= ">\n";
- }
-
- # Show grid.
- $mygrid = ($self == "unspecified") ? "" : $self;
- $node_menu .= "$mygrid $meta_designator ";
- $node_menu .= ">\n";
-
- if ($physical)
- $node_menu .= hiddenvar("p", $physical);
-
- if ( $clustername ) {
- $url = rawurlencode($clustername);
- $node_menu .= "$clustername ";
- $node_menu .= ">\n";
- $node_menu .= hiddenvar("c", $clustername);
- }
-
- if (!count($metrics)) {
- echo "Cannot find any metrics for selected cluster \"$clustername\", exiting.
\n";
- echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n";
- exit;
- }
- reset($metrics);
- $firsthost = key($metrics);
-
- $mmfh = array();
-
- $mmfh = $metrics[$firsthost];
-
- $context_metrics = array();
-
- foreach( $mmfh as $mm => $bla )
- {
- $context_metrics[] = $mm;
- }
-
- foreach ($reports as $mr => $mfoo)
- $context_metrics[] = $mr;
-
- $node_menu .= "Joblist ";
-
- if( isset( $hostname ) && ( $view != 'host' ) ) {
-
- $node_menu .= ">\n";
- $href = "";
- $node_menu .= "$href";
- $node_menu .= "host: $hostname ";
- }
-
- if( count( $filter ) > 0 && $view != "search" ) {
-
- $my_ct = 1;
- $filter_nr = count( $filter );
-
- foreach( $filter as $filtername=>$filterval ) {
-
- $node_menu .= ">\n";
-
- $href = "$n_filterval ) {
-
- if( $temp_ct < $my_ct ) {
- $href .= "&". $n_filtername . "=" . $n_filterval;
-
- if( $my_filterorder == "" )
- $my_filterorder = $my_filters[$temp_ct];
- else
- $my_filterorder .= "," . $my_filters[$temp_ct];
- }
-
- $temp_ct++;
- }
- $href .= "&filterorder=$my_filterorder\">";
-
- if( $my_ct < $filter_nr )
- $node_menu .= "$href$filtername: $filterval ";
- else
- $node_menu .= "$filtername: $filterval ";
-
- $my_ct++;
- }
- }
-
- $tpl->gotoBlock( "_ROOT" );
- $tpl->assignGlobal("view", $view);
-
-
- if( array_key_exists( "id", $filter ) or isset($hostname) ) {
-
- $range = "job";
-
- if( $page_call != "host_view" )
- {
-
- if (is_array($context_metrics) ) {
- $metric_menu = "Metric "
- ."