- Timestamp:
- 05/20/05 15:32:17 (18 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 1 deleted
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/libtoga.php
r109 r110 1 1 <?php 2 $GANGLIA_PATH = "/var/www/ganglia"; 2 //$GANGLIA_PATH = "/var/www/ganglia"; 3 4 // Toga's conf 5 // 6 include_once "./conf.php"; 7 8 global $GANGLIA_PATH, $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE; 9 10 //printf("gpath %s clmaxw %s ndmaxw %s ds %s",$GANGLIA_PATH, $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE); 3 11 4 12 include_once "$GANGLIA_PATH/conf.php"; … … 29 37 30 38 var $clustername, $metricname; 39 var $restvars; 31 40 32 41 function HTTPVariables() { 42 43 $this->restvars = array(); 33 44 34 45 global $HTTP_GET_VARS; … … 36 47 $this->clustername = $HTTP_GET_VARS["c"] ? $HTTP_GET_VARS["c"] : null; 37 48 $this->metricname = $HTTP_GET_VARS["m"] ? $HTTP_GET_VARS["m"] : null; 49 50 foreach( $HTTP_GET_VARS as $httpvar => $httpval ) { 51 52 if( $httpval ) { 53 $this->restvars[$httpvar] = $httpval; 54 } 55 } 38 56 } 39 57 … … 44 62 function getMetricName() { 45 63 return $this->metricname; 64 } 65 66 function getHttpVar( $var ) { 67 if( isset( $this->restvars[$var] ) ) 68 return $retval; 69 else 70 return null; 46 71 } 47 72 } … … 86 111 function DataGatherer() { 87 112 113 global $DATA_SOURCE; 114 115 $ds_fields = explode( ':', $DATA_SOURCE ); 116 $ds_ip = $ds_fields[0]; 117 $ds_port = $ds_fields[1]; 118 119 $this->source = new DataSource( $ds_ip, $ds_port ); 120 88 121 $this->parser = xml_parser_create(); 89 $this->source = new DataSource();90 122 $this->httpvars = new HTTPVariables(); 91 123 $this->xmlhandler = new TorqueXMLHandler(); … … 132 164 } 133 165 134 function gotNode( $hostname, $location = 'unspecified', $jobid = null) {166 function gotNode( $hostname, $location = 'unspecified', $jobid ) { 135 167 136 168 $nodes = &$this->nodes; … … 148 180 if( $jobid ) { 149 181 $nodes[$hostname]->addJob( $jobid ); 182 //printf("add job %s to node %s", $jobid, $hostname ); 150 183 } 151 184 } … … 218 251 $jobs[$jobid][$toganame][] = $hostname; 219 252 $this->gotNode( $hostname, null, $jobid ); 253 //printf( "got job %s on node %s", $jobid, $hostname ); 220 254 } 221 255 … … 294 328 295 329 $jobs[] = $jobid; 330 //print_r( $jobs ); 331 $this->jobs = $jobs; 296 332 } 297 333 … … 321 357 322 358 function getJobs() { 359 //print_r( $this->jobs ); 323 360 return $this->jobs; 324 361 } … … 351 388 class NodeImage { 352 389 353 var $image, $x, $y, $hostname ;354 355 function NodeImage( $image, $x, $y ) {390 var $image, $x, $y, $hostname, $jobs; 391 392 function NodeImage( $image, $x, $y, $hostname, $multiproc_job ) { 356 393 357 394 $this->image = $image; 358 395 $this->x = $x; 359 396 $this->y = $y; 397 $this->hostname = $hostname; 398 $this->multiproc_job = $multiproc_job; 360 399 } 361 400 … … 386 425 387 426 function drawNode( $load ) { 427 428 global $SMALL_CLUSTERIMAGE_NODEWIDTH; 388 429 389 430 if( !isset( $this->x ) or !isset( $this->y ) or !isset( $load ) ) { … … 393 434 } 394 435 395 $queue_color = imageColorAllocate( &$this->image, 0, 102, 304 ); 396 $job_color = imageColorAllocate( &$this->image, 204, 204, 0 ); 436 $black_color = imageColorAllocate( &$this->image, 0, 0, 0 ); 397 437 398 438 // Convert Ganglias Hexadecimal load color to a Decimal one 399 439 $my_loadcolor = $this->colorHex( load_color($load) ); 400 440 401 imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+11, $this->y+11, $queuecolor ); 402 imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+10, $this->y+10, $my_loadcolor ); 441 $size = $SMALL_CLUSTERIMAGE_NODEWIDTH; 442 443 imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color ); 444 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 ); 403 449 404 450 // Een job markering? … … 429 475 430 476 function draw() { 477 478 global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH; 479 431 480 $mydatag = $this->dataget; 432 481 $mydatag->parseXML(); 433 482 434 $max_width = 250; 435 $node_width = 11; 483 //$max_width = 250; 484 //$node_width = 11; 485 486 $max_width = $SMALL_CLUSTERIMAGE_MAXWIDTH; 487 $node_width = $SMALL_CLUSTERIMAGE_NODEWIDTH; 488 489 //printf( "cmaxw %s nmaxw %s", $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH ); 436 490 437 491 $nodes = $mydatag->getNodes(); … … 479 533 if( isset( $nodes[$host] ) and ($cur_node < $nodes_nr) ) { 480 534 //printf( "image %s\n", $host ); 481 $node = new NodeImage( $image, $x, $y ); 482 $node->setHostname( $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 } 549 550 //printf( "jobs %s node %s", $nrjobs, $host ); 551 $node = new NodeImage( $image, $x, $y, $host, $multiproc_job ); 552 //$node->setHostname( $host ); 483 553 $node->draw(); 484 554 //$nodes[$host]->setCoords( $x, $y );
Note: See TracChangeset
for help on using the changeset viewer.