- Timestamp:
- 05/13/05 12:07:07 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/toga/toga-functions.php
r103 r104 1 <PRE> 1 2 <?php 2 3 $GANGLIA_PATH = "/var/www/ganglia"; … … 90 91 class TorqueXMLHandler { 91 92 93 var $clusters, $heartbeat; 94 92 95 function TorqueXMLHandler() { 96 $clusters = array(); 97 $heartbeat = array(); 93 98 } 94 99 … … 105 110 $jobid = null; 106 111 107 printf( '%s=%s', $attrs[NAME], $attrs[VAL] ); 108 109 sscanf( $attrs[NAME], 'TOGA-JOB-%d', $jobid ); 110 111 if( $jobid ) { 112 113 if( !isset( $jobs[$jobid] ) ) 114 $jobs[$jobid] = array(); 115 116 $fields = explode( ' ', $attrs[VAL] ); 117 118 foreach( $fields as $f ) { 119 $togavalues = explode( '=', $f ); 120 121 foreach( $togavalues as $toganame => $togavalue ) { 112 // printf( '%s=%s', $attrs[NAME], $attrs[VAL] ); 113 114 115 if( $name == 'CLUSTER' ) { 116 117 $clustername = $attrs[VAL]; 118 119 if( !isset( $clusters[$clustername] ) ) 120 $clusters[$clustername] = array(); 121 122 } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'TOGA' ) ) { 123 124 if( strstr( $attrs[NAME], 'TOGA-HEARTBEAT' ) ) { 125 126 $heartbeat['time'] = $attrs[VAL]; 127 printf( "heartbeat %s\n", $heartbeat['time'] ); 128 129 } else if( strstr( $attrs[NAME], 'TOGA-JOB' ) ) { 130 131 sscanf( $attrs[NAME], 'TOGA-JOB-%d', $jobid ); 132 133 printf( "jobid %s\n", $jobid ); 134 135 if( !isset( $jobs[$jobid] ) ) 136 $jobs[$jobid] = array(); 137 138 $fields = explode( ' ', $attrs[VAL] ); 139 140 foreach( $fields as $f ) { 141 $togavalues = explode( '=', $f ); 142 143 $toganame = $togavalues[0]; 144 $togavalue = $togavalues[1]; 145 146 printf( "toganame %s, togavalue %s\n", $toganame, $togavalue ); 122 147 123 148 if( $toganame == 'nodes' ) { 124 149 150 if( !isset( $jobs[$toganame] ) ) 151 $jobs[$toganame] = array(); 152 125 153 $nodes = explode( ';', $togavalue ); 126 154 127 155 foreach( $nodes as $node ) { 128 156 129 // Doe iets koels met $node 157 printf( "node %s\n", $node ); 158 $jobs[$toganame][] = new Node( $node ); 130 159 } 131 160 161 } else { 162 163 $jobs[$toganame] = $togavalue; 164 132 165 } 133 134 $jobs[$toganame] = $togavalue;135 136 166 } 137 167 } 138 139 168 } 140 169 } … … 146 175 class Node { 147 176 148 var $img; 149 150 function Node() { 151 177 var $img, $hostname, $location; 178 179 function Node( $hostname ) { 180 181 $this->hostname = $hostname; 152 182 $this->img = new NodeImg(); 183 } 184 185 function setLocation( $location ) { 186 $this->location = $location; 187 } 188 189 function setCpus( $cpus ) { 190 $this->cpus = $cpus; 153 191 } 154 192 } … … 210 248 $my_data->parseXML(); 211 249 ?> 250 </PRE>
Note: See TracChangeset
for help on using the changeset viewer.