Changeset 110 for trunk/web


Ignore:
Timestamp:
05/20/05 15:32:17 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/toga-functions.php:

Renamed -> libtoga.php

web/addons/toga/libtoga.php:

new toga-functions.php:

  • Now nodes are correctly marked in clusterimage with a 'j' for single processor jobs and a 'J' for multi processor jobs

web/addons/toga/image.php:

  • Script for generating images

web/addons/toga/conf.php:

  • Configuration for web frontend

web/templates/toga/cluster_extra.tpl:

  • Plugin html template for ganglia

client:

  • Leftover removal from first tree
  • This is named 'plugin' atm
Location:
trunk/web
Files:
3 added
1 moved

Legend:

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

    r109 r110  
    11<?php
    2 $GANGLIA_PATH = "/var/www/ganglia";
     2//$GANGLIA_PATH = "/var/www/ganglia";
     3
     4// Toga's conf
     5//
     6include_once "./conf.php";
     7
     8global $GANGLIA_PATH, $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE;
     9
     10//printf("gpath %s clmaxw %s ndmaxw %s ds %s",$GANGLIA_PATH, $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE);
    311
    412include_once "$GANGLIA_PATH/conf.php";
     
    2937
    3038        var $clustername, $metricname;
     39        var $restvars;
    3140
    3241        function HTTPVariables() {
     42
     43                $this->restvars = array();
    3344
    3445                global $HTTP_GET_VARS;
     
    3647                $this->clustername = $HTTP_GET_VARS["c"] ? $HTTP_GET_VARS["c"] : null;
    3748                $this->metricname = $HTTP_GET_VARS["m"] ? $HTTP_GET_VARS["m"] : null;
     49
     50                foreach( $HTTP_GET_VARS as $httpvar => $httpval ) {
     51                       
     52                        if( $httpval ) {
     53                                $this->restvars[$httpvar] = $httpval;
     54                        }
     55                }
    3856        }
    3957
     
    4462        function getMetricName() {
    4563                return $this->metricname;
     64        }
     65
     66        function getHttpVar( $var ) {
     67                if( isset( $this->restvars[$var] ) )
     68                        return $retval;
     69                else
     70                        return null;
    4671        }
    4772}
     
    86111        function DataGatherer() {
    87112
     113                global $DATA_SOURCE;
     114               
     115                $ds_fields = explode( ':', $DATA_SOURCE );
     116                $ds_ip = $ds_fields[0];
     117                $ds_port = $ds_fields[1];
     118
     119                $this->source = new DataSource( $ds_ip, $ds_port );
     120
    88121                $this->parser = xml_parser_create();
    89                 $this->source = new DataSource();
    90122                $this->httpvars = new HTTPVariables();
    91123                $this->xmlhandler = new TorqueXMLHandler();
     
    132164        }
    133165
    134         function gotNode( $hostname, $location = 'unspecified', $jobid = null ) {
     166        function gotNode( $hostname, $location = 'unspecified', $jobid ) {
    135167
    136168                $nodes = &$this->nodes;
     
    148180                if( $jobid ) {
    149181                        $nodes[$hostname]->addJob( $jobid );
     182                        //printf("add job %s to node %s", $jobid, $hostname );
    150183                }
    151184        }
     
    218251                                                        $jobs[$jobid][$toganame][] = $hostname;
    219252                                                        $this->gotNode( $hostname, null, $jobid );
     253                                                        //printf( "got job %s on node %s", $jobid, $hostname );
    220254                                                }
    221255
     
    294328
    295329                $jobs[] = $jobid;
     330                //print_r( $jobs );
     331                $this->jobs = $jobs;
    296332        }
    297333
     
    321357
    322358        function getJobs() {
     359                //print_r( $this->jobs );
    323360                return $this->jobs;
    324361        }
     
    351388class NodeImage {
    352389
    353         var $image, $x, $y, $hostname;
    354 
    355         function NodeImage( $image, $x, $y ) {
     390        var $image, $x, $y, $hostname, $jobs;
     391
     392        function NodeImage( $image, $x, $y, $hostname, $multiproc_job ) {
    356393
    357394                $this->image = $image;
    358395                $this->x = $x;
    359396                $this->y = $y;
     397                $this->hostname = $hostname;
     398                $this->multiproc_job = $multiproc_job;
    360399        }
    361400
     
    386425
    387426        function drawNode( $load ) {
     427
     428                global $SMALL_CLUSTERIMAGE_NODEWIDTH;
    388429
    389430                if( !isset( $this->x ) or !isset( $this->y ) or !isset( $load ) ) {
     
    393434                }
    394435
    395                 $queue_color = imageColorAllocate( &$this->image, 0, 102, 304 );
    396                 $job_color = imageColorAllocate( &$this->image, 204, 204, 0 );
     436                $black_color = imageColorAllocate( &$this->image, 0, 0, 0 );
    397437
    398438                // Convert Ganglias Hexadecimal load color to a Decimal one
    399439                $my_loadcolor = $this->colorHex( load_color($load) );
    400440
    401                 imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+11, $this->y+11, $queuecolor );
    402                 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+10, $this->y+10, $my_loadcolor );
     441                $size = $SMALL_CLUSTERIMAGE_NODEWIDTH;
     442
     443                imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color );
     444                imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor );
     445                if( $this->multiproc_job == 2 )
     446                        imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), "J", $black_color );
     447                else if( $this->multiproc_job == 1 )
     448                        imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), "j", $black_color );
    403449
    404450                // Een job markering?
     
    429475
    430476        function draw() {
     477
     478                global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH;
     479       
    431480                $mydatag = $this->dataget;
    432481                $mydatag->parseXML();
    433482
    434                 $max_width = 250;
    435                 $node_width = 11;
     483                //$max_width = 250;
     484                //$node_width = 11;
     485
     486                $max_width = $SMALL_CLUSTERIMAGE_MAXWIDTH;
     487                $node_width = $SMALL_CLUSTERIMAGE_NODEWIDTH;
     488
     489                //printf( "cmaxw %s nmaxw %s", $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH );
    436490
    437491                $nodes = $mydatag->getNodes();
     
    479533                                if( isset( $nodes[$host] ) and ($cur_node < $nodes_nr) ) {
    480534                                        //printf( "image %s\n", $host );
    481                                         $node = new NodeImage( $image, $x, $y );
    482                                         $node->setHostname( $host );
     535                                        $nodejobs = $nodes[$host]->getJobs();
     536                                        $jobs = $mydatag->getJobs();
     537
     538                                        $multiproc_job = 0;
     539
     540                                        if( count( $nodejobs ) > 0 ) {
     541                                                $multiproc_job = 1;
     542
     543                                                foreach( $nodejobs as $myjob ){
     544                                                        if( isset($jobs[$myjob]['ppn']) and $jobs[$myjob]['ppn'] > 1 )
     545                                                                $multiproc_job = 2;
     546                                                                break;
     547                                                }
     548                                        }
     549
     550                                        //printf( "jobs %s node %s", $nrjobs, $host );
     551                                        $node = new NodeImage( $image, $x, $y, $host, $multiproc_job );
     552                                        //$node->setHostname( $host );
    483553                                        $node->draw();
    484554                                        //$nodes[$host]->setCoords( $x, $y );
Note: See TracChangeset for help on using the changeset viewer.