- Timestamp:
- 06/13/05 11:31:02 (18 years ago)
- Location:
- trunk/web/addons/toga
- Files:
-
- 3 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 -
trunk/web/addons/toga/overview.php
r129 r135 358 358 $req_cpu = $jobattrs[requested_time]; 359 359 $req_memory = $jobattrs[requested_memory]; 360 $nodes = count( $jobattrs[nodes] ); 360 361 if( $state == 'R' ) 362 $nodes = count( $jobattrs[nodes] ); 363 else 364 $nodes = $jobattrs[nodes]; 365 361 366 $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1; 362 367 $cpus = $nodes * $ppn; … … 440 445 $even = 1; 441 446 442 $overview_jobs = count( $sorted_jobs ); 443 $overview_nodes = count( $gnodes ); 444 $overview_cpus = 0; 445 446 $f_cpus = 0; 447 $f_jobs = 0; 447 $used_jobs = 0; 448 $used_cpus = 0; 449 $used_nodes = 0; 450 451 $all_used_nodes = array(); 452 453 $avail_nodes = count( $gnodes ); 454 $avail_cpus = cluster_sum("cpu_num", $metrics); 455 456 $view_cpus = 0; 457 $view_jobs = 0; 458 $view_nodes = 0; 459 460 $view_used_nodes = array(); 448 461 449 462 foreach( $sorted_jobs as $jobid => $sortdec ) { … … 455 468 $cpus = $nodes * $ppn; 456 469 457 $overview_cpus = $overview_cpus + $cpus; 470 foreach( $jobs[$jobid][nodes] as $tempnode ) 471 $all_used_nodes[] = $tempnode; 472 473 if( $jobs[$jobid][status] == 'R' ) { 474 $used_cpus += $cpus; 475 $used_jobs++; 476 } 458 477 459 478 if( $report_time == $heartbeat ) { … … 474 493 475 494 if( $display_job ) { 476 477 495 478 496 $tpl->newBlock("node"); … … 486 504 $tpl->assign("req_cpu", makeTime( timeToEpoch( $jobs[$jobid][requested_time] ) ) ); 487 505 $tpl->assign("req_memory", $jobs[$jobid][requested_memory] ); 488 $nodes = count( $jobs[$jobid][nodes] ); 506 507 if( $jobs[$jobid][status] == 'R' ) 508 $nodes = count( $jobs[$jobid][nodes] ); 509 else if( $jobs[$jobid][status] == 'Q' ) 510 $nodes = $jobs[$jobid][nodes]; 511 489 512 $ppn = (int) $jobs[$jobid][ppn] ? $jobs[$jobid][ppn] : 1; 490 513 $cpus = $nodes * $ppn; … … 494 517 $job_start = $start_time; 495 518 496 $f_cpus = $f_cpus + $cpus; 497 $f_jobs++; 519 $view_cpus += $cpus; 520 $view_jobs++; 521 522 if( $jobs[$jobid][status] == 'R' ) 523 foreach( $jobs[$jobid][nodes] as $tempnode ) 524 $view_used_nodes[] = $tempnode; 525 else if( $jobs[$jobid][status] == 'Q' ) 526 $view_nodes += $jobs[$jobid][nodes]; 498 527 499 528 if( $even ) { … … 517 546 } 518 547 } 519 520 $tpl->assignGlobal("cpus_nr", $overview_cpus ); 521 $tpl->assignGlobal("jobs_nr", $overview_jobs ); 522 $tpl->assignGlobal("nodes_nr", $overview_nodes ); 548 array_unique( $all_used_nodes ); 549 array_unique( $view_used_nodes ); 550 $used_nodes = count( $all_used_nodes ); 551 $view_nodes += count( $view_used_nodes ); 552 553 //$tpl->assignGlobal("cpus_nr", $overview_cpus ); 554 //$tpl->assignGlobal("jobs_nr", $overview_jobs ); 555 556 $tpl->assignGlobal("avail_nodes", $avail_nodes ); 557 $tpl->assignGlobal("avail_cpus", $avail_cpus ); 558 559 $tpl->assignGlobal("used_nodes", $used_nodes ); 560 $tpl->assignGlobal("used_jobs", $used_jobs ); 561 $tpl->assignGlobal("used_cpus", $used_cpus ); 562 563 $tpl->assignGlobal("view_nodes", $view_nodes ); 564 $tpl->assignGlobal("view_jobs", $view_jobs ); 565 $tpl->assignGlobal("view_cpus", $view_cpus ); 566 523 567 $tpl->assignGlobal("report_time", makeDate( $heartbeat)); 524 568 525 $tpl->assignGlobal("f_cpus_nr", $f_cpus );526 $tpl->assignGlobal("f_jobs_nr", $f_jobs );569 //$tpl->assignGlobal("f_cpus_nr", $f_cpus ); 570 //$tpl->assignGlobal("f_jobs_nr", $f_jobs ); 527 571 528 572 if( array_key_exists( "id", $filter ) and $start_time ) { -
trunk/web/addons/toga/templates/overview.tpl
r126 r135 6 6 <TD ALIGN="CENTER"> 7 7 <IMG SRC="{clusterimage}"><BR> 8 {nodes_nr} nodes total: {jobs_nr} jobs with {cpus_nr} CPU's (at {report_time}).<BR> 9 current view: {f_jobs_nr} jobs with {f_cpus_nr} CPU's{lag_msg}. 8 9 <TABLE ALIGN=CENTER> 10 <TR> 11 <TD><FONT SIZE="-1" class=footer>Last updated:</FONT></TD><TD><FONT SIZE="-1" class=footer>{report_time}</TD> 12 </TR><TR> 13 <TD><FONT SIZE="-1" class=footer>Available:</FONT></TD><TD><FONT SIZE="-1" class=footer>{avail_nodes} nodes / {avail_cpus} cpu's</FONT></TD> 14 </TR><TR> 15 <TD><FONT SIZE="-1" class=footer>Usage:</FONT></TD><TD><FONT SIZE="-1" class=footer>{used_jobs} jobs - {used_nodes} nodes / {used_cpus} cpu's</FONT></TD> 16 </TR><TR> 17 <TD><FONT SIZE="-1" class=footer>View:</FONT></TD><TD><FONT SIZE="-1" class=footer>{view_jobs} jobs - {view_nodes} nodes / {view_cpus} cpu's</FONT></TD> 18 </TR> 19 </TABLE> 20 </FONT> 21 10 22 </TD> 11 23 <TD ALIGN="CENTER"> … … 15 27 </TABLE> 16 28 17 <BR> <BR>29 <BR> 18 30 19 31 <SCRIPT TYPE="text/javascript" SRC="ts_picker.js"></SCRIPT>
Note: See TracChangeset
for help on using the changeset viewer.