Ignore:
Timestamp:
04/21/07 16:22:47 (17 years ago)
Author:
bastiaans
Message:

web/addons/job_monarch/overview.php:

  • make our own datasource
  • store the XML data in a session for the clusterimage
  • assign a image map of clickable nodes for the clusterimage

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

  • add node_clustermap imagemap block

web/addons/job_monarch/libtoga.php:

web/addons/job_monarch/image.php:

Location:
trunk/web/addons/job_monarch
Files:
4 edited

Legend:

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

    r305 r326  
    2929}
    3030
     31function checkSessionData() {
     32
     33        global $_SESSION;
     34
     35        session_start();
     36
     37        if( isset( $_SESSION["data"] ) ) {
     38                $myxml_data     = &$_SESSION["data"];
     39        } else {
     40                $myxml_data     = 0;
     41        }
     42
     43        if( !$myxml_data ) {
     44                $ds             = new DataSource();
     45                $myxml_data     = $ds->getData();
     46
     47                print_f( "%s\n", $myxml_data );
     48        }
     49        return $myxml_data;
     50}
     51
     52
    3153$httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
    3254$view = $httpvars->getHttpVar( "view" );
     
    4163function drawHostImage() {
    4264
    43         global $clustername, $hostname;
     65        global $clustername, $hostname, $data_gatherer;
    4466
    45         $data_gatherer = new DataGatherer( $clustername );
    46         $data_gatherer->parseXML();
     67        $ds             = new DataSource();
     68        $myxml_data     = $ds->getData();
     69
     70        $data_gatherer  = new DataGatherer( $clustername );
     71
     72        $data_gatherer->parseXML( $myxml_data );
    4773
    4874        if( $data_gatherer->isJobmonRunning() )
     
    5682function drawSmallClusterImage() {
    5783
    58         global $clustername;
     84        global $clustername, $data_gatherer;
    5985
    60         $data_gatherer = new DataGatherer( $clustername );
    61         $data_gatherer->parseXML();
     86        $ds             = new DataSource();
     87        $myxml_data     = $ds->getData();
     88
     89        $data_gatherer  = new DataGatherer( $clustername );
     90
     91        $data_gatherer->parseXML( $myxml_data );
    6292
    6393        if( $data_gatherer->isJobmonRunning() ) {
    64                 $ic = new ClusterImage( $clustername );
     94                $ic = new ClusterImage( $myxml_data, $clustername );
    6595                $ic->setSmall();
    6696        } else {
     
    75105        global $filter, $clustername;
    76106
    77         $ic = new ClusterImage( $clustername );
     107        $myxml_data     = checkSessionData();
     108
     109        $ic = new ClusterImage( $myxml_data, $clustername );
    78110        $ic->setBig();
    79111
  • trunk/web/addons/job_monarch/libtoga.php

    r313 r326  
    417417        var $data, $ip, $port;
    418418
    419         function DataSource( $ip = '127.0.0.1', $port = 8649 ) {
    420                 $this->ip = $ip;
    421                 $this->port = $port;
     419        //function DataSource( $ip = '127.0.0.1', $port = 8649 ) {
     420        function DataSource() {
     421
     422                global $DATA_SOURCE;
     423
     424                $ds_fields      = explode( ':', $DATA_SOURCE );
     425
     426                $ds_ip          = $ds_fields[0];
     427                $ds_port        = $ds_fields[1];
     428
     429                $this->ip       = $ds_ip;
     430                $this->port     = $ds_port;
     431
    422432        }
    423433
     
    454464        function DataGatherer( $cluster ) {
    455465
    456                 global $DATA_SOURCE;
     466                //global $DATA_SOURCE;
    457467       
    458468                //printf("dg cluster = %s\n", $cluster );
    459                 $ds_fields = explode( ':', $DATA_SOURCE );
    460                 $ds_ip = $ds_fields[0];
    461                 $ds_port = $ds_fields[1];
    462 
    463                 $this->source = new DataSource( $ds_ip, $ds_port );
    464 
    465                 $this->parser = xml_parser_create();
     469                //$ds_fields = explode( ':', $DATA_SOURCE );
     470                //$ds_ip = $ds_fields[0];
     471                //$ds_port = $ds_fields[1];
     472
     473                //$this->source = new DataSource( $ds_ip, $ds_port );
     474
     475                $this->cluster  = $cluster;
    466476                $this->httpvars = $httpvars;
    467                 $this->xmlhandler = new TorqueXMLHandler( $cluster );
     477        }
     478
     479        function parseXML( $data ) {
     480
     481                //$src = &$this->source;
     482                //$this->data = $src->getData();
     483
     484                $this->parser           = xml_parser_create();
     485                $this->xmlhandler       = new TorqueXMLHandler( $this->cluster );
     486
    468487                xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) );
    469         }
    470 
    471         function parseXML() {
    472 
    473                 $src = &$this->source;
    474                 $this->data = $src->getData();
    475 
    476                 if ( !xml_parse( $this->parser, $this->data ) )
     488                //if ( !xml_parse( $this->parser, $this->data ) )
     489                if ( !xml_parse( $this->parser, $data ) )
    477490                        $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) );
    478491        }
     
    591604
    592605                        if( !isset( $nodes[$hostname] ) )
    593                                 $nodes[$hostname] = new NodeImage( $hostname );
     606                                $nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname );
    594607
    595608                } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) {
     
    668681                               
    669682                                                        if( !isset( $nodes[$host] ) )
    670                                                                 $my_node = new NodeImage( $host );
     683                                                                $my_node = new NodeImage( $this->proc_cluster, $host );
    671684                                                        else
    672685                                                                $my_node = $nodes[$host];
     
    767780        var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo;
    768781
    769         function NodeImage( $hostname ) {
     782        function NodeImage( $cluster, $hostname ) {
    770783
    771784                global $SMALL_CLUSTERIMAGE_NODEWIDTH;
     
    778791                $this->hostname = $hostname;
    779792                $this->cpus = $this->determineCpus();
     793                $this->clustername = $cluster;
    780794                $this->showinfo = 1;
    781795                $this->size = $SMALL_CLUSTERIMAGE_NODEWIDTH;
     
    818832                $this->x = $x;
    819833                $this->y = $y;
     834        }
     835
     836        function getImagemapArea() {
     837
     838                $area_topleft           = $this->x . "," . $this->y;
     839                $area_bottomright       = ($this->x + $this->size) . "," . ($this->y + $this->size);
     840                $area_coords            = $area_topleft . "," . $area_bottomright;
     841
     842                $area_href              = "./?c=" . $this->clustername . "&h=" . $this->hostname;
     843                $area_tooltip           = $this->hostname . ": " . implode( " ", $this->jobs );
     844
     845                $tag_href               = "HREF=\"" . $area_href . "\"";
     846                $tag_coords             = "COORDS=\"" . $area_coords . "\"";
     847                $tag_tooltip1           = "ALT=\"" . $area_tooltip . "\"";
     848                $tag_tooltip2           = "TITLE=\"" . $area_tooltip . "\"";
     849
     850                return ("<AREA SHAPE=\"RECT\" " . $tag_coords . " " . $tag_href . " " . $tag_tooltip1 . " " . $tag_tooltip2 . ">");
    820851        }
    821852
     
    929960        var $filtername, $filters;
    930961
    931         function ClusterImage( $clustername ) {
    932 
     962        //function ClusterImage( $clustername ) {
     963        function ClusterImage( $data, $clustername ) {
     964
     965                //$this->dataget                = $dataget;
    933966                $this->dataget          = new DataGatherer( $clustername );
     967                $this->data             = $data;
    934968                $this->clustername      = $clustername;
    935969                $this->filters          = array();
    936970                $this->size             = 's';
     971                $this->width            = 0;
     972                $this->height           = 0;
     973                $this->output           = 1;
     974        }
     975
     976        function getWidth() {
     977                return $this->width;
     978        }
     979        function getHeight() {
     980                return $this->height;
    937981        }
    938982
     
    943987        function setBig() {
    944988                $this->size     = 'b';
     989        }
     990
     991        function setNoimage() {
     992                $this->output   = 0;
    945993        }
    946994
     
    10071055       
    10081056                $mydatag = $this->dataget;
    1009                 $mydatag->parseXML();
     1057                $mydatag->parseXML( $this->data );
    10101058
    10111059                if( $this->isSmall() ) {
     
    10481096                $y_offset       = $fontheight + (2 * $fontspaceing);
    10491097
     1098                $this->width    = $max_width;
     1099                $this->height   = ($y_offset + (($node_rows*$node_width)+1) );
     1100
    10501101                $image = imageCreateTrueColor( $max_width, ($y_offset + (($node_rows*$node_width)+1) ) );
    10511102                $colorwhite = imageColorAllocate( $image, 255, 255, 255 );
     
    10901141                        }
    10911142                }
    1092                
    1093                 header( 'Content-type: image/png' );
    1094                 imagePNG( $image );
    1095                 imageDestroy( $image );
     1143       
     1144                $this->nodes    = &$nodes;
     1145
     1146                if ($this->output) {
     1147                        header( 'Content-type: image/png' );
     1148                        imagePNG( $image );
     1149                        imageDestroy( $image );
     1150                }
     1151        }
     1152
     1153        function getImagemapArea() {
     1154
     1155                $clusterimage_map       = "";
     1156
     1157                foreach( $this->nodes as $hostname => $node ) {
     1158
     1159                        $node_map               = $node->getImagemapArea();
     1160                        $clusterimage_map       .= $node_map;
     1161                }
     1162
     1163                return $clusterimage_map;
    10961164        }
    10971165}
  • trunk/web/addons/job_monarch/overview.php

    r322 r326  
    2626global $hosts_up, $m, $start, $end, $filterorder, $COLUMN_REQUESTED_MEMORY, $COLUMN_QUEUED, $COLUMN_NODES, $hostname, $piefilter;
    2727
     28$ds             = new DataSource();
     29$myxml_data     = $ds->getData();
     30
    2831$data_gatherer = new DataGatherer( $clustername );
    2932
     
    3336        $tpl->assign( "cluster_url", rawurlencode($clustername) );
    3437
    35 $data_gatherer->parseXML();
     38$data_gatherer->parseXML( $myxml_data );
    3639
    3740$heartbeat = $data_gatherer->getHeartbeat();
     
    4144
    4245function setupFilterSettings() {
    43         global $tpl, $filter, $clustername, $piefilter;
     46        global $tpl, $filter, $clustername, $piefilter, $data_gatherer, $myxml_data;
    4447
    4548        $filter_image_url = "";
     
    5255        }
    5356
    54         $tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
     57        //include( "./ci_test.php" );
     58        session_start();
     59        //printf("data %s\n", strval( $myxml_data ) );
     60        $_SESSION["data"] = &$myxml_data;
     61
     62        $ic = new ClusterImage( $myxml_data, $clustername );
     63        $ic->setBig();
     64        $ic->setNoimage();
     65        $ic->draw();
     66
     67        //$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
     68        $tpl->assign( "clusterimage", "./image.php?". session_name() . "=" . session_id() ."&c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
     69
     70        $tpl->assign( "clusterimage_width", $ic->getWidth() );
     71        $tpl->assign( "clusterimage_height", $ic->getHeight() );
     72
     73        $tpl->newBlock( "node_clustermap" );
     74        $tpl->assign( "node_area_map", $ic->getImagemapArea() );
     75        $tpl->gotoBlock( "_ROOT" );
     76
    5577        $tpl->assign( "f_order", $filterorder );
    5678
  • trunk/web/addons/job_monarch/templates/overview.tpl

    r299 r326  
    113113
    114114  <TD ALIGN="CENTER"><CENTER>
    115     <IMG SRC="{clusterimage}"><BR>
     115<!-- INCLUDESCRIPT BLOCK : ci_script -->
     116    <IMG SRC="{clusterimage}" USEMAP="#MONARCH_CLUSTER_BIG" WIDTH="{clusterimage_width}" HEIGHT="{clusterimage_height}" BORDER="0">
     117    <MAP NAME="MONARCH_CLUSTER_BIG">
     118<!-- START BLOCK : node_clustermap -->
     119{node_area_map}
     120<!-- END BLOCK : node_clustermap -->
     121    </MAP>
     122    <BR>
    116123<FONT class="footer">Last updated: {report_time}</FONT></CENTER>
    117124  </TD>
Note: See TracChangeset for help on using the changeset viewer.