Changeset 122 for trunk/web/addons/toga/libtoga.php
- Timestamp:
- 06/01/05 16:55:14 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/libtoga.php
r117 r122 334 334 class NodeImage { 335 335 336 var $image, $x, $y, $hostname, $jobs, $tasks ;336 var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo; 337 337 338 338 function NodeImage( $hostname ) { … … 345 345 $this->hostname = $hostname; 346 346 $this->cpus = $this->determineCpus(); 347 $this->showinfo = 1; 347 348 } 348 349 … … 400 401 } 401 402 403 function getHostname() { 404 return $this->hostname; 405 } 406 402 407 function getJobs() { 403 408 return $this->jobs; 404 409 } 405 410 411 function setShowinfo( $showinfo ) { 412 $this->showinfo = $showinfo; 413 } 414 406 415 function draw() { 407 416 408 global $SMALL_CLUSTERIMAGE_NODEWIDTH, $JOB_NODE_MARKING_ALLCPUS, $JOB_NODE_MARKING_SINGLECPU; 417 $this->drawSmall(); 418 } 419 420 function drawBig() { 421 422 } 423 424 function drawSmall() { 425 426 global $SMALL_CLUSTERIMAGE_NODEWIDTH; 409 427 global $JOB_NODE_MARKING; 410 428 411 $this->load = $this->determineLoad();412 413 if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) {414 printf( "aborting\n" );415 printf( "x %d y %d load %f\n", $this->x, $this->y, $load );416 return;417 }418 419 429 $black_color = imageColorAllocate( $this->image, 0, 0, 0 ); 420 421 // Convert Ganglias Hexadecimal load color to a Decimal one422 //423 $load = $this->determineLoad();424 $my_loadcolor = $this->colorHex( load_color($load) );425 426 430 $size = $SMALL_CLUSTERIMAGE_NODEWIDTH; 427 431 428 432 imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color ); 429 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $my_loadcolor ); 430 431 $nr_jobs = count( $this->jobs ); 432 433 $node_mark = null; 434 435 if( count( $this->jobs ) > 0 ) 436 $node_mark = $JOB_NODE_MARKING; 437 438 // if( $this->tasks < $this->cpus ) 439 // $node_mark = $JOB_NODE_MARKING_SINGLECPU; 440 441 // else if( $this->tasks == $this->cpus ) 442 // $node_mark = $JOB_NODE_MARKING_ALLCPUS; 443 444 if( $node_mark ) 445 imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $node_mark, $black_color ); 433 434 if( $this->showinfo) { 435 436 $this->load = $this->determineLoad(); 437 438 if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) { 439 printf( "aborting\n" ); 440 printf( "x %d y %d load %f\n", $this->x, $this->y, $load ); 441 return; 442 } 443 444 445 // Convert Ganglias Hexadecimal load color to a Decimal one 446 // 447 $load = $this->determineLoad(); 448 $usecolor = $this->colorHex( load_color($load) ); 449 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); 450 if( count( $this->jobs ) > 0 ) 451 imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $JOB_NODE_MARKING, $black_color ); 452 453 } else { 454 455 // White 456 $usecolor = imageColorAllocate( $this->image, 255, 255, 255 ); 457 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); 458 } 459 460 446 461 } 447 462 … … 470 485 471 486 var $dataget, $image, $clustername; 472 473 function ClusterImage( $clustername, $data_gather ) { 474 475 if( !isset( $data_gather ) ) 476 $this->dataget = new DataGatherer(); 477 else 478 $this->dataget = $data_gather; 479 487 var $filtername, $filtervalue; 488 489 function ClusterImage( $clustername ) { 490 491 $this->dataget = new DataGatherer(); 480 492 $this->clustername = $clustername; 493 $this->filtername = null; 494 $this->filtervalue = null; 495 } 496 497 function setFilter( $filtername, $filtervalue ) { 498 499 //printf( "filter set to %s = %s\n", $filtername, $filtervalue ); 500 $this->filtername = $filtername; 501 $this->filtervalue = $filtervalue; 502 } 503 504 function filterNodes( $jobs, $nodes ) { 505 506 $filtered_nodes = array(); 507 508 foreach( $nodes as $node ) { 509 510 $mynjobs = $node->getJobs(); 511 $hostname = $node->getHostname(); 512 513 if( $this->filtername ) { 514 foreach( $mynjobs as $myjob ) 515 516 if( $this->filtername == 'jobid' && $node->hasJob( $this->filtervalue) ) 517 $filtered_nodes[] = $hostname; 518 else if( $jobs[$myjob][$this->filtername] == $this->filtervalue && !in_array( $hostname, $filtered_nodes ) ) 519 $filtered_nodes[] = $hostname; 520 } else 521 $filtered_nodes[] = $hostname; 522 } 523 524 return $filtered_nodes; 481 525 } 482 526 … … 526 570 imageFill( $image, 0, 0, $colorwhite ); 527 571 572 $jobs = $mydatag->getJobs(); 573 //printf("filtername = %s\n", $filtername ); 574 $filtered_nodes = $this->filterNodes( $jobs, $nodes ); 575 576 //print_r($filtered_nodes); 577 528 578 for( $n = 0; $n < $node_rows; $n++ ) { 529 579 … … 536 586 $host = $nodes_hosts[$cur_node]; 537 587 588 538 589 if( isset( $nodes[$host] ) ) { 539 590 540 591 $nodes[$host]->setCoords( $x, $y ); 541 592 $nodes[$host]->setImage( $image ); 593 594 if( !in_array( $host, $filtered_nodes ) ) 595 $nodes[$host]->setShowinfo( 0 ); 596 542 597 $nodes[$host]->draw(); 543 598 }
Note: See TracChangeset
for help on using the changeset viewer.