Ignore:
Timestamp:
06/13/05 11:31:02 (19 years ago)
Author:
bastiaans
Message:

toga/templates/overview.tpl:

  • Now readable job/node/cpu counting info

toga/overview.php:

  • Now correctly counts for with new queued job cpu/node numbers

toga/libtoga.php:

  • Changed node parsing from XML for new queued job cpu/node numbers
  • Misc RRD generation testing changes
File:
1 edited

Legend:

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

    r130 r135  
    134134
    135135                $output = explode( "\n", $output );
    136                 print_r( $output );
     136                //print_r( $output );
    137137                return $output;
    138138        }
     
    207207        }
    208208
    209         function makeJobRrds( $clustername, $hostname, $descr, $start, $end) {
     209        function makeJobRrd( $clustername, $hostname, $metric, $descr, $start, $end) {
    210210                $this->clustername = $clustername;
    211211                $this->hostname = $hostname;
     
    219219                        $time_size = count( $times );
    220220                        $curtime = 1;
    221                         $this->metrics = $this->dirList( $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $times[0] );
    222221                        //print_r( $this->metrics );
    223222
    224                         $intv = $this->getIntervalStep( '"'.$this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $times[0]. '/'.$this->metrics[0].'"' );
    225                         foreach( $this->metrics as $metric ) { 
    226                                 $newfile = $this->tempdir .'/toga.temp-'. $descr .'-'.$metric;
    227 
    228                                 foreach( $times as $timep ) {
    229 
    230                                         $r_start = null;
    231                                         $r_end = null;
    232 
    233                                         if( $curtime == 1 )
    234                                                 $r_start = $start;
    235 
    236                                         if( $curtime == $time_size )
    237                                                 $r_end = $end;
    238 
    239                                         $file = $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $timep .'/'. $metric;
    240 
    241                                         $r_values = $this->getValues( $file, $r_start, $r_end );
    242                                         //print_r($r_values);
    243 
    244                                         $myvalues = $myvalues + $r_values;
     223                        $firstold = $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $times[0]. '/'.$metric;
     224
     225                        if( !file_exists( $firstold ) )
     226                                return 0;
     227
     228                        $hostdir = $this->tempdir .'/'. $hostname;             
     229                        $newdir = $hostdir .'/'.$descr;
     230                        $newfile = $newdir .'/'.$metric;
     231
     232                        //if( file_exists( $newfile ) )
     233                        //      return 0;
     234
     235                        if( !file_exists( $hostdir ) )
     236                                mkdir( $hostdir );
     237
     238                        if( !file_exists( $newdir ) )
     239                                mkdir( $newdir );
     240
     241                        //$this->metrics = $this->dirList( $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $times[0] );
     242                        $intv = $this->getIntervalStep( '"'.$firstold.'"' );
     243
     244                        foreach( $times as $timep ) {
     245
     246                                $r_start = null;
     247                                $r_end = null;
     248
     249                                if( $curtime == 1 )
     250                                        $r_start = $start;
     251
     252                                if( $curtime == $time_size )
     253                                        $r_end = $end;
     254
     255                                $file = $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $timep .'/'. $metric;
     256
     257                                $r_values = $this->getValues( $file, $r_start, $r_end );
     258                                //print_r($r_values);
     259
     260                                $myvalues = $myvalues + $r_values;
    245261                               
    246                                         $curtime++;     
    247                                 }
    248                                 //printf( "----myvalues----\n" );
    249                                 //print_r($myvalues);
    250                                 //printf( "----myvalues----\n" );
    251 
    252                                 $heartbeat = intval( 8 * $intv );
    253                                 $ret = $this->doCmd( $this->rrdbin .' create "'.$newfile.'" --step '. $intv .' --start '. $start .' DS:sum:GAUGE:'.$heartbeat.':U:U RRA:AVERAGE:0.5:1:'. count( $myvalues ) );
    254 
    255                                 $update_args = array();
    256                                 $arglist_nr = 0;
    257 
    258                                 ksort( $myvalues );
    259 
    260                                 foreach( $myvalues as $mytime=>$myvalue ) {
    261                                         $myupdateval = ' '.trim($mytime).':'.trim($myvalue);
    262 
    263                                         if( !isset($update_args[$arglist_nr]) )
    264                                                 $update_args[$arglist_nr] = '';
    265 
    266                                         if( intval( strlen($update_args[$arglist_nr]) + strlen($myupdateval) ) > 50000 )
    267                                                 $arglist_nr++;
    268 
    269                                         $update_args[$arglist_nr] .= $myupdateval;
    270                                 }
    271 
    272                                 //printf( "grootte args = %s\n", strlen( $update_args ) );
    273 
    274                                 $ret = $this->doCmd( $this->rrdbin .' update "'. $newfile . '" blaaa' );
    275                                 foreach( $update_args as $update_arg )
    276                                         $ret = $this->doCmd( $this->rrdbin .' update "'. $newfile . '"'.$update_arg );
    277 
    278                                 return;
    279                         }
    280                 }
     262                                $curtime++;     
     263                        }
     264                        //printf( "----myvalues----\n" );
     265                        //print_r($myvalues);
     266                        //printf( "----myvalues----\n" );
     267
     268                        $heartbeat = intval( 8 * $intv );
     269                        $ret = $this->doCmd( $this->rrdbin .' create "'.$newfile.'" --step '. $intv .' --start '. $start .' DS:sum:GAUGE:'.$heartbeat.':U:U RRA:AVERAGE:0.5:1:'. count( $myvalues ) );
     270
     271                        $update_args = array();
     272                        $arglist_nr = 0;
     273
     274                        ksort( $myvalues );
     275                        reset( $myvalues );
     276                        $myvalues = array_unique( $myvalues );
     277                        reset( $myvalues );
     278
     279                        foreach( $myvalues as $mytime=>$myvalue ) {
     280                                $myupdateval = ' '.trim($mytime).':'.trim($myvalue);
     281
     282                                if( !isset($update_args[$arglist_nr]) )
     283                                        $update_args[$arglist_nr] = '';
     284
     285                                // Max_Args for Linux kernel is normally about 130k
     286                                //
     287                                if( intval( strlen($update_args[$arglist_nr]) + strlen($myupdateval) ) > 100000 )
     288                                        $arglist_nr++;
     289
     290                                $update_args[$arglist_nr] .= $myupdateval;
     291                        }
     292
     293                        //printf( "grootte args = %s\n", strlen( $update_args ) );
     294
     295                        foreach( $update_args as $update_arg )
     296                                $ret = $this->doCmd( $this->rrdbin .' update "'. $newfile . '"'.$update_arg );
     297
     298                        printf( "generated %s\n", $newfile );
     299                } else
     300                        return 0;
    281301        }
    282302
     
    311331                                        else
    312332                                                $keepval = 0;
    313                                 } else if( $stop ) {
    314 
    315                                         if( intval($timestamp) <= intval($stop) )
     333                                } else if( $end ) {
     334
     335                                        if( intval($timestamp) <= intval($end) )
    316336                                                $keepval = 1;
    317337                                        else
     
    322342                                //printf("timestamp = %s, value = %s\n", $timestamp, $value );
    323343
    324                                 if( $keepval )
     344                                if( $keepval and !isset($arvalues[$timestamp] ) )
    325345                                        $arvalues[$timestamp] = $value;
    326346                        }
     
    330350                //printf( "----arvalues----\n" );
    331351
    332                 ksort( $arvalues );
     352                //ksort( $arvalues );
    333353                //printf( "----arsortvalues----\n" );
    334354                //print_r( $arvalues);
     
    521541                                        if( $toganame == 'nodes' ) {
    522542
    523                                                 if( !isset( $jobs[$jobid][$toganame] ) )
    524                                                         $jobs[$jobid][$toganame] = array();
    525 
    526                                                 $mynodes = explode( ';', $togavalue );
    527 
    528                                                 foreach( $mynodes as $node )
    529 
    530                                                         $jobs[$jobid][$toganame][] = $node;
     543                                                if( $jobs[$jobid][status] == 'R' ) {
     544                                               
     545                                                        if( !isset( $jobs[$jobid][$toganame] ) )
     546                                                                $jobs[$jobid][$toganame] = array();
     547
     548                                                        $mynodes = explode( ';', $togavalue );
     549
     550                                                        foreach( $mynodes as $node )
     551
     552                                                                $jobs[$jobid][$toganame][] = $node;
     553
     554                                                } else if( $jobs[$jobid][status] == 'Q' ) {
     555
     556                                                        $jobs[$jobid][$toganame] = $togavalue;
     557                                                }
     558                                               
    531559                                        } else {
    532560
Note: See TracChangeset for help on using the changeset viewer.