Changeset 326 for trunk/web/addons
- Timestamp:
- 04/21/07 16:22:47 (16 years ago)
- Location:
- trunk/web/addons/job_monarch
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/image.php
r305 r326 29 29 } 30 30 31 function checkSessionData() { 32 33 global $_SESSION; 34 35 session_start(); 36 37 if( isset( $_SESSION["data"] ) ) { 38 $myxml_data = &$_SESSION["data"]; 39 } else { 40 $myxml_data = 0; 41 } 42 43 if( !$myxml_data ) { 44 $ds = new DataSource(); 45 $myxml_data = $ds->getData(); 46 47 print_f( "%s\n", $myxml_data ); 48 } 49 return $myxml_data; 50 } 51 52 31 53 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); 32 54 $view = $httpvars->getHttpVar( "view" ); … … 41 63 function drawHostImage() { 42 64 43 global $clustername, $hostname ;65 global $clustername, $hostname, $data_gatherer; 44 66 45 $data_gatherer = new DataGatherer( $clustername ); 46 $data_gatherer->parseXML(); 67 $ds = new DataSource(); 68 $myxml_data = $ds->getData(); 69 70 $data_gatherer = new DataGatherer( $clustername ); 71 72 $data_gatherer->parseXML( $myxml_data ); 47 73 48 74 if( $data_gatherer->isJobmonRunning() ) … … 56 82 function drawSmallClusterImage() { 57 83 58 global $clustername ;84 global $clustername, $data_gatherer; 59 85 60 $data_gatherer = new DataGatherer( $clustername ); 61 $data_gatherer->parseXML(); 86 $ds = new DataSource(); 87 $myxml_data = $ds->getData(); 88 89 $data_gatherer = new DataGatherer( $clustername ); 90 91 $data_gatherer->parseXML( $myxml_data ); 62 92 63 93 if( $data_gatherer->isJobmonRunning() ) { 64 $ic = new ClusterImage( $ clustername );94 $ic = new ClusterImage( $myxml_data, $clustername ); 65 95 $ic->setSmall(); 66 96 } else { … … 75 105 global $filter, $clustername; 76 106 77 $ic = new ClusterImage( $clustername ); 107 $myxml_data = checkSessionData(); 108 109 $ic = new ClusterImage( $myxml_data, $clustername ); 78 110 $ic->setBig(); 79 111 -
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 } -
trunk/web/addons/job_monarch/overview.php
r322 r326 26 26 global $hosts_up, $m, $start, $end, $filterorder, $COLUMN_REQUESTED_MEMORY, $COLUMN_QUEUED, $COLUMN_NODES, $hostname, $piefilter; 27 27 28 $ds = new DataSource(); 29 $myxml_data = $ds->getData(); 30 28 31 $data_gatherer = new DataGatherer( $clustername ); 29 32 … … 33 36 $tpl->assign( "cluster_url", rawurlencode($clustername) ); 34 37 35 $data_gatherer->parseXML( );38 $data_gatherer->parseXML( $myxml_data ); 36 39 37 40 $heartbeat = $data_gatherer->getHeartbeat(); … … 41 44 42 45 function setupFilterSettings() { 43 global $tpl, $filter, $clustername, $piefilter ;46 global $tpl, $filter, $clustername, $piefilter, $data_gatherer, $myxml_data; 44 47 45 48 $filter_image_url = ""; … … 52 55 } 53 56 54 $tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url ); 57 //include( "./ci_test.php" ); 58 session_start(); 59 //printf("data %s\n", strval( $myxml_data ) ); 60 $_SESSION["data"] = &$myxml_data; 61 62 $ic = new ClusterImage( $myxml_data, $clustername ); 63 $ic->setBig(); 64 $ic->setNoimage(); 65 $ic->draw(); 66 67 //$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url ); 68 $tpl->assign( "clusterimage", "./image.php?". session_name() . "=" . session_id() ."&c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url ); 69 70 $tpl->assign( "clusterimage_width", $ic->getWidth() ); 71 $tpl->assign( "clusterimage_height", $ic->getHeight() ); 72 73 $tpl->newBlock( "node_clustermap" ); 74 $tpl->assign( "node_area_map", $ic->getImagemapArea() ); 75 $tpl->gotoBlock( "_ROOT" ); 76 55 77 $tpl->assign( "f_order", $filterorder ); 56 78 -
trunk/web/addons/job_monarch/templates/overview.tpl
r299 r326 113 113 114 114 <TD ALIGN="CENTER"><CENTER> 115 <IMG SRC="{clusterimage}"><BR> 115 <!-- INCLUDESCRIPT BLOCK : ci_script --> 116 <IMG SRC="{clusterimage}" USEMAP="#MONARCH_CLUSTER_BIG" WIDTH="{clusterimage_width}" HEIGHT="{clusterimage_height}" BORDER="0"> 117 <MAP NAME="MONARCH_CLUSTER_BIG"> 118 <!-- START BLOCK : node_clustermap --> 119 {node_area_map} 120 <!-- END BLOCK : node_clustermap --> 121 </MAP> 122 <BR> 116 123 <FONT class="footer">Last updated: {report_time}</FONT></CENTER> 117 124 </TD>
Note: See TracChangeset
for help on using the changeset viewer.