Changeset 514


Ignore:
Timestamp:
03/08/08 21:16:32 (16 years ago)
Author:
bastiaans
Message:

jobmond/jobmond.py:

  • added report time to down/offline nodes
  • added domain name to down/offline nodes

web/addons/job_monarch/libtoga.php:

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.py

    r513 r514  
    490490                if BATCH_API == 'pbs':
    491491
     492                        domain          = fqdn_parts( socket.getfqdn() )[1]
     493
    492494                        downed_nodes    = list()
    493495                        offline_nodes   = list()
     
    505507                                        offline_nodes.append( name )
    506508
    507                         self.dp.multicastGmetric( 'MONARCH-DOWN'   , string.join( downed_nodes,  ',' ) )
    508                         self.dp.multicastGmetric( 'MONARCH-OFFLINE', string.join( offline_nodes, ',' ) )
     509                        downnodeslist           = do_nodelist( downed_nodes )
     510                        offlinenodeslist        = do_nodelist( offline_nodes )
     511
     512                        down_str        = 'nodes=%s domain=%s reported=%s' %( string.join( downnodeslist, ';' ), domain, str( int( int( self.cur_time ) + int( self.timeoffset ) ) ) )
     513                        offl_str        = 'nodes=%s domain=%s reported=%s' %( string.join( offlinenodeslist, ';' ), domain, str( int( int( self.cur_time ) + int( self.timeoffset ) ) ) )
     514                        self.dp.multicastGmetric( 'MONARCH-DOWN'   , down_str )
     515                        self.dp.multicastGmetric( 'MONARCH-OFFLINE', offl_str )
    509516
    510517                # Now let's spread the knowledge
  • trunk/web/addons/job_monarch/libtoga.php

    r496 r514  
    126126}
    127127
     128
    128129class TarchDbase {
    129130
     
    566567                $this->nodes            = array();
    567568                $heartbeat              = array();
     569                $down_nodes             = array();
     570                $offline_nodes          = array();
    568571                $this->clustername      = $clustername;
    569572                $this->fqdn             = 1;
     
    573576
    574577                return $this->fqdn;
     578       
     579       
    575580        }
    576581
     
    600605        }
    601606
     607        function makeHostname( $thostname, $tdomain=null )
     608        {
     609                // Should hostname be FQDN or short w/o domain
     610                //
     611                $nodes = &$this->nodes;
     612
     613                $fqdn = 1;
     614
     615                //$tdomain = explode( '.', $thostname );
     616                // TODO: domain van hostname afhalen: parameter weghalen
     617
     618                if( $tdomain )
     619                {
     620                        $domain_len     = 0 - strlen( $tdomain );
     621
     622                        // Let's see if Ganglia use's FQDN or short hostnames
     623                        //
     624                        foreach( $nodes as $hostname => $nimage )
     625                        {
     626       
     627                                if( substr( $hostname, $domain_len ) != $tdomain )
     628                                {
     629                                        $fqdn   = 0;
     630                                }
     631                        }
     632                }
     633                else
     634                {
     635                        $fqdn   = 0;
     636                }
     637       
     638                if( $tdomain && $fqdn )
     639                {
     640                        if( substr( $thostname, $domain_len ) != $tdomain )
     641                        {
     642                                $thostname = $thostname . '.'.$tdomain;
     643                        }
     644                        else
     645                        {
     646                                $thostname = $thostname;
     647                        }
     648                }
     649
     650                return $thostname;
     651        }
     652
    602653        function startElement( $parser, $name, $attrs ) {
    603654
     
    640691                } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) {
    641692
    642                         if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) ) {
    643 
     693                        if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) )
     694                        {
    644695                                $this->heartbeat['time'] = $attrs[VAL];
    645                                 //printf( "heartbeat %s\n", $heartbeat['time'] );
     696                        }
     697                        else if( strstr( $attrs[NAME], 'MONARCH-DOWN' ) )
     698                        {
     699                                $fields         = explode( ' ', $attrs[VAL] );
     700
     701                                $nodes_down     = array();
     702                                $down_domain    = null;
     703
     704                                foreach( $fields as $f )
     705                                {
     706                                        $togavalues     = explode( '=', $f );
     707
     708                                        $toganame       = $togavalues[0];
     709                                        $togavalue      = $togavalues[1];
     710
     711                                        if( $toganame == 'nodes' )
     712                                        {
     713                                                $mynodes = explode( ';', $togavalue );
     714
     715                                                foreach( $mynodes as $node )
     716                                                {
     717                                                        $nodes_down[] = $node;
     718                                                }
     719                                        }
     720                                        else if( $toganame == 'domain' )
     721                                        {
     722                                                $down_domain = $togavalue;
     723                                        }
     724                                        else if( $toganame == 'reported' )
     725                                        {
     726                                                if( !isset( $this->down_nodes['heartbeat'] ) )
     727                                                {
     728                                                        $this->down_nodes[$togavalue]   = array( $nodes_down, $down_domain );
     729                                                }
     730                                        }
     731                                }
     732
     733                        } else if( strstr( $attrs[NAME], 'MONARCH-OFFLINE' ) ) {
     734
     735                                $fields         = explode( ' ', $attrs[VAL] );
     736
     737                                $nodes_offline  = array();
     738                                $offline_domain = null;
     739
     740                                foreach( $fields as $f )
     741                                {
     742                                        $togavalues     = explode( '=', $f );
     743
     744                                        $toganame       = $togavalues[0];
     745                                        $togavalue      = $togavalues[1];
     746
     747                                        if( $toganame == 'nodes' )
     748                                        {
     749                                                $mynodes = explode( ';', $togavalue );
     750
     751                                                foreach( $mynodes as $node )
     752                                                {
     753                                                        $nodes_offline[] = $node;
     754                                                }
     755                                        }
     756                                        else if( $toganame == 'domain' )
     757                                        {
     758                                                $offline_domain = $togavalue;
     759                                        }
     760                                        else if( $toganame == 'reported' )
     761                                        {
     762                                                if( !isset( $this->offline_nodes['heartbeat'] ) )
     763                                                {
     764                                                        $this->offline_nodes[$togavalue] = array( $nodes_offline, $offline_domain );
     765                                                }
     766                                        }
     767                                }
    646768
    647769                        } else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) ) {
     
    762884
    763885        function stopElement( $parser, $name ) {
     886
     887                $nodes  = $this->nodes;
     888
     889                if( $name == "GANGLIA_XML" )
     890                {
     891                        foreach( $this->down_nodes as $reported => $dnodes )
     892                        {
     893
     894                                if( $reported == $this->heartbeat['time'] )
     895                                {
     896                                        $domain = $dnodes[1];
     897
     898                                        foreach( $dnodes[0] as $downhost )
     899                                        {
     900                                                $downhost = $this->makeHostname( $downhost, $domain );
     901
     902                                                if( isset( $nodes[$downhost] ) )
     903                                                {
     904                                                        // OMG PHP4 is fking stupid!
     905                                                        // $nodes[$downhost]->setDown( 1 ) won't work here..
     906                                                        //
     907                                                        $mynode = $nodes[$downhost];
     908                                                        $mynode->setDown( 1 );
     909                                                        $nodes[$downhost] = $mynode;
     910                                                }
     911                                        }
     912                                }
     913                        }
     914
     915                        foreach( $this->offline_nodes as $reported => $onodes )
     916                        {
     917                                if( $reported == $this->heartbeat['time'] )
     918                                {
     919                                        $domain = $onodes[1];
     920
     921                                        foreach( $onodes[0] as $offlinehost )
     922                                        {
     923                                                $offlinehost = $this->makeHostname( $offlinehost, $domain );
     924
     925                                                if( isset( $nodes[$offlinehost] ) )
     926                                                {
     927                                                        // OMG PHP4 is fking stupid!
     928                                                        // $nodes[$offlinehost]->setDown( 1 ) won't work here..
     929                                                        //
     930                                                        $mynode = $nodes[$offlinehost];
     931                                                        $mynode->setOffline( 1 );
     932                                                        $nodes[$offlinehost] = $mynode;
     933                                                }
     934                                        }
     935                                }
     936                        }
     937                }
     938
     939                $this->nodes = $nodes;
    764940        }
    765941
     
    8511027                $this->showinfo = 1;
    8521028                $this->size = $SMALL_CLUSTERIMAGE_NODEWIDTH;
     1029                $this->down = 0;
     1030                $this->offline = 0;
    8531031        }
    8541032
     
    8781056
    8791057                $this->tasks = $this->tasks + $cpus;
     1058        }
     1059
     1060        function setDown( $down ) {
     1061
     1062                $this->down = $down;
     1063        }
     1064
     1065        function isDown() {
     1066
     1067                return $this->down;
     1068        }
     1069        function setOffline( $offline ) {
     1070
     1071                $this->offline = $offline;
     1072        }
     1073
     1074        function isOffline() {
     1075
     1076                return $this->offline;
    8801077        }
    8811078
     
    8981095
    8991096                $area_href              = "./?c=" . $this->clustername . "&h=" . $this->hostname;
    900                 $area_tooltip           = $this->hostname . ": " . implode( " ", $this->jobs );
     1097
     1098                $area_tooltip           = $this->hostname;
     1099
     1100                if( $this->down)
     1101                {
     1102                        $area_tooltip           = $area_tooltip . ": DOWN";
     1103                }
     1104                else if( $this->offline )
     1105                {
     1106                        $area_tooltip           = $area_tooltip . ": OFFLINE";
     1107                }
     1108
     1109                $area_tooltip           = $area_tooltip . ": " . implode( " ", $this->jobs );
    9011110
    9021111                $tag_href               = "HREF=\"" . $area_href . "\"";
     
    9551164        function draw() {
    9561165
    957                 global $JOB_NODE_MARKING;
     1166                global $JOB_NODE_MARKING, $NODE_DOWN_MARKING, $NODE_OFFLINE_MARKING;
    9581167
    9591168                $black_color = imageColorAllocate( $this->image, 0, 0, 0 );
     
    9781187                        $usecolor = $this->colorHex( load_color($load) );
    9791188                        imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor );
    980                         if( count( $this->jobs ) > 0 )
     1189                        if( $this->down )
     1190                        {
     1191                                imageString( $this->image, 1, $this->x+(($size/2)-1), $this->y+(($size/2)-4), $NODE_DOWN_MARKING, $black_color );
     1192                        }
     1193                        else if( $this->offline )
     1194                        {
     1195                                imageString( $this->image, 1, $this->x+(($size/2)-1), $this->y+(($size/2)-4), $NODE_OFFLINE_MARKING, $black_color );
     1196                        }
     1197                        else if( count( $this->jobs ) > 0 )
     1198                        {
    9811199                                imageString( $this->image, 1, $this->x+(($size/2)-1), $this->y+(($size/2)-4), $JOB_NODE_MARKING, $black_color );
     1200                        }
    9821201
    9831202                } else {
Note: See TracChangeset for help on using the changeset viewer.