Changeset 135 for trunk/web/addons/toga/libtoga.php
- Timestamp:
- 06/13/05 11:31:02 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/libtoga.php
r130 r135 134 134 135 135 $output = explode( "\n", $output ); 136 print_r( $output );136 //print_r( $output ); 137 137 return $output; 138 138 } … … 207 207 } 208 208 209 function makeJobRrd s( $clustername, $hostname, $descr, $start, $end) {209 function makeJobRrd( $clustername, $hostname, $metric, $descr, $start, $end) { 210 210 $this->clustername = $clustername; 211 211 $this->hostname = $hostname; … … 219 219 $time_size = count( $times ); 220 220 $curtime = 1; 221 $this->metrics = $this->dirList( $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname .'/'. $times[0] );222 221 //print_r( $this->metrics ); 223 222 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; 245 261 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; 281 301 } 282 302 … … 311 331 else 312 332 $keepval = 0; 313 } else if( $ stop) {314 315 if( intval($timestamp) <= intval($ stop) )333 } else if( $end ) { 334 335 if( intval($timestamp) <= intval($end) ) 316 336 $keepval = 1; 317 337 else … … 322 342 //printf("timestamp = %s, value = %s\n", $timestamp, $value ); 323 343 324 if( $keepval )344 if( $keepval and !isset($arvalues[$timestamp] ) ) 325 345 $arvalues[$timestamp] = $value; 326 346 } … … 330 350 //printf( "----arvalues----\n" ); 331 351 332 ksort( $arvalues );352 //ksort( $arvalues ); 333 353 //printf( "----arsortvalues----\n" ); 334 354 //print_r( $arvalues); … … 521 541 if( $toganame == 'nodes' ) { 522 542 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 531 559 } else { 532 560
Note: See TracChangeset
for help on using the changeset viewer.