- Timestamp:
- 05/24/05 11:26:41 (18 years ago)
- Location:
- trunk/web/addons/toga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/conf.php
r110 r111 14 14 $SMALL_CLUSTERIMAGE_NODEWIDTH = 11; 15 15 16 // How to mark nodes with a job in clusterimage 17 // allcpus when all cpu's are in use 18 // singlecpu when less than all cpus are in use 19 // 20 $JOB_NODE_MARKING_ALLCPUS = "J"; 21 $JOB_NODE_MARKING_SINGLECPU = "j"; 22 16 23 // XML Datasource for Toga 17 24 // by default localhost's gmetad -
trunk/web/addons/toga/image.php
r110 r111 6 6 7 7 $view = $httpvars->getHttpVar( "view" ); 8 $clustername = $httpvars->getClusterName(); 8 9 9 10 function drawSmallClusterImage() { 10 11 11 $ic = new ClusterImage( );12 $ic = new ClusterImage( $clustername ); 12 13 $ic->draw(); 13 14 } -
trunk/web/addons/toga/libtoga.php
r110 r111 187 187 188 188 $jobs = &$this->jobs; 189 $nodes = &$this->nodes; 189 190 190 191 if ( $attrs[TN] ) { … … 211 212 $location = $attrs[LOCATION]; 212 213 213 $this->gotNode( $hostname, $location, null ); 214 if( !isset( $this->nodes[$hostname] ) ) 215 $this->nodes[$hostname] = new NodeImage( $hostname ); 216 217 //$this->gotNode( $hostname, $location, null ); 214 218 215 219 } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'TOGA' ) ) { … … 244 248 $jobs[$jobid][$toganame] = array(); 245 249 246 $nodes = explode( ';', $togavalue ); 247 248 foreach( $nodes as $node ) { 249 250 $hostname = $node.'.'.$jobs[$jobid][domain]; 251 $jobs[$jobid][$toganame][] = $hostname; 252 $this->gotNode( $hostname, null, $jobid ); 253 //printf( "got job %s on node %s", $jobid, $hostname ); 250 $mynodes = explode( ';', $togavalue ); 251 252 foreach( $mynodes as $node ) { 253 254 //$hostname = $node.'.'.$jobs[$jobid][domain]; 255 $jobs[$jobid][$toganame][] = $node; 256 257 //if( !isset( $this->nodes[$hostname] ) ) 258 //$mynode = new NodeImage( $hostname ); 259 260 //$the_node = $this->nodes[$hostname]; 261 //$the_node->addJob( $jobid, 262 //$this->gotNode( $hostname, null, $jobid ); 263 //printf( "got node %s\n", $node ); 254 264 } 255 265 … … 258 268 $jobs[$jobid][$toganame] = $togavalue; 259 269 } 270 } 271 272 if( isset( $jobs[$jobid][domain] ) and isset( $jobs[$jobid][nodes] ) ) { 273 274 foreach( $jobs[$jobid][nodes] as $node ) { 275 276 $host = $node.'.'.$jobs[$jobid][domain]; 277 278 if( !isset( $this->nodes[$host] ) ) 279 $my_node = new NodeImage( $host ); 280 else 281 $my_node = $this->nodes[$host]; 282 283 if( !$my_node->hasJob( $jobid ) ) 284 285 if( isset( $jobs[$jobid][ppn] ) ) 286 $my_node->addJob( $jobid, ((int) $jobs[$jobid][ppn]) ); 287 else 288 $my_node->addJob( $jobid, 1 ); 289 290 $this->nodes[$host] = $my_node; 291 } 292 } else { 293 294 printf( "no domain or nodes set for %s\n", $jobid ); 260 295 } 261 296 } … … 332 367 } 333 368 369 334 370 function setLocation( $location ) { 335 371 $this->location = $location; … … 361 397 } 362 398 363 function setCoords( $x, $y ) {364 $myimg = $this->img;365 $myimg->setCoords( $x, $y );366 }399 //function setCoords( $x, $y ) { 400 //$myimg = $this->img; 401 //$myimg->setCoords( $x, $y ); 402 //} 367 403 368 404 function setImage( $image ) { … … 388 424 class NodeImage { 389 425 390 var $image, $x, $y, $hostname, $jobs; 391 392 function NodeImage( $image, $x, $y, $hostname, $multiproc_job ) { 426 var $image, $x, $y, $hostname, $jobs, $tasks; 427 428 function NodeImage( $hostname ) { 429 430 $this->jobs = array(); 431 //$this->image = $image; 432 //$this->x = $x; 433 //$this->y = $y; 434 $this->tasks = 0; 435 $this->hostname = $hostname; 436 $this->cpus = $this->determineCpus(); 437 } 438 439 function addJob( $jobid, $cpus ) { 440 $jobs = &$this->jobs; 441 442 $jobs[] = $jobid; 443 $this->jobs = $jobs; 444 445 $this->addTask( $cpus ); 446 } 447 448 function hasJob( $jobid ) { 449 450 $jobfound = 0; 451 452 if( count( $this->jobs ) > 0 ) 453 foreach( $this->jobs as $job ) 454 455 if( $job == $jobid ) 456 $jobfound = 1; 457 458 return $jobfound; 459 } 460 461 function addTask( $cpus ) { 462 463 $this->tasks = $this->tasks + $cpus; 464 } 465 466 function setImage( $image ) { 393 467 394 468 $this->image = $image; 395 $this->x = $x;396 $this->y = $y;397 $this->hostname = $hostname;398 $this->multiproc_job = $multiproc_job;399 469 } 400 470 … … 412 482 } 413 483 414 function setImage( $image ) {415 $this->image = $image;416 }417 418 484 function setLoad( $load ) { 419 485 $this->load = $load; … … 424 490 } 425 491 426 function drawNode( $load ) { 427 428 global $SMALL_CLUSTERIMAGE_NODEWIDTH; 429 430 if( !isset( $this->x ) or !isset( $this->y ) or !isset( $load ) ) { 492 function draw() { 493 494 global $SMALL_CLUSTERIMAGE_NODEWIDTH, $JOB_NODE_MARKING_ALLCPUS, $JOB_NODE_MARKING_SINGLECPU; 495 496 $this->load = $this->determineLoad(); 497 498 if( !isset( $this->x ) or !isset( $this->y ) or !isset( $this->load ) ) { 431 499 printf( "aborting\n" ); 432 500 printf( "x %d y %d load %f\n", $this->x, $this->y, $load ); … … 434 502 } 435 503 436 $black_color = imageColorAllocate( &$this->image, 0, 0, 0 );504 $black_color = imageColorAllocate( $this->image, 0, 0, 0 ); 437 505 438 506 // Convert Ganglias Hexadecimal load color to a Decimal one 507 // 508 $load = $this->determineLoad(); 439 509 $my_loadcolor = $this->colorHex( load_color($load) ); 440 510 … … 443 513 imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color ); 444 514 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor ); 445 if( $this->multiproc_job == 2 ) 446 imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), "J", $black_color ); 447 else if( $this->multiproc_job == 1 ) 448 imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), "j", $black_color ); 449 450 // Een job markering? 451 //imageFilledEllipse( $this->image, ($this->x+9)/2, ($this->y+9)/2, 6, 6, $jobcolor ); 452 } 453 454 function draw() { 515 516 $nr_jobs = count( $this->jobs ); 517 518 $node_mark = null; 519 520 if( count( $this->jobs ) > 0 ) 521 522 if( $this->tasks < $this->cpus ) 523 $node_mark = $JOB_NODE_MARKING_SINGLECPU; 524 525 else if( $this->tasks == $this->cpus ) 526 $node_mark = $JOB_NODE_MARKING_ALLCPUS; 527 528 if( $node_mark ) 529 imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $node_mark, $black_color ); 530 } 531 532 function determineCpus() { 455 533 456 534 global $metrics; … … 458 536 $cpus = $metrics[$this->hostname][cpu_num][VAL]; 459 537 if (!$cpus) $cpus=1; 538 539 return $cpus; 540 } 541 542 function determineLoad() { 543 544 global $metrics; 545 460 546 $load_one = $metrics[$this->hostname][load_one][VAL]; 461 $load = ((float) $load_one)/$cpus; 462 //printf( "hostname %s cpus %s load_one %s load %f\n", $this->hostname, $cpus, $load_one, $load ); 463 464 $this->drawNode( $load ); 547 $load = ((float) $load_one)/$this->cpus; 548 549 return $load; 465 550 } 466 551 } … … 468 553 class ClusterImage { 469 554 470 var $dataget, $image ;471 472 function ClusterImage( ) {555 var $dataget, $image, $clustername; 556 557 function ClusterImage( $clustername ) { 473 558 $this->dataget = new DataGatherer(); 559 $this->clustername = $clustername; 474 560 } 475 561 … … 490 576 491 577 $nodes = $mydatag->getNodes(); 578 $nodes_hosts = array_keys( $nodes ); 492 579 493 580 $nodes_nr = count( $nodes ); 494 $node_keys = array_keys( $nodes);581 //printf( "%d nodes\n", $nodes_nr ); 495 582 496 583 $nodes_size = $nodes_nr*$node_width; … … 527 614 528 615 $cur_node = ($n * $nodes_per_row) + ($m); 529 $host = $node_keys[$cur_node]; 616 $host = $nodes_hosts[$cur_node]; 617 618 if( isset( $nodes[$host] ) ) { 619 620 $nodes[$host]->setCoords( $x, $y ); 621 $nodes[$host]->setImage( $image ); 622 $nodes[$host]->draw(); 623 } 624 530 625 531 626 //printf( "host %s curnode %s ", $host, $cur_node ); 532 627 533 if( isset( $nodes[$host] ) and ($cur_node < $nodes_nr) ) {534 //printf( "image %s\n", $host );535 $nodejobs = $nodes[$host]->getJobs();536 $jobs = $mydatag->getJobs();537 538 $multiproc_job = 0;539 540 if( count( $nodejobs ) > 0 ) {541 $multiproc_job = 1;542 543 foreach( $nodejobs as $myjob ){544 if( isset($jobs[$myjob]['ppn']) and $jobs[$myjob]['ppn'] > 1 )545 $multiproc_job = 2;546 break;547 }548 }628 // if( isset( $nodes[$host] ) and ($cur_node < $nodes_nr) ) { 629 // //printf( "image %s\n", $host ); 630 // $nodejobs = $nodes[$host]->getJobs(); 631 // $jobs = $mydatag->getJobs(); 632 633 // $multiproc_job = 0; 634 635 // if( count( $nodejobs ) > 0 ) { 636 // $multiproc_job = 1; 637 638 // foreach( $nodejobs as $myjob ){ 639 // if( isset($jobs[$myjob]['ppn']) and $jobs[$myjob]['ppn'] > 1 ) 640 // $multiproc_job = 2; 641 // break; 642 // } 643 // } 549 644 550 645 //printf( "jobs %s node %s", $nrjobs, $host ); 551 $node = new NodeImage( $image, $x, $y, $host, $multiproc_job );646 // $node = new NodeImage( $image, $x, $y, $host, $multiproc_job ); 552 647 //$node->setHostname( $host ); 553 $node->draw();648 // $node->draw(); 554 649 //$nodes[$host]->setCoords( $x, $y ); 555 650 //$nodes[$host]->setImage( &$image ); 556 651 //$nodes[$host]->draw(); 557 652 //$cur_node++; 558 }653 // } 559 654 } 560 655 } … … 570 665 //$my_data->printInfo(); 571 666 572 $ic = new ClusterImage( );667 $ic = new ClusterImage( "LISA Cluster" ); 573 668 $ic->draw(); 574 669 ?>
Note: See TracChangeset
for help on using the changeset viewer.