Changeset 463 for trunk/web


Ignore:
Timestamp:
02/07/08 10:35:47 (16 years ago)
Author:
bastiaans
Message:

libtoga.php:

  • added getUsingFQDN() functions to determine FQDN usage from overview etc
  • fixed: moved column and row number header printing so that it will always be printed, even if there are nodes missing
  • code cleanup
  • added more comments

overview.php:

  • check getUsingFQDN() whether or not to use a domain name for node hostnames
  • added more comments

version.php:

  • make sure it's know this is a SVN version
Location:
trunk/web/addons/job_monarch
Files:
3 edited

Legend:

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

    r461 r463  
    564564        }
    565565
     566        function getUsingFQDN() {
     567                $handler = $this->xmlhandler;
     568                return $handler->getUsingFQDN();
     569        }
     570
    566571        function getNodes() {
    567572                $handler = $this->xmlhandler;
     
    611616                $this->clustername      = $clustername;
    612617                $this->fqdn             = 1;
     618        }
     619
     620        function getUsingFQDN() {
     621
     622                return $this->fqdn;
    613623        }
    614624
     
    12631273                                $skan_str       = str_replace( "{x}", "%d", $skan_str );
    12641274                                $skan_str       = str_replace( "{y}", "%d", $skan_str );
    1265                                 //printf("ppoep = %s\n", $skan_str);
    12661275                        }
    12671276                        else if( $x_present)
     
    12861295                                if( $x_present && $y_present )
    12871296                                {
    1288                                         //$n    = sscanf( $hostname, $skan_str, $i, $j );
    12891297                                        if( $x_first )
    12901298                                        {
     
    12951303                                                $n = sscanf( $hostname, $skan_str, $y, $x );
    12961304                                        }
     1305
    12971306                                        // Remove nodes that don't match
    12981307                                        //
    12991308                                        if( $n < 2 )
    13001309                                        {
    1301                                                 //printf( "removing node %s - x present & y present + <2 x,y matches\n", $hostname );
     1310                                                // This node hostname has no match for: {x} and {y}
     1311                                                //
    13021312                                                unset( $nodes[$hostname] );
    13031313                                        }
     
    13061316                                {
    13071317                                        $n = sscanf( $hostname, $skan_str, $x );
     1318
    13081319                                        // Remove nodes that don't match
    13091320                                        //
    13101321                                        if( $n < 1 )
    13111322                                        {
    1312                                                 //printf( "removing node %s - x present & !y present + <1 x match\n", $hostname );
     1323                                                // This node hostname has no match for: {x}
     1324                                                //
    13131325                                                unset( $nodes[$hostname] );
    13141326                                        }
     
    13181330                                {
    13191331                                        $n = sscanf( $hostname, $skan_str, $y );
     1332
    13201333                                        // Remove nodes that don't match
    13211334                                        //
    13221335                                        if( $n < 1 )
    13231336                                        {
    1324                                                 //printf( "removing node %s - y present & !x present + <1 y match\n", $hostname );
     1337                                                // This node hostname has no match for: {y}
     1338                                                //
    13251339                                                unset( $nodes[$hostname] );
    13261340                                        }
    13271341                                        $x      = 1;
    13281342                                }
    1329                                 //printf( "xfirst %s yfirst %s\n", $x_first, $y_first );
    1330 
    1331                                 //printf( "n %s\n", $n );
    1332 
    1333 
    1334                                 //printf( "node %s x_min %s x %s\n", $hostname, $x_min, $x );
    1335 
     1343
     1344                                // Determine the lowest value of {x} that exists in all node hostnames
     1345                                //
    13361346                                if( !$x_min && $x != null )
    13371347                                {
     
    13421352                                        $x_min  = $x;
    13431353                                }
     1354
     1355                                // Determine the highest value of {x} that exists in all node hostnames
     1356                                //
    13441357                                if( !$x_max && $x != null )
    13451358                                {
     
    13501363                                        $x_max  = $x;
    13511364                                }
     1365
     1366                                // Determine the lowest value of {y} that exists in all node hostnames
     1367                                //
    13521368                                if( !$y_min && $y != null )
    13531369                                {
     
    13581374                                        $y_min  = $y;
    13591375                                }
     1376
     1377                                // Determine the highest value of {y} that exists in all node hostnames
     1378                                //
    13601379                                if( !$y_max && $y != null )
    13611380                                {
     
    13681387                        }
    13691388
    1370                         //printf( "ss %s\n", $skan_str);
     1389                        // Sort all the nodes (alpha and numerically)
     1390                        // 1: gb-r1n1, 2: gb-r1n2, 3: gb-r2n1, etc
     1391                        //
    13711392                        $sorted_nodes   = usort( $nodes, "cmp" );
    1372 
    1373                         //print_r( $nodes );
    13741393
    13751394                        $cur_node       = 0;
     
    14271446                        if( $this->isSmall() ) {
    14281447
     1448                                // Draw a fancy little header text to explain what it is
     1449                                //
    14291450                                $colorblue      = imageColorAllocate( $image, 0, 0, 255 );
    14301451
     
    14381459                                if( isset( $SORT_XLABEL ) )
    14391460                                {
     1461                                        // Print the {x} label: rack
     1462                                        //
    14401463                                        imageString( $image, $font, $x_offset, $fontspaceing, $SORT_XLABEL, $colorblue );
    14411464                                }
     
    14431466                                if( isset( $SORT_YLABEL ) )
    14441467                                {
    1445                                         // Stupid php without imageStringDown function
     1468                                        // Stupid php without imageStringDown function... we'll make one ourself
     1469                                        //
     1470
     1471                                        // Print the {y} label: node
    14461472                                        //
    14471473                                        imageStringDown( $image, $font, $fontspaceing, $y_offset, $SORT_YLABEL, $colorblue );
    14481474                                }
    14491475                        }
    1450                         //print_r( $nodes );
    14511476
    14521477                        for( $n = $x_min; $n <= $x_max; $n++ )
     
    14541479                                for( $m = $y_min; $m <= $y_max; $m++ )
    14551480                                {
     1481
    14561482                                        if( $x_min > 0 )
    14571483                                        {
     
    14611487                                        {
    14621488                                                $y      = $y_offset + ( ($m-$y_min) * $node_width );
     1489                                        }
     1490
     1491                                        if( $this->isBig() )
     1492                                        {
     1493                                                // Draw y(node) column number header
     1494                                                //
     1495                                                if(( $n == $x_min ) && ( isset($SORT_YLABEL) ) )
     1496                                                {
     1497                                                        $mfontspacing   = 1;
     1498
     1499                                                        $ylabel_x       = $x - ( $fontwidth * strlen( $y_max ) ) - $mfontspacing;
     1500                                                        $ylabel_y       = $y;
     1501
     1502                                                        imageString( $image, $font, $ylabel_x, $ylabel_y, strval( $m ), $colorblue );
     1503
     1504                                                        $xmin_hit[$n]   = true;
     1505                                                }
     1506
     1507                                                // Draw x(rack) column number header
     1508                                                //
     1509                                                if(( $m == $y_min ) && ( isset($SORT_XLABEL) ) )
     1510                                                {
     1511                                                        $mfontspacing   = 2;
     1512                                                        $xlabel_y       = $y - ( $fontheight * strlen( $x_max ) );
     1513                                                        $xlabel_x       = $x + $mfontspacing;
     1514
     1515                                                        imageStringDown( $image, $font, $xlabel_x, $xlabel_y, strval( $n ), $colorblue );
     1516                                                }
    14631517                                        }
    14641518
     
    14841538                                                        if( intval( $rx ) > $n )
    14851539                                                        {
    1486                                                                 $m      = $y_max + 1;
    1487                                                                 //printf( "skipping node %s - y present & x present + rx %s > n %s\n", $rx, $n);
     1540                                                                // If x(rack) is higher than current x, skip to next x(rack)
     1541                                                                //
     1542                                                                $m              = $y_max + 1;
     1543
    14881544                                                                continue;
    14891545                                                        }
    14901546                                                        if( intval( $ry ) > $m )
    14911547                                                        {
    1492                                                                 //printf( "skipping node %s - y present & x present + ry %s > m %s\n", $ry, $m);
     1548                                                                // If y(node) is higher than current y, skip to next y(node)
     1549                                                                //
    14931550                                                                continue;
    14941551                                                        }
     
    15051562                                                if( !in_array( $host, $filtered_nodes ) )
    15061563                                                {
    1507                                                         //printf( "setting node %s showinfo to 0 - not found in filtered_nodes", $host);
     1564                                                        // This node has been filtered out: we only want to see certain nodes
     1565                                                        //
    15081566                                                        $nodes[$cur_node]->setShowinfo( 0 );
    15091567                                                }
     
    15211579                                                $cur_node++;
    15221580                                        }
    1523                                         if( $this->isBig() )
    1524                                         {
    1525                                                 if(( $n == $x_min ) && ( isset($SORT_YLABEL) ) )
    1526                                                 {
    1527                                                         $mfontspacing   = 1;
    1528                                                         $ylabel_x       = $x - ( $fontwidth * strlen( $y_max ) ) - $mfontspacing;
    1529                                                         $ylabel_y       = $y;
    1530 
    1531                                                         imageString( $image, $font, $ylabel_x, $ylabel_y, strval( $m ), $colorblue );
    1532                                                 }
    1533                                                 if(( $m == $y_min ) && ( isset($SORT_XLABEL) ) )
    1534                                                 {
    1535                                                         $mfontspacing   = 2;
    1536                                                         $xlabel_y       = $y - ( $fontheight * strlen( $x_max ) );
    1537                                                         $xlabel_x       = $x + $mfontspacing;
    1538 
    1539                                                         imageStringDown( $image, $font, $xlabel_x, $xlabel_y, strval( $n ), $colorblue );
    1540                                                 }
    1541                                         }
    1542 
    15431581                                }
    15441582                        }
  • trunk/web/addons/job_monarch/overview.php

    r462 r463  
    4444$gnodes         = $data_gatherer->getNodes();
    4545$cpus           = $data_gatherer->getCpus();
     46$use_fqdn       = $data_gatherer->getUsingFQDN();
    4647
    4748function setupFilterSettings()
     
    507508        global $start, $end, $reports, $gnodes, $default_showhosts;
    508509        global $COLUMN_QUEUED, $COLUMN_REQUESTED_MEMORY, $COLUMN_NODES, $hostname;
    509         global $cluster;
     510        global $cluster, $use_fqdn;
    510511
    511512        $metricname             = $m;
     
    552553        $view_name_nodes        = array();
    553554
     555        // Is the "requested memory" column enabled in the config
     556        //
    554557        if( $COLUMN_REQUESTED_MEMORY )
    555558        {
     
    557560        }
    558561
     562        // Is the "nodes hostnames" column enabled in the config
     563        //
    559564        if( $COLUMN_NODES )
    560565        {
     
    562567        }
    563568
     569        // Is the "queued time" column enabled in the config
     570        //
    564571        if( $COLUMN_QUEUED )
    565572        {
     
    582589        }
    583590
     591        // Running / queued amount jobs graph
     592        //
    584593        if( $rjqj_host != null )
    585594        {
     
    641650                                                $hostnode       = $tempnode;
    642651
    643                                                 //if( substr( $hostnode, $domain_len ) != $jobs[$jobid][domain] )
    644                                                 //{
    645                                                 //      $hostnode = $hostnode. '.'. $jobs[$jobid][domain];
    646                                                 //}
     652                                                if( $use_fqdn == 1)
     653                                                {
     654                                                        if( substr( $hostnode, $domain_len ) != $jobs[$jobid][domain] )
     655                                                        {
     656                                                                $hostnode = $hostnode. '.'. $jobs[$jobid][domain];
     657                                                        }
     658                                                }
    647659
    648660                                                if( $hostname == $hostnode )
     
    804816                                                foreach( $jobs[$jobid][nodes] as $mynode )
    805817                                                {
    806                                                         //$myhost_href  = "./?c=".$clustername."&h=".$mynode.".".$jobs[$jobid][domain];
     818                                                        if( $use_fqdn == 1)
     819                                                        {
     820                                                                $mynode = $mynode.".".$jobs[$jobid][domain];
     821                                                        }
    807822                                                        $myhost_href    = "./?c=".$clustername."&h=".$mynode;
    808823                                                        $mynodehosts[]  = "<A HREF=\"".$myhost_href."\">".$mynode."</A>";
     
    978993                        foreach ( $hosts_up as $host )
    979994                        {
    980                                 //$domain_len           = 0 - strlen( $domain );
    981 
    982                                 //if( substr( $host, $domain_len ) != $domain )
    983                                 //{
    984                                 //      $host           = $host . '.' . $domain;
    985                                 //}
     995                                $domain_len             = 0 - strlen( $domain );
     996
     997                                if( $use_fqdn )
     998                                {
     999                                        if( substr( $host, $domain_len ) != $domain )
     1000                                        {
     1001                                                $host           = $host . '.' . $domain;
     1002                                        }
     1003                                }
    9861004
    9871005                                $cpus                   = $metrics[$host]["cpu_num"]["VAL"];
     
    10071025                                }
    10081026                        }
     1027
    10091028                        switch ( $sort )
    10101029                        {
  • trunk/web/addons/job_monarch/version.php

    r417 r463  
    2222 */
    2323
    24 $monarchversion = "0.2.1";
     24$monarchversion = "0.3SVN";
    2525?>
Note: See TracChangeset for help on using the changeset viewer.