Index: trunk/web/addons/toga/image.php =================================================================== --- trunk/web/addons/toga/image.php (revision 121) +++ trunk/web/addons/toga/image.php (revision 122) @@ -1,4 +1,8 @@ getClusterName(); +if( isset($id) && ($id!='')) $filter = 'id'; +else if( isset($state) && ($state!='')) $filter='state'; +else if( isset($user) && ($user!='')) $filter='user'; +else if( isset($queue) && ($queue!='')) $filter='queue'; + function drawSmallClusterImage() { - $ic = new ClusterImage( $clustername, null ); + $ic = new ClusterImage( $clustername ); $ic->draw(); } @@ -14,5 +23,21 @@ function drawBigClusterImage() { - $ic = new ClusterImage( $clustername, null ); + global $filter, $queue, $id, $user; + + $ic = new ClusterImage( $clustername ); + switch( $filter ) { + + case "id": + $ic->setFilter( 'jobid', $id ); + break; + case "user": + $ic->setFilter( 'owner', $user); + break; + case "queue": + $ic->setFilter( 'queue', $queue); + break; + default: + break; + } $ic->draw(); } Index: trunk/web/addons/toga/index.php =================================================================== --- trunk/web/addons/toga/index.php (revision 121) +++ trunk/web/addons/toga/index.php (revision 122) @@ -35,5 +35,5 @@ global $page, $gridwalk, $clustername; global $parentgrid, $physical, $hostname; - global $self, $filter; + global $self, $filter, $cluster_url, $get_metric_string; if ( $context == "control" && $controlroom < 0 ) @@ -129,8 +129,10 @@ if ( $clustername ) { $url = rawurlencode($clustername); - $node_menu .= "$clustername "; - //$node_menu .= ">\n"; + $node_menu .= "$clustername "; + $node_menu .= ">\n"; $node_menu .= hiddenvar("c", $clustername); } + + $node_menu .= "Joblist "; if( count( $filter ) > 0 ) { Index: trunk/web/addons/toga/libtoga.php =================================================================== --- trunk/web/addons/toga/libtoga.php (revision 121) +++ trunk/web/addons/toga/libtoga.php (revision 122) @@ -334,5 +334,5 @@ class NodeImage { - var $image, $x, $y, $hostname, $jobs, $tasks; + var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo; function NodeImage( $hostname ) { @@ -345,4 +345,5 @@ $this->hostname = $hostname; $this->cpus = $this->determineCpus(); + $this->showinfo = 1; } @@ -400,48 +401,62 @@ } + function getHostname() { + return $this->hostname; + } + function getJobs() { return $this->jobs; } + function setShowinfo( $showinfo ) { + $this->showinfo = $showinfo; + } + function draw() { - global $SMALL_CLUSTERIMAGE_NODEWIDTH, $JOB_NODE_MARKING_ALLCPUS, $JOB_NODE_MARKING_SINGLECPU; + $this->drawSmall(); + } + + function drawBig() { + + } + + function drawSmall() { + + global $SMALL_CLUSTERIMAGE_NODEWIDTH; global $JOB_NODE_MARKING; - $this->load = $this->determineLoad(); - - if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) { - printf( "aborting\n" ); - printf( "x %d y %d load %f\n", $this->x, $this->y, $load ); - return; - } - $black_color = imageColorAllocate( $this->image, 0, 0, 0 ); - - // Convert Ganglias Hexadecimal load color to a Decimal one - // - $load = $this->determineLoad(); - $my_loadcolor = $this->colorHex( load_color($load) ); - $size = $SMALL_CLUSTERIMAGE_NODEWIDTH; imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color ); - imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor ); - - $nr_jobs = count( $this->jobs ); - - $node_mark = null; - - if( count( $this->jobs ) > 0 ) - $node_mark = $JOB_NODE_MARKING; - - // if( $this->tasks < $this->cpus ) - // $node_mark = $JOB_NODE_MARKING_SINGLECPU; - - // else if( $this->tasks == $this->cpus ) - // $node_mark = $JOB_NODE_MARKING_ALLCPUS; - - if( $node_mark ) - imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $node_mark, $black_color ); + + if( $this->showinfo) { + + $this->load = $this->determineLoad(); + + if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) { + printf( "aborting\n" ); + printf( "x %d y %d load %f\n", $this->x, $this->y, $load ); + return; + } + + + // Convert Ganglias Hexadecimal load color to a Decimal one + // + $load = $this->determineLoad(); + $usecolor = $this->colorHex( load_color($load) ); + imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); + if( count( $this->jobs ) > 0 ) + imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $JOB_NODE_MARKING, $black_color ); + + } else { + + // White + $usecolor = imageColorAllocate( $this->image, 255, 255, 255 ); + imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); + } + + } @@ -470,13 +485,42 @@ var $dataget, $image, $clustername; - - function ClusterImage( $clustername, $data_gather ) { - - if( !isset( $data_gather ) ) - $this->dataget = new DataGatherer(); - else - $this->dataget = $data_gather; - + var $filtername, $filtervalue; + + function ClusterImage( $clustername ) { + + $this->dataget = new DataGatherer(); $this->clustername = $clustername; + $this->filtername = null; + $this->filtervalue = null; + } + + function setFilter( $filtername, $filtervalue ) { + + //printf( "filter set to %s = %s\n", $filtername, $filtervalue ); + $this->filtername = $filtername; + $this->filtervalue = $filtervalue; + } + + function filterNodes( $jobs, $nodes ) { + + $filtered_nodes = array(); + + foreach( $nodes as $node ) { + + $mynjobs = $node->getJobs(); + $hostname = $node->getHostname(); + + if( $this->filtername ) { + foreach( $mynjobs as $myjob ) + + if( $this->filtername == 'jobid' && $node->hasJob( $this->filtervalue) ) + $filtered_nodes[] = $hostname; + else if( $jobs[$myjob][$this->filtername] == $this->filtervalue && !in_array( $hostname, $filtered_nodes ) ) + $filtered_nodes[] = $hostname; + } else + $filtered_nodes[] = $hostname; + } + + return $filtered_nodes; } @@ -526,4 +570,10 @@ imageFill( $image, 0, 0, $colorwhite ); + $jobs = $mydatag->getJobs(); + //printf("filtername = %s\n", $filtername ); + $filtered_nodes = $this->filterNodes( $jobs, $nodes ); + + //print_r($filtered_nodes); + for( $n = 0; $n < $node_rows; $n++ ) { @@ -536,8 +586,13 @@ $host = $nodes_hosts[$cur_node]; + if( isset( $nodes[$host] ) ) { $nodes[$host]->setCoords( $x, $y ); $nodes[$host]->setImage( $image ); + + if( !in_array( $host, $filtered_nodes ) ) + $nodes[$host]->setShowinfo( 0 ); + $nodes[$host]->draw(); } Index: trunk/web/addons/toga/overview.php =================================================================== --- trunk/web/addons/toga/overview.php (revision 121) +++ trunk/web/addons/toga/overview.php (revision 122) @@ -1,4 +1,4 @@ assign( "self", "./index.php" ); $tpl->assign( "clustername", $clustername ); -$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage" ); $data_gatherer->parseXML(); @@ -14,7 +13,12 @@ $nodes = $data_gatherer->getNodes(); +$filter_image_url = ""; + foreach( $filter as $filtername => $filtervalue ) { $tpl->assign( "f_".$filtername, $filtervalue ); -} + $filter_image_url .= "&$filtername=$filtervalue"; +} + +$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url ); $tpl->assign("heartbeat", makeDate( $heartbeat ) ); @@ -22,4 +26,11 @@ $pie = drawPie(); $tpl->assign("pie", $pie ); + +//if( !array_key_exists( 'id', $filter ) ) { + +// $graph_args = "c=$cluster_url&$get_metric_string&st=$cluster[LOCALTIME]"; +// $tpl->newBlock( "average_graphs" ); +// $tpl->assign( "graph_args", $graph_args ); +//} function timeToEpoch( $time ) { Index: trunk/web/addons/toga/templates/overview.tpl =================================================================== --- trunk/web/addons/toga/templates/overview.tpl (revision 121) +++ trunk/web/addons/toga/templates/overview.tpl (revision 122) @@ -4,9 +4,9 @@
+ |
reported: {heartbeat} |
- + |