Changeset 326 for trunk/web/addons/job_monarch/libtoga.php
- Timestamp:
- 04/21/07 16:22:47 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/libtoga.php
r313 r326 417 417 var $data, $ip, $port; 418 418 419 function DataSource( $ip = '127.0.0.1', $port = 8649 ) { 420 $this->ip = $ip; 421 $this->port = $port; 419 //function DataSource( $ip = '127.0.0.1', $port = 8649 ) { 420 function DataSource() { 421 422 global $DATA_SOURCE; 423 424 $ds_fields = explode( ':', $DATA_SOURCE ); 425 426 $ds_ip = $ds_fields[0]; 427 $ds_port = $ds_fields[1]; 428 429 $this->ip = $ds_ip; 430 $this->port = $ds_port; 431 422 432 } 423 433 … … 454 464 function DataGatherer( $cluster ) { 455 465 456 global $DATA_SOURCE;466 //global $DATA_SOURCE; 457 467 458 468 //printf("dg cluster = %s\n", $cluster ); 459 $ds_fields = explode( ':', $DATA_SOURCE );460 $ds_ip = $ds_fields[0];461 $ds_port = $ds_fields[1];462 463 $this->source = new DataSource( $ds_ip, $ds_port );464 465 $this-> parser = xml_parser_create();469 //$ds_fields = explode( ':', $DATA_SOURCE ); 470 //$ds_ip = $ds_fields[0]; 471 //$ds_port = $ds_fields[1]; 472 473 //$this->source = new DataSource( $ds_ip, $ds_port ); 474 475 $this->cluster = $cluster; 466 476 $this->httpvars = $httpvars; 467 $this->xmlhandler = new TorqueXMLHandler( $cluster ); 477 } 478 479 function parseXML( $data ) { 480 481 //$src = &$this->source; 482 //$this->data = $src->getData(); 483 484 $this->parser = xml_parser_create(); 485 $this->xmlhandler = new TorqueXMLHandler( $this->cluster ); 486 468 487 xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) ); 469 } 470 471 function parseXML() { 472 473 $src = &$this->source; 474 $this->data = $src->getData(); 475 476 if ( !xml_parse( $this->parser, $this->data ) ) 488 //if ( !xml_parse( $this->parser, $this->data ) ) 489 if ( !xml_parse( $this->parser, $data ) ) 477 490 $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) ); 478 491 } … … 591 604 592 605 if( !isset( $nodes[$hostname] ) ) 593 $nodes[$hostname] = new NodeImage( $ hostname );606 $nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname ); 594 607 595 608 } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) { … … 668 681 669 682 if( !isset( $nodes[$host] ) ) 670 $my_node = new NodeImage( $ host );683 $my_node = new NodeImage( $this->proc_cluster, $host ); 671 684 else 672 685 $my_node = $nodes[$host]; … … 767 780 var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo; 768 781 769 function NodeImage( $ hostname ) {782 function NodeImage( $cluster, $hostname ) { 770 783 771 784 global $SMALL_CLUSTERIMAGE_NODEWIDTH; … … 778 791 $this->hostname = $hostname; 779 792 $this->cpus = $this->determineCpus(); 793 $this->clustername = $cluster; 780 794 $this->showinfo = 1; 781 795 $this->size = $SMALL_CLUSTERIMAGE_NODEWIDTH; … … 818 832 $this->x = $x; 819 833 $this->y = $y; 834 } 835 836 function getImagemapArea() { 837 838 $area_topleft = $this->x . "," . $this->y; 839 $area_bottomright = ($this->x + $this->size) . "," . ($this->y + $this->size); 840 $area_coords = $area_topleft . "," . $area_bottomright; 841 842 $area_href = "./?c=" . $this->clustername . "&h=" . $this->hostname; 843 $area_tooltip = $this->hostname . ": " . implode( " ", $this->jobs ); 844 845 $tag_href = "HREF=\"" . $area_href . "\""; 846 $tag_coords = "COORDS=\"" . $area_coords . "\""; 847 $tag_tooltip1 = "ALT=\"" . $area_tooltip . "\""; 848 $tag_tooltip2 = "TITLE=\"" . $area_tooltip . "\""; 849 850 return ("<AREA SHAPE=\"RECT\" " . $tag_coords . " " . $tag_href . " " . $tag_tooltip1 . " " . $tag_tooltip2 . ">"); 820 851 } 821 852 … … 929 960 var $filtername, $filters; 930 961 931 function ClusterImage( $clustername ) { 932 962 //function ClusterImage( $clustername ) { 963 function ClusterImage( $data, $clustername ) { 964 965 //$this->dataget = $dataget; 933 966 $this->dataget = new DataGatherer( $clustername ); 967 $this->data = $data; 934 968 $this->clustername = $clustername; 935 969 $this->filters = array(); 936 970 $this->size = 's'; 971 $this->width = 0; 972 $this->height = 0; 973 $this->output = 1; 974 } 975 976 function getWidth() { 977 return $this->width; 978 } 979 function getHeight() { 980 return $this->height; 937 981 } 938 982 … … 943 987 function setBig() { 944 988 $this->size = 'b'; 989 } 990 991 function setNoimage() { 992 $this->output = 0; 945 993 } 946 994 … … 1007 1055 1008 1056 $mydatag = $this->dataget; 1009 $mydatag->parseXML( );1057 $mydatag->parseXML( $this->data ); 1010 1058 1011 1059 if( $this->isSmall() ) { … … 1048 1096 $y_offset = $fontheight + (2 * $fontspaceing); 1049 1097 1098 $this->width = $max_width; 1099 $this->height = ($y_offset + (($node_rows*$node_width)+1) ); 1100 1050 1101 $image = imageCreateTrueColor( $max_width, ($y_offset + (($node_rows*$node_width)+1) ) ); 1051 1102 $colorwhite = imageColorAllocate( $image, 255, 255, 255 ); … … 1090 1141 } 1091 1142 } 1092 1093 header( 'Content-type: image/png' ); 1094 imagePNG( $image ); 1095 imageDestroy( $image ); 1143 1144 $this->nodes = &$nodes; 1145 1146 if ($this->output) { 1147 header( 'Content-type: image/png' ); 1148 imagePNG( $image ); 1149 imageDestroy( $image ); 1150 } 1151 } 1152 1153 function getImagemapArea() { 1154 1155 $clusterimage_map = ""; 1156 1157 foreach( $this->nodes as $hostname => $node ) { 1158 1159 $node_map = $node->getImagemapArea(); 1160 $clusterimage_map .= $node_map; 1161 } 1162 1163 return $clusterimage_map; 1096 1164 } 1097 1165 }
Note: See TracChangeset
for help on using the changeset viewer.