Changeset 122


Ignore:
Timestamp:
06/01/05 16:55:14 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/templates/overview.tpl:

  • Cosmetic HTML change

web/addons/toga/index.php:

  • Added Joblist filter tree text

web/addons/toga/overview.php:

  • Setup clusterimage filter

web/addons/toga/image.php:

  • Added filter handling

web/addons/toga/libtoga.php:

Location:
trunk/web/addons/toga
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/image.php

    r117 r122  
    11<?php
    22include_once "./libtoga.php";
     3
     4if ( !empty( $_GET ) ) {
     5        extract( $_GET );
     6}
    37
    48$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
     
    610$clustername = $httpvars->getClusterName();
    711
     12if( isset($id) && ($id!='')) $filter = 'id';
     13else if( isset($state) && ($state!='')) $filter='state';
     14else if( isset($user) && ($user!='')) $filter='user';
     15else if( isset($queue) && ($queue!='')) $filter='queue';
     16
    817function drawSmallClusterImage() {
    918
    10         $ic = new ClusterImage( $clustername, null );
     19        $ic = new ClusterImage( $clustername );
    1120        $ic->draw();
    1221}
     
    1423function drawBigClusterImage() {
    1524
    16         $ic = new ClusterImage( $clustername, null );
     25        global $filter, $queue, $id, $user;
     26
     27        $ic = new ClusterImage( $clustername );
     28        switch( $filter ) {
     29
     30                case "id":
     31                        $ic->setFilter( 'jobid', $id );
     32                        break;
     33                case "user":
     34                        $ic->setFilter( 'owner', $user);
     35                        break;
     36                case "queue":
     37                        $ic->setFilter( 'queue', $queue);
     38                        break;
     39                default:
     40                        break;
     41        }
    1742        $ic->draw();
    1843}
  • trunk/web/addons/toga/index.php

    r119 r122  
    3535        global $page, $gridwalk, $clustername;
    3636        global $parentgrid, $physical, $hostname;
    37         global $self, $filter;
     37        global $self, $filter, $cluster_url, $get_metric_string;
    3838
    3939        if ( $context == "control" && $controlroom < 0 )
     
    129129        if ( $clustername ) {
    130130                $url = rawurlencode($clustername);
    131                 $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">$clustername</A></B> ";
    132                 //$node_menu .= "<B>&gt;</B>\n";
     131                $node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> ";
     132                $node_menu .= "<B>&gt;</B>\n";
    133133                $node_menu .= hiddenvar("c", $clustername);
    134134        }
     135
     136        $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";
    135137
    136138        if( count( $filter ) > 0 ) {
  • trunk/web/addons/toga/libtoga.php

    r117 r122  
    334334class NodeImage {
    335335
    336         var $image, $x, $y, $hostname, $jobs, $tasks;
     336        var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo;
    337337
    338338        function NodeImage( $hostname ) {
     
    345345                $this->hostname = $hostname;
    346346                $this->cpus = $this->determineCpus();
     347                $this->showinfo = 1;
    347348        }
    348349
     
    400401        }
    401402
     403        function getHostname() {
     404                return $this->hostname;
     405        }
     406
    402407        function getJobs() {
    403408                return $this->jobs;
    404409        }
    405410
     411        function setShowinfo( $showinfo ) {
     412                $this->showinfo = $showinfo;
     413        }
     414
    406415        function draw() {
    407416
    408                 global $SMALL_CLUSTERIMAGE_NODEWIDTH, $JOB_NODE_MARKING_ALLCPUS, $JOB_NODE_MARKING_SINGLECPU;
     417                $this->drawSmall();
     418        }
     419
     420        function drawBig() {
     421
     422        }
     423
     424        function drawSmall() {
     425
     426                global $SMALL_CLUSTERIMAGE_NODEWIDTH;
    409427                global $JOB_NODE_MARKING;
    410428
    411                 $this->load = $this->determineLoad();
    412 
    413                 if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) {
    414                         printf( "aborting\n" );
    415                         printf( "x %d y %d load %f\n", $this->x, $this->y, $load );
    416                         return;
    417                 }
    418 
    419429                $black_color = imageColorAllocate( $this->image, 0, 0, 0 );
    420 
    421                 // Convert Ganglias Hexadecimal load color to a Decimal one
    422                 //
    423                 $load = $this->determineLoad();
    424                 $my_loadcolor = $this->colorHex( load_color($load) );
    425 
    426430                $size = $SMALL_CLUSTERIMAGE_NODEWIDTH;
    427431
    428432                imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color );
    429                 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor );
    430 
    431                 $nr_jobs = count( $this->jobs );
    432 
    433                 $node_mark = null;
    434 
    435                 if( count( $this->jobs ) > 0 )
    436                         $node_mark = $JOB_NODE_MARKING;
    437 
    438                 //      if( $this->tasks < $this->cpus )
    439                 //              $node_mark = $JOB_NODE_MARKING_SINGLECPU;
    440 
    441                 //      else if( $this->tasks == $this->cpus )
    442                 //              $node_mark = $JOB_NODE_MARKING_ALLCPUS;
    443 
    444                 if( $node_mark )
    445                         imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $node_mark, $black_color );
     433
     434                if( $this->showinfo) {
     435               
     436                        $this->load = $this->determineLoad();
     437
     438                        if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) {
     439                                printf( "aborting\n" );
     440                                printf( "x %d y %d load %f\n", $this->x, $this->y, $load );
     441                                return;
     442                        }
     443
     444
     445                        // Convert Ganglias Hexadecimal load color to a Decimal one
     446                        //
     447                        $load = $this->determineLoad();
     448                        $usecolor = $this->colorHex( load_color($load) );
     449                        imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor );
     450                        if( count( $this->jobs ) > 0 )
     451                                imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $JOB_NODE_MARKING, $black_color );
     452
     453                } else {
     454
     455                        // White
     456                        $usecolor = imageColorAllocate( $this->image, 255, 255, 255 );
     457                        imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor );
     458                }
     459
     460
    446461        }
    447462
     
    470485
    471486        var $dataget, $image, $clustername;
    472 
    473         function ClusterImage( $clustername, $data_gather ) {
    474 
    475                 if( !isset( $data_gather ) )
    476                         $this->dataget = new DataGatherer();
    477                 else
    478                         $this->dataget = $data_gather;
    479 
     487        var $filtername, $filtervalue;
     488
     489        function ClusterImage( $clustername ) {
     490
     491                $this->dataget = new DataGatherer();
    480492                $this->clustername = $clustername;
     493                $this->filtername = null;
     494                $this->filtervalue = null;
     495        }
     496
     497        function setFilter( $filtername, $filtervalue ) {
     498
     499                //printf( "filter set to %s = %s\n", $filtername, $filtervalue );
     500                $this->filtername = $filtername;
     501                $this->filtervalue = $filtervalue;
     502        }
     503
     504        function filterNodes( $jobs, $nodes ) {
     505
     506                $filtered_nodes = array();
     507
     508                foreach( $nodes as $node ) {
     509
     510                        $mynjobs = $node->getJobs();
     511                        $hostname = $node->getHostname();
     512
     513                        if( $this->filtername ) {
     514                                foreach( $mynjobs as $myjob )
     515
     516                                        if( $this->filtername == 'jobid' && $node->hasJob( $this->filtervalue) )
     517                                                $filtered_nodes[] = $hostname;
     518                                        else if( $jobs[$myjob][$this->filtername] == $this->filtervalue  && !in_array( $hostname, $filtered_nodes  ) )
     519                                                $filtered_nodes[] = $hostname;
     520                        } else
     521                                $filtered_nodes[] = $hostname;
     522                }
     523
     524                return $filtered_nodes;
    481525        }
    482526
     
    526570                imageFill( $image, 0, 0, $colorwhite );
    527571
     572                $jobs = $mydatag->getJobs();
     573                //printf("filtername = %s\n", $filtername );
     574                $filtered_nodes = $this->filterNodes( $jobs, $nodes );
     575
     576                //print_r($filtered_nodes);
     577
    528578                for( $n = 0; $n < $node_rows; $n++ ) {
    529579                       
     
    536586                                $host = $nodes_hosts[$cur_node];
    537587
     588
    538589                                if( isset( $nodes[$host] ) ) {
    539590
    540591                                        $nodes[$host]->setCoords( $x, $y );
    541592                                        $nodes[$host]->setImage( $image );
     593
     594                                        if( !in_array( $host, $filtered_nodes ) )
     595                                                $nodes[$host]->setShowinfo( 0 );
     596
    542597                                        $nodes[$host]->draw();
    543598                                }
  • trunk/web/addons/toga/overview.php

    r120 r122  
    11<?php
    2 global $GANGLIA_PATH, $clustername, $tpl, $filter;
     2global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url;
    33
    44$data_gatherer = new DataGatherer();
     
    66//$tpl->assign( "self", "./index.php" );
    77$tpl->assign( "clustername", $clustername );
    8 $tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage" );
    98
    109$data_gatherer->parseXML();
     
    1413$nodes = $data_gatherer->getNodes();
    1514
     15$filter_image_url = "";
     16
    1617foreach( $filter as $filtername => $filtervalue ) {
    1718        $tpl->assign( "f_".$filtername, $filtervalue );
    18 }
     19        $filter_image_url .= "&$filtername=$filtervalue";
     20}
     21
     22$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
    1923
    2024$tpl->assign("heartbeat", makeDate( $heartbeat ) );
     
    2226$pie = drawPie();
    2327$tpl->assign("pie", $pie );
     28
     29//if( !array_key_exists( 'id', $filter ) ) {
     30
     31//      $graph_args = "c=$cluster_url&$get_metric_string&st=$cluster[LOCALTIME]";
     32//      $tpl->newBlock( "average_graphs" );
     33//      $tpl->assign( "graph_args", $graph_args );
     34//}
    2435
    2536function timeToEpoch( $time ) {
  • trunk/web/addons/toga/templates/overview.tpl

    r121 r122  
    44<TABLE>
    55<TR>
    6   <TD>
     6  <TD ALIGN="CENTER">
    77    <IMG SRC="{clusterimage}"><BR>
    88    reported: {heartbeat}
    99  </TD>
    10   <TD>
     10  <TD ALIGN="CENTER">
    1111    <IMG SRC="{pie}">
    1212  </TD>
Note: See TracChangeset for help on using the changeset viewer.