[102] | 1 | <?php |
---|
[225] | 2 | /* |
---|
| 3 | * |
---|
| 4 | * This file is part of Jobmonarch |
---|
| 5 | * |
---|
| 6 | * Copyright (C) 2006 Ramon Bastiaans |
---|
| 7 | * |
---|
| 8 | * Jobmonarch is free software; you can redistribute it and/or modify |
---|
| 9 | * it under the terms of the GNU General Public License as published by |
---|
| 10 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | * (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * Jobmonarch is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 21 | * |
---|
[231] | 22 | * SVN $Id: libtoga.php 231 2006-03-10 16:36:38Z bastiaans $ |
---|
| 23 | * |
---|
[225] | 24 | */ |
---|
| 25 | |
---|
| 26 | |
---|
[117] | 27 | // If php is compiled without globals |
---|
| 28 | // |
---|
[145] | 29 | //if ( !empty( $_GET ) ) { |
---|
| 30 | // extract( $_GET ); |
---|
| 31 | //} |
---|
[117] | 32 | |
---|
[103] | 33 | class HTTPVariables { |
---|
| 34 | |
---|
| 35 | var $clustername, $metricname; |
---|
[112] | 36 | var $restvars, $httpvars; |
---|
[103] | 37 | |
---|
[117] | 38 | function HTTPVariables( $httpvars, $getvars ) { |
---|
[103] | 39 | |
---|
[110] | 40 | $this->restvars = array(); |
---|
| 41 | |
---|
[117] | 42 | $this->clustername = $httpvars["c"] ? $httpvars["c"] : null; |
---|
| 43 | $this->metricname = $httpvars["m"] ? $httpvars["m"] : null; |
---|
[103] | 44 | |
---|
[117] | 45 | foreach( $httpvars as $httpvar => $httpval ) { |
---|
[110] | 46 | |
---|
| 47 | if( $httpval ) { |
---|
| 48 | $this->restvars[$httpvar] = $httpval; |
---|
| 49 | } |
---|
| 50 | } |
---|
[117] | 51 | |
---|
| 52 | foreach( $getvars as $getvar => $getval ) { |
---|
| 53 | |
---|
| 54 | if( $getval ) { |
---|
| 55 | $this->restvars[$getvar] = $getval; |
---|
| 56 | } |
---|
| 57 | } |
---|
[103] | 58 | } |
---|
| 59 | |
---|
| 60 | function getClusterName() { |
---|
| 61 | return $this->clustername; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | function getMetricName() { |
---|
| 65 | return $this->metricname; |
---|
| 66 | } |
---|
[110] | 67 | |
---|
| 68 | function getHttpVar( $var ) { |
---|
| 69 | if( isset( $this->restvars[$var] ) ) |
---|
[112] | 70 | return $this->restvars[$var]; |
---|
[110] | 71 | else |
---|
| 72 | return null; |
---|
| 73 | } |
---|
[103] | 74 | } |
---|
| 75 | |
---|
[112] | 76 | // Toga's conf |
---|
| 77 | // |
---|
| 78 | include_once "./conf.php"; |
---|
[195] | 79 | include_once "./version.php"; |
---|
[112] | 80 | |
---|
[117] | 81 | global $GANGLIA_PATH; |
---|
[206] | 82 | global $RRDTOOL; |
---|
| 83 | global $JOB_ARCHIVE_DIR; |
---|
[207] | 84 | global $JOB_ARCHIVE_DBASE; |
---|
[112] | 85 | |
---|
[117] | 86 | $my_dir = getcwd(); |
---|
[112] | 87 | |
---|
[117] | 88 | // Load Ganglia's PHP |
---|
| 89 | chdir( $GANGLIA_PATH ); |
---|
[112] | 90 | |
---|
[117] | 91 | include_once "./conf.php"; |
---|
| 92 | include_once "./functions.php"; |
---|
| 93 | include_once "./ganglia.php"; |
---|
[145] | 94 | include_once "./get_context.php"; |
---|
| 95 | unset( $start ); |
---|
| 96 | $context = 'cluster'; |
---|
[117] | 97 | include_once "./get_ganglia.php"; |
---|
| 98 | |
---|
| 99 | // Back to our PHP |
---|
| 100 | chdir( $my_dir ); |
---|
| 101 | |
---|
| 102 | global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH, $DATA_SOURCE, $HTTP_GET_VARS, $_GET; |
---|
| 103 | $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET ); |
---|
| 104 | |
---|
[112] | 105 | // Set cluster context so that Ganglia will |
---|
| 106 | // provide us with the correct metrics array |
---|
| 107 | // |
---|
[126] | 108 | global $context, $clustername, $reports; |
---|
[129] | 109 | |
---|
[117] | 110 | //$clustername = $httpvars->getClusterName(); |
---|
[112] | 111 | |
---|
[126] | 112 | global $default_metric; |
---|
| 113 | |
---|
[112] | 114 | // Ganglia's array of host metrics |
---|
| 115 | // |
---|
[126] | 116 | global $metrics, $hosts_up; |
---|
[112] | 117 | |
---|
[130] | 118 | class TarchDbase { |
---|
| 119 | |
---|
[138] | 120 | var $ip, $dbase, $conn; |
---|
[130] | 121 | |
---|
[204] | 122 | function TarchDbase( $ip = null, $dbase = 'jobarch' ) { |
---|
[207] | 123 | |
---|
| 124 | global $JOB_ARCHIVE_DBASE; |
---|
| 125 | |
---|
| 126 | $db_fields = explode( '/', $JOB_ARCHIVE_DBASE ); |
---|
| 127 | |
---|
| 128 | $this->ip = $db_fields[0]; |
---|
| 129 | $this->dbase = $db_fields[1]; |
---|
[138] | 130 | $this->conn = null; |
---|
[130] | 131 | } |
---|
| 132 | |
---|
| 133 | function connect() { |
---|
| 134 | |
---|
| 135 | if( $this->ip == null and $this->dbase == 'toga' ) |
---|
[138] | 136 | $this->conn = pg_connect( "dbname=".$this->dbase ); |
---|
[130] | 137 | else |
---|
[204] | 138 | $this->conn = pg_connect( "host=".$this->ip." dbname=".$this->dbase ); |
---|
[130] | 139 | } |
---|
[138] | 140 | |
---|
| 141 | function searchDbase( $id = null, $queue = null, $user = null, $name = null, $start_from_time = null, $start_to_time = null, $end_from_time = null, $end_to_time = null ) { |
---|
| 142 | |
---|
| 143 | if( $id ) |
---|
[152] | 144 | $query = "SELECT job_id FROM jobs WHERE job_id = '$id' AND job_status = 'F'"; |
---|
[138] | 145 | else { |
---|
| 146 | $query_args = array(); |
---|
| 147 | |
---|
| 148 | if( $queue ) |
---|
| 149 | $query_args[] = "job_queue ='$queue'"; |
---|
| 150 | if( $user ) |
---|
| 151 | $query_args[] = "job_owner ='$user'"; |
---|
| 152 | if( $name ) |
---|
| 153 | $query_args[] = "job_name = '$name'"; |
---|
| 154 | if( $start_from_time ) |
---|
| 155 | $query_args[] = "job_start_timestamp >= $start_from_time"; |
---|
[142] | 156 | if( $start_to_time ) |
---|
[138] | 157 | $query_args[] = "job_start_timestamp <= $start_to_time"; |
---|
| 158 | if( $end_from_time ) |
---|
| 159 | $query_args[] = "job_stop_timestamp >= $end_from_time"; |
---|
| 160 | if( $end_to_time ) |
---|
| 161 | $query_args[] = "job_stop_timestamp <= $end_to_time"; |
---|
| 162 | |
---|
[152] | 163 | $query = "SELECT job_id FROM jobs WHERE job_status = 'F' AND "; |
---|
[138] | 164 | $extra_query_args = ''; |
---|
| 165 | |
---|
| 166 | foreach( $query_args as $myquery ) { |
---|
| 167 | |
---|
| 168 | if( $extra_query_args == '' ) |
---|
| 169 | $extra_query_args = $myquery; |
---|
| 170 | else |
---|
| 171 | $extra_query_args .= " AND ".$myquery; |
---|
| 172 | } |
---|
| 173 | $query .= $extra_query_args; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | $ids = $this->queryDbase( $query ); |
---|
[140] | 177 | |
---|
| 178 | $ret = array(); |
---|
| 179 | |
---|
| 180 | foreach( $ids as $crow) |
---|
| 181 | $ret[] = $crow[job_id]; |
---|
| 182 | |
---|
| 183 | return $ret; |
---|
[138] | 184 | } |
---|
| 185 | |
---|
| 186 | function getNodesForJob( $jobid ) { |
---|
| 187 | |
---|
| 188 | $result = $this->queryDbase( "SELECT node_id FROM job_nodes WHERE job_id = '$jobid'" ); |
---|
| 189 | |
---|
| 190 | $nodes = array(); |
---|
| 191 | |
---|
| 192 | foreach( $result as $result_row ) |
---|
| 193 | |
---|
[141] | 194 | $nodes[] = $this->getNodeArray( $result_row[node_id] ); |
---|
[138] | 195 | |
---|
| 196 | return $nodes; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | function getJobsForNode( $nodeid ) { |
---|
| 200 | |
---|
| 201 | $result = $this->queryDbase( "SELECT job_id FROM job_nodes WHERE node_id = '$nodeid'" ); |
---|
| 202 | |
---|
| 203 | $jobs = array(); |
---|
| 204 | |
---|
| 205 | foreach( $result as $result_row ) |
---|
| 206 | |
---|
[141] | 207 | $jobs[] = $this->getJobArray( $result_row[job_id] ); |
---|
[138] | 208 | |
---|
| 209 | return $jobs; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | function getJobArray( $id ) { |
---|
| 213 | $result = $this->queryDbase( "SELECT * FROM jobs WHERE job_id = '$id'" ); |
---|
| 214 | |
---|
| 215 | return ( $this->makeArray( $result[0] ) ); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | function getNodeArray( $id ) { |
---|
| 219 | |
---|
| 220 | $result = $this->queryDbase( "SELECT * FROM nodes WHERE node_id = '$id'" ); |
---|
| 221 | |
---|
| 222 | return ( $this->makeArray( $result[0] ) ); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | function makeArray( $result_row ) { |
---|
| 226 | |
---|
| 227 | $myar = array(); |
---|
| 228 | |
---|
| 229 | foreach( $result_row as $mykey => $myval ) { |
---|
| 230 | |
---|
| 231 | $map_key = explode( '_', $mykey ); |
---|
| 232 | |
---|
[141] | 233 | $rmap_key = array_reverse( $map_key ); |
---|
| 234 | array_pop( $rmap_key ); |
---|
| 235 | $map_key = array_reverse( $rmap_key ); |
---|
[138] | 236 | |
---|
[141] | 237 | $newkey = implode( '_', $map_key ); |
---|
| 238 | |
---|
[138] | 239 | $myar[$newkey] = $result_row[$mykey]; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | return $myar; |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | function queryDbase( $query ) { |
---|
| 246 | |
---|
| 247 | $result_rows = array(); |
---|
| 248 | |
---|
| 249 | if( !$this->conn ) |
---|
| 250 | $this->connect(); |
---|
| 251 | |
---|
[143] | 252 | //printf( "query = [%s]\n", $query ); |
---|
[138] | 253 | $result = pg_query( $this->conn, $query ); |
---|
| 254 | |
---|
| 255 | while ($row = pg_fetch_assoc($result)) |
---|
| 256 | $result_rows[] = $row; |
---|
| 257 | |
---|
| 258 | return $result_rows; |
---|
| 259 | } |
---|
[130] | 260 | } |
---|
| 261 | |
---|
[138] | 262 | class TarchRrdGraph { |
---|
[130] | 263 | var $rrdbin, $rrdvalues, $clustername, $hostname, $tempdir, $tarchdir, $metrics; |
---|
| 264 | |
---|
[206] | 265 | function TarchRrdGraph( $clustername, $hostname ) { |
---|
| 266 | |
---|
| 267 | global $RRDTOOL; |
---|
| 268 | global $JOB_ARCHIVE_DIR; |
---|
| 269 | |
---|
| 270 | $this->rrdbin = $RRDTOOL; |
---|
[130] | 271 | $this->rrdvalues = array(); |
---|
[206] | 272 | $this->tarchdir = $JOB_ARCHIVE_DIR; |
---|
[145] | 273 | $this->clustername = $clustername; |
---|
| 274 | $this->hostname = $hostname; |
---|
[130] | 275 | } |
---|
| 276 | |
---|
| 277 | function doCmd( $command ) { |
---|
| 278 | |
---|
| 279 | printf( "command = %s\n", $command ); |
---|
| 280 | $pipe = popen( $command . ' 2>&1', 'r' ); |
---|
| 281 | |
---|
| 282 | if (!$pipe) { |
---|
| 283 | print "pipe failed."; |
---|
| 284 | return ""; |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | $output = ''; |
---|
| 288 | while(!feof($pipe)) |
---|
| 289 | $output .= fread($pipe, 1024); |
---|
| 290 | |
---|
| 291 | pclose($pipe); |
---|
| 292 | |
---|
| 293 | $output = explode( "\n", $output ); |
---|
[135] | 294 | //print_r( $output ); |
---|
[130] | 295 | return $output; |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | function dirList( $dir ) { |
---|
| 299 | |
---|
| 300 | $dirlist = array(); |
---|
| 301 | |
---|
| 302 | if ($handle = opendir( $dir )) { |
---|
| 303 | while (false !== ($file = readdir($handle))) { |
---|
| 304 | if ($file != "." && $file != "..") { |
---|
| 305 | $dirlist[] = $file; |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | closedir($handle); |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | return $dirlist; |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | function getTimePeriods( $start, $end ) { |
---|
| 315 | |
---|
[145] | 316 | //printf("start = %s end = %s\n", $start, $end ); |
---|
[130] | 317 | $times = array(); |
---|
| 318 | $dirlist = $this->dirList( $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname ); |
---|
[145] | 319 | |
---|
| 320 | //print_r( $dirlist ); |
---|
| 321 | |
---|
[130] | 322 | $first = 0; |
---|
| 323 | $last = 9999999999999; |
---|
| 324 | |
---|
| 325 | foreach( $dirlist as $dir ) { |
---|
| 326 | |
---|
| 327 | if( $dir > $first and $dir <= $start ) |
---|
| 328 | $first = $dir; |
---|
| 329 | if( $dir < $last and $dir >= $end ) |
---|
| 330 | $last = $dir; |
---|
| 331 | } |
---|
| 332 | |
---|
[145] | 333 | //printf( "first = %s last = %s\n", $first, $last ); |
---|
| 334 | |
---|
[130] | 335 | foreach( $dirlist as $dir ) { |
---|
| 336 | |
---|
[145] | 337 | //printf( "dir %s ", $dir ); |
---|
| 338 | |
---|
| 339 | if( $dir >= $first and $dir <= $last and !array_key_exists( $dir, $times ) ) { |
---|
| 340 | |
---|
[130] | 341 | $times[] = $dir; |
---|
[145] | 342 | //printf("newtime %s ", $dir ); |
---|
| 343 | |
---|
| 344 | } |
---|
[130] | 345 | } |
---|
| 346 | |
---|
[145] | 347 | //print_r( $times ); |
---|
| 348 | |
---|
[130] | 349 | sort( $times ); |
---|
| 350 | |
---|
[145] | 351 | //print_r( $times ); |
---|
| 352 | |
---|
[130] | 353 | return $times; |
---|
| 354 | } |
---|
| 355 | |
---|
[145] | 356 | function getRrdDirs( $start, $stop ) { |
---|
| 357 | |
---|
| 358 | //printf( "tarchdir = %s\n", $this->tarchdir ); |
---|
| 359 | $timess = $this->getTimePeriods( $start, $stop ); |
---|
| 360 | //print_r( $timess ); |
---|
| 361 | |
---|
| 362 | $rrd_files = array(); |
---|
| 363 | |
---|
| 364 | foreach( $timess as $time ) { |
---|
| 365 | |
---|
| 366 | $rrd_files[] = $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname. '/'.$time; |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | return $rrd_files; |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | function getRrdFiles( $metric, $start, $stop ) { |
---|
| 373 | |
---|
| 374 | $times = $this->getTimePeriods( $start, $stop ); |
---|
| 375 | |
---|
| 376 | $rrd_files = array(); |
---|
| 377 | |
---|
| 378 | foreach( $times as $time ) { |
---|
| 379 | |
---|
| 380 | $rrd_files[] = $this->tarchdir . '/' . $this->clustername . '/' . $this->hostname . '/' .$time. '/' . $metric. '.rrd'; |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | return $rrd_files; |
---|
| 384 | } |
---|
| 385 | |
---|
[130] | 386 | function graph( $descr ) { |
---|
[141] | 387 | // monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl# rrdtool graph /var/www/ganglia/test1.png --start 1118683231 --end 1118750431 --width 300 --height 400 DEF:'1'='./1118647515/load_one.rrd':'sum':AVERAGE DEF:'2'='./1118690723/load_one.rrd':'sum':AVERAGE DEF:'3'='./1118733925/load_one.rrd':'sum':AVERAGE AREA:1#555555:"load_one" AREA:2#555555 AREA:3#555555 |
---|
| 388 | // 380x461 |
---|
| 389 | // monitor2:/data/toga/rrds/LISA Cluster/gb-r15n11.irc.sara.nl# |
---|
[130] | 390 | //$command = $this->rrdbin . " graph - --start $start --end $end ". |
---|
| 391 | "--width $width --height $height $upper_limit $lower_limit ". |
---|
| 392 | "--title '$title' $vertical_label $extras $background ". $series; |
---|
| 393 | |
---|
| 394 | //$graph = $this->doCmd( $command ); |
---|
| 395 | |
---|
| 396 | //return $graph; |
---|
[145] | 397 | return 0; |
---|
[130] | 398 | } |
---|
| 399 | } |
---|
| 400 | |
---|
[103] | 401 | class DataSource { |
---|
| 402 | |
---|
| 403 | var $data, $ip, $port; |
---|
| 404 | |
---|
| 405 | function DataSource( $ip = '127.0.0.1', $port = 8649 ) { |
---|
| 406 | $this->ip = $ip; |
---|
| 407 | $this->port = $port; |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | function getData() { |
---|
| 411 | |
---|
| 412 | $errstr; |
---|
| 413 | $errno = 0; |
---|
| 414 | $timeout = 3; |
---|
| 415 | |
---|
| 416 | $fp = fsockopen( $this->ip, $this->port, &$errno, &$errstr, $timeout ); |
---|
| 417 | |
---|
[106] | 418 | if( !$fp ) { |
---|
[103] | 419 | echo 'Unable to connect to '.$this->ip.':'.$this->port; // printf( 'Unable to connect to [%s:%.0f]', $this->ip, $this->port ); |
---|
| 420 | return; |
---|
| 421 | } |
---|
| 422 | |
---|
[177] | 423 | stream_set_timeout( $fp, 30 ); |
---|
| 424 | |
---|
[103] | 425 | while ( !feof( $fp ) ) { |
---|
| 426 | |
---|
| 427 | $data .= fread( $fp, 16384 ); |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | fclose( $fp ); |
---|
| 431 | |
---|
| 432 | return $data; |
---|
| 433 | } |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | class DataGatherer { |
---|
| 437 | |
---|
[105] | 438 | var $xmlhandler, $data, $httpvars; |
---|
[103] | 439 | |
---|
[163] | 440 | function DataGatherer( $cluster ) { |
---|
[103] | 441 | |
---|
[110] | 442 | global $DATA_SOURCE; |
---|
[163] | 443 | |
---|
| 444 | //printf("dg cluster = %s\n", $cluster ); |
---|
[110] | 445 | $ds_fields = explode( ':', $DATA_SOURCE ); |
---|
| 446 | $ds_ip = $ds_fields[0]; |
---|
| 447 | $ds_port = $ds_fields[1]; |
---|
| 448 | |
---|
| 449 | $this->source = new DataSource( $ds_ip, $ds_port ); |
---|
| 450 | |
---|
[103] | 451 | $this->parser = xml_parser_create(); |
---|
[112] | 452 | $this->httpvars = $httpvars; |
---|
[163] | 453 | $this->xmlhandler = new TorqueXMLHandler( $cluster ); |
---|
[103] | 454 | xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) ); |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | function parseXML() { |
---|
| 458 | |
---|
| 459 | $src = &$this->source; |
---|
| 460 | $this->data = $src->getData(); |
---|
| 461 | |
---|
[112] | 462 | if ( !xml_parse( &$this->parser, $this->data ) ) |
---|
[103] | 463 | $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( &$this->parser ) ), xml_get_current_line_number( &$this->parser ) ); |
---|
| 464 | } |
---|
| 465 | |
---|
[105] | 466 | function printInfo() { |
---|
| 467 | $handler = $this->xmlhandler; |
---|
| 468 | $handler->printInfo(); |
---|
| 469 | } |
---|
| 470 | |
---|
[106] | 471 | function getNodes() { |
---|
| 472 | $handler = $this->xmlhandler; |
---|
| 473 | return $handler->getNodes(); |
---|
| 474 | } |
---|
| 475 | |
---|
[124] | 476 | function getCpus() { |
---|
| 477 | $handler = $this->xmlhandler; |
---|
| 478 | return $handler->getCpus(); |
---|
| 479 | } |
---|
| 480 | |
---|
[106] | 481 | function getJobs() { |
---|
| 482 | $handler = $this->xmlhandler; |
---|
| 483 | return $handler->getJobs(); |
---|
| 484 | } |
---|
| 485 | |
---|
[114] | 486 | function getHeartbeat() { |
---|
| 487 | $handler = $this->xmlhandler; |
---|
| 488 | return $handler->getHeartbeat(); |
---|
| 489 | } |
---|
[103] | 490 | } |
---|
| 491 | |
---|
| 492 | class TorqueXMLHandler { |
---|
| 493 | |
---|
[163] | 494 | var $clusters, $heartbeat, $nodes, $jobs, $clustername, $proc_cluster; |
---|
[104] | 495 | |
---|
[163] | 496 | function TorqueXMLHandler( $clustername ) { |
---|
[105] | 497 | $jobs = array(); |
---|
[104] | 498 | $clusters = array(); |
---|
[163] | 499 | $this->nodes = array(); |
---|
[104] | 500 | $heartbeat = array(); |
---|
[163] | 501 | $this->clustername = $clustername; |
---|
| 502 | //printf(" cluster set to %s \n", $this->clustername ); |
---|
[103] | 503 | } |
---|
| 504 | |
---|
[124] | 505 | function getCpus() { |
---|
| 506 | |
---|
| 507 | $cpus = 0; |
---|
| 508 | |
---|
| 509 | foreach( $this->jobs as $jobid=>$jobattrs ) { |
---|
| 510 | |
---|
| 511 | $nodes = count( $jobattrs[nodes] ); |
---|
| 512 | $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1; |
---|
| 513 | $mycpus = $nodes * $ppn; |
---|
| 514 | |
---|
| 515 | $cpus = $cpus + $mycpus; |
---|
| 516 | } |
---|
| 517 | } |
---|
| 518 | |
---|
[103] | 519 | function startElement( $parser, $name, $attrs ) { |
---|
| 520 | |
---|
[105] | 521 | $jobs = &$this->jobs; |
---|
[111] | 522 | $nodes = &$this->nodes; |
---|
[105] | 523 | |
---|
[103] | 524 | if ( $attrs[TN] ) { |
---|
| 525 | |
---|
| 526 | // Ignore dead metrics. Detect and mask failures. |
---|
| 527 | if ( $attrs[TN] > $attrs[TMAX] * 4 ) |
---|
| 528 | return; |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | $jobid = null; |
---|
| 532 | |
---|
[163] | 533 | //printf( '%s=%s', $attrs[NAME], $attrs[VAL] ); |
---|
[103] | 534 | |
---|
[163] | 535 | //printf( "clustername = %s proc_cluster = %s\n", $this->clustername, $this->proc_cluster ); |
---|
| 536 | |
---|
[104] | 537 | if( $name == 'CLUSTER' ) { |
---|
[103] | 538 | |
---|
[163] | 539 | $this->proc_cluster = $attrs[NAME]; |
---|
| 540 | //printf( "Found cluster %s\n", $attrs[NAME] ); |
---|
| 541 | //print_r( $attrs ); |
---|
[103] | 542 | |
---|
[163] | 543 | //if( !isset( $clusters[$clustername] ) ) |
---|
| 544 | // $clusters[$clustername] = array(); |
---|
[103] | 545 | |
---|
[163] | 546 | } else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) { |
---|
[105] | 547 | |
---|
| 548 | $hostname = $attrs[NAME]; |
---|
| 549 | $location = $attrs[LOCATION]; |
---|
[163] | 550 | //printf( "Found node %s\n", $hostname ); |
---|
[105] | 551 | |
---|
[200] | 552 | if( !isset( $nodes[$hostname] ) ) |
---|
[163] | 553 | $nodes[$hostname] = new NodeImage( $hostname ); |
---|
[105] | 554 | |
---|
[219] | 555 | } else if( $name == 'METRIC' and strstr( $attrs[NAME], 'MONARCH' ) and $this->proc_cluster == $this->clustername ) { |
---|
[103] | 556 | |
---|
[219] | 557 | if( strstr( $attrs[NAME], 'MONARCH-HEARTBEAT' ) ) { |
---|
[103] | 558 | |
---|
[114] | 559 | $this->heartbeat['time'] = $attrs[VAL]; |
---|
[106] | 560 | //printf( "heartbeat %s\n", $heartbeat['time'] ); |
---|
[104] | 561 | |
---|
[219] | 562 | } else if( strstr( $attrs[NAME], 'MONARCH-JOB' ) ) { |
---|
[104] | 563 | |
---|
[219] | 564 | sscanf( $attrs[NAME], 'MONARCH-JOB-%d', $jobid ); |
---|
[104] | 565 | |
---|
[106] | 566 | //printf( "jobid %s\n", $jobid ); |
---|
[104] | 567 | |
---|
| 568 | if( !isset( $jobs[$jobid] ) ) |
---|
| 569 | $jobs[$jobid] = array(); |
---|
| 570 | |
---|
| 571 | $fields = explode( ' ', $attrs[VAL] ); |
---|
| 572 | |
---|
| 573 | foreach( $fields as $f ) { |
---|
| 574 | $togavalues = explode( '=', $f ); |
---|
| 575 | |
---|
| 576 | $toganame = $togavalues[0]; |
---|
| 577 | $togavalue = $togavalues[1]; |
---|
| 578 | |
---|
[106] | 579 | //printf( "\t%s\t= %s\n", $toganame, $togavalue ); |
---|
[104] | 580 | |
---|
[103] | 581 | if( $toganame == 'nodes' ) { |
---|
| 582 | |
---|
[135] | 583 | if( $jobs[$jobid][status] == 'R' ) { |
---|
| 584 | |
---|
| 585 | if( !isset( $jobs[$jobid][$toganame] ) ) |
---|
| 586 | $jobs[$jobid][$toganame] = array(); |
---|
[104] | 587 | |
---|
[135] | 588 | $mynodes = explode( ';', $togavalue ); |
---|
[103] | 589 | |
---|
[135] | 590 | foreach( $mynodes as $node ) |
---|
[103] | 591 | |
---|
[135] | 592 | $jobs[$jobid][$toganame][] = $node; |
---|
| 593 | |
---|
| 594 | } else if( $jobs[$jobid][status] == 'Q' ) { |
---|
| 595 | |
---|
| 596 | $jobs[$jobid][$toganame] = $togavalue; |
---|
| 597 | } |
---|
| 598 | |
---|
[104] | 599 | } else { |
---|
[103] | 600 | |
---|
[105] | 601 | $jobs[$jobid][$toganame] = $togavalue; |
---|
[104] | 602 | } |
---|
[103] | 603 | } |
---|
[111] | 604 | |
---|
| 605 | if( isset( $jobs[$jobid][domain] ) and isset( $jobs[$jobid][nodes] ) ) { |
---|
[112] | 606 | |
---|
| 607 | $nr_nodes = count( $jobs[$jobid][nodes] ); |
---|
| 608 | |
---|
[111] | 609 | foreach( $jobs[$jobid][nodes] as $node ) { |
---|
| 610 | |
---|
[200] | 611 | $domain = $jobs[$jobid][domain]; |
---|
| 612 | $domain_len = 0 - strlen( $domain ); |
---|
| 613 | |
---|
| 614 | if( substr( $node, $domain_len ) != $domain ) { |
---|
| 615 | $host = $node. '.'.$domain; |
---|
| 616 | } else { |
---|
| 617 | $host = $node; |
---|
| 618 | } |
---|
| 619 | |
---|
| 620 | //$host = $node.'.'.$jobs[$jobid][domain]; |
---|
[111] | 621 | |
---|
[200] | 622 | if( !isset( $nodes[$host] ) ) |
---|
[111] | 623 | $my_node = new NodeImage( $host ); |
---|
| 624 | else |
---|
[200] | 625 | $my_node = $nodes[$host]; |
---|
[111] | 626 | |
---|
| 627 | if( !$my_node->hasJob( $jobid ) ) |
---|
| 628 | |
---|
| 629 | if( isset( $jobs[$jobid][ppn] ) ) |
---|
| 630 | $my_node->addJob( $jobid, ((int) $jobs[$jobid][ppn]) ); |
---|
| 631 | else |
---|
| 632 | $my_node->addJob( $jobid, 1 ); |
---|
| 633 | |
---|
[163] | 634 | $nodes[$host] = $my_node; |
---|
[111] | 635 | } |
---|
| 636 | } |
---|
[103] | 637 | } |
---|
| 638 | } |
---|
[114] | 639 | $this->jobs = $jobs; |
---|
[163] | 640 | //print_r( $nodes ); |
---|
| 641 | $this->nodes = $nodes; |
---|
[200] | 642 | //print_r( $this->nodes ); |
---|
[103] | 643 | } |
---|
| 644 | |
---|
| 645 | function stopElement( $parser, $name ) { |
---|
| 646 | } |
---|
[105] | 647 | |
---|
| 648 | function printInfo() { |
---|
| 649 | |
---|
| 650 | $jobs = &$this->jobs; |
---|
| 651 | |
---|
| 652 | printf( "---jobs---\n" ); |
---|
| 653 | |
---|
| 654 | foreach( $jobs as $jobid => $job ) { |
---|
| 655 | |
---|
| 656 | printf( "job %s\n", $jobid ); |
---|
| 657 | |
---|
| 658 | if( isset( $job[nodes] ) ) { |
---|
| 659 | |
---|
| 660 | foreach( $job[nodes] as $node ) { |
---|
| 661 | |
---|
| 662 | $mynode = $this->nodes[$node]; |
---|
| 663 | $hostname = $mynode->getHostname(); |
---|
| 664 | $location = $mynode->getLocation(); |
---|
| 665 | |
---|
| 666 | printf( "\t- node %s\tlocation %s\n", $hostname, $location ); |
---|
| 667 | //$this->nodes[$hostname]->setLocation( "hier draait job ".$jobid ); |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | |
---|
| 672 | printf( "---nodes---\n" ); |
---|
| 673 | |
---|
| 674 | $nodes = &$this->nodes; |
---|
| 675 | |
---|
| 676 | foreach( $nodes as $node ) { |
---|
| 677 | |
---|
| 678 | $hostname = $node->getHostname(); |
---|
| 679 | $location = $node->getLocation(); |
---|
| 680 | $jobs = implode( ' ', $node->getJobs() ); |
---|
| 681 | printf( "* node %s\tlocation %s\tjobs %s\n", $hostname, $location, $jobs ); |
---|
| 682 | } |
---|
| 683 | } |
---|
[106] | 684 | |
---|
| 685 | function getNodes() { |
---|
[163] | 686 | //print_r( $this->nodes ); |
---|
[106] | 687 | return $this->nodes; |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | function getJobs() { |
---|
| 691 | return $this->jobs; |
---|
| 692 | } |
---|
[114] | 693 | |
---|
| 694 | function getHeartbeat() { |
---|
| 695 | return $this->heartbeat['time']; |
---|
| 696 | } |
---|
[103] | 697 | } |
---|
| 698 | |
---|
[107] | 699 | class NodeImage { |
---|
[102] | 700 | |
---|
[122] | 701 | var $image, $x, $y, $hostname, $jobs, $tasks, $showinfo; |
---|
[102] | 702 | |
---|
[111] | 703 | function NodeImage( $hostname ) { |
---|
[102] | 704 | |
---|
[111] | 705 | $this->jobs = array(); |
---|
| 706 | //$this->image = $image; |
---|
| 707 | //$this->x = $x; |
---|
| 708 | //$this->y = $y; |
---|
| 709 | $this->tasks = 0; |
---|
[110] | 710 | $this->hostname = $hostname; |
---|
[111] | 711 | $this->cpus = $this->determineCpus(); |
---|
[122] | 712 | $this->showinfo = 1; |
---|
[102] | 713 | } |
---|
| 714 | |
---|
[111] | 715 | function addJob( $jobid, $cpus ) { |
---|
| 716 | $jobs = &$this->jobs; |
---|
| 717 | |
---|
| 718 | $jobs[] = $jobid; |
---|
| 719 | $this->jobs = $jobs; |
---|
| 720 | |
---|
| 721 | $this->addTask( $cpus ); |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | function hasJob( $jobid ) { |
---|
| 725 | |
---|
| 726 | $jobfound = 0; |
---|
| 727 | |
---|
| 728 | if( count( $this->jobs ) > 0 ) |
---|
| 729 | foreach( $this->jobs as $job ) |
---|
| 730 | |
---|
| 731 | if( $job == $jobid ) |
---|
| 732 | $jobfound = 1; |
---|
| 733 | |
---|
| 734 | return $jobfound; |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | function addTask( $cpus ) { |
---|
| 738 | |
---|
| 739 | $this->tasks = $this->tasks + $cpus; |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | function setImage( $image ) { |
---|
| 743 | |
---|
| 744 | $this->image = $image; |
---|
| 745 | } |
---|
| 746 | |
---|
[106] | 747 | function setCoords( $x, $y ) { |
---|
[107] | 748 | |
---|
[106] | 749 | $this->x = $x; |
---|
| 750 | $this->y = $y; |
---|
| 751 | } |
---|
| 752 | |
---|
[102] | 753 | function colorHex( $color ) { |
---|
| 754 | |
---|
[109] | 755 | $my_color = imageColorAllocate( $this->image, hexdec( substr( $color, 0, 2 )), hexdec( substr( $color, 2, 2 )), hexdec( substr( $color, 4, 2 )) ); |
---|
[102] | 756 | |
---|
| 757 | return $my_color; |
---|
| 758 | } |
---|
| 759 | |
---|
[106] | 760 | function setLoad( $load ) { |
---|
| 761 | $this->load = $load; |
---|
| 762 | } |
---|
| 763 | |
---|
[108] | 764 | function setHostname( $hostname ) { |
---|
| 765 | $this->hostname = $hostname; |
---|
| 766 | } |
---|
| 767 | |
---|
[122] | 768 | function getHostname() { |
---|
| 769 | return $this->hostname; |
---|
| 770 | } |
---|
| 771 | |
---|
[114] | 772 | function getJobs() { |
---|
| 773 | return $this->jobs; |
---|
| 774 | } |
---|
| 775 | |
---|
[122] | 776 | function setShowinfo( $showinfo ) { |
---|
| 777 | $this->showinfo = $showinfo; |
---|
| 778 | } |
---|
| 779 | |
---|
[111] | 780 | function draw() { |
---|
[106] | 781 | |
---|
[122] | 782 | $this->drawSmall(); |
---|
| 783 | } |
---|
[110] | 784 | |
---|
[122] | 785 | function drawBig() { |
---|
[111] | 786 | |
---|
[122] | 787 | } |
---|
[106] | 788 | |
---|
[122] | 789 | function drawSmall() { |
---|
[106] | 790 | |
---|
[122] | 791 | global $SMALL_CLUSTERIMAGE_NODEWIDTH; |
---|
| 792 | global $JOB_NODE_MARKING; |
---|
[102] | 793 | |
---|
[122] | 794 | $black_color = imageColorAllocate( $this->image, 0, 0, 0 ); |
---|
[110] | 795 | $size = $SMALL_CLUSTERIMAGE_NODEWIDTH; |
---|
[107] | 796 | |
---|
[110] | 797 | imageFilledRectangle( $this->image, $this->x, $this->y, $this->x+($size), $this->y+($size), $black_color ); |
---|
| 798 | |
---|
[122] | 799 | if( $this->showinfo) { |
---|
| 800 | |
---|
| 801 | $this->load = $this->determineLoad(); |
---|
[111] | 802 | |
---|
[122] | 803 | if( !isset( $this->image ) or !isset( $this->x ) or !isset( $this->y ) ) { |
---|
| 804 | printf( "aborting\n" ); |
---|
| 805 | printf( "x %d y %d load %f\n", $this->x, $this->y, $load ); |
---|
| 806 | return; |
---|
| 807 | } |
---|
[111] | 808 | |
---|
| 809 | |
---|
[122] | 810 | // Convert Ganglias Hexadecimal load color to a Decimal one |
---|
| 811 | // |
---|
| 812 | $load = $this->determineLoad(); |
---|
| 813 | $usecolor = $this->colorHex( load_color($load) ); |
---|
| 814 | imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); |
---|
| 815 | if( count( $this->jobs ) > 0 ) |
---|
| 816 | imageString( $this->image, 1, $this->x+(($size/2)-2), $this->y+(($size/2)-3), $JOB_NODE_MARKING, $black_color ); |
---|
[111] | 817 | |
---|
[122] | 818 | } else { |
---|
[111] | 819 | |
---|
[122] | 820 | // White |
---|
| 821 | $usecolor = imageColorAllocate( $this->image, 255, 255, 255 ); |
---|
| 822 | imageFilledRectangle( $this->image, $this->x+1, $this->y+1, $this->x+($size-1), $this->y+($size-1), $usecolor ); |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | |
---|
[102] | 826 | } |
---|
| 827 | |
---|
[111] | 828 | function determineCpus() { |
---|
[102] | 829 | |
---|
[108] | 830 | global $metrics; |
---|
| 831 | |
---|
| 832 | $cpus = $metrics[$this->hostname][cpu_num][VAL]; |
---|
[107] | 833 | if (!$cpus) $cpus=1; |
---|
[111] | 834 | |
---|
| 835 | return $cpus; |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | function determineLoad() { |
---|
| 839 | |
---|
| 840 | global $metrics; |
---|
| 841 | |
---|
[108] | 842 | $load_one = $metrics[$this->hostname][load_one][VAL]; |
---|
[111] | 843 | $load = ((float) $load_one)/$this->cpus; |
---|
[102] | 844 | |
---|
[111] | 845 | return $load; |
---|
[106] | 846 | } |
---|
| 847 | } |
---|
| 848 | |
---|
[107] | 849 | class ClusterImage { |
---|
[106] | 850 | |
---|
[111] | 851 | var $dataget, $image, $clustername; |
---|
[124] | 852 | var $filtername, $filters; |
---|
[106] | 853 | |
---|
[122] | 854 | function ClusterImage( $clustername ) { |
---|
[114] | 855 | |
---|
[163] | 856 | //printf( "image cluster = %s\n", $clustername ); |
---|
| 857 | $this->dataget = new DataGatherer( $clustername ); |
---|
[111] | 858 | $this->clustername = $clustername; |
---|
[124] | 859 | $this->filters = array(); |
---|
[106] | 860 | } |
---|
| 861 | |
---|
[122] | 862 | function setFilter( $filtername, $filtervalue ) { |
---|
| 863 | |
---|
[124] | 864 | //printf("filter %s = %s\n", $filtername, $filtervalue ); |
---|
[122] | 865 | //printf( "filter set to %s = %s\n", $filtername, $filtervalue ); |
---|
[124] | 866 | $this->filters[$filtername] = $filtervalue; |
---|
| 867 | //print_r($this->filters); |
---|
[122] | 868 | } |
---|
| 869 | |
---|
| 870 | function filterNodes( $jobs, $nodes ) { |
---|
| 871 | |
---|
| 872 | $filtered_nodes = array(); |
---|
| 873 | |
---|
| 874 | foreach( $nodes as $node ) { |
---|
| 875 | |
---|
| 876 | $hostname = $node->getHostname(); |
---|
| 877 | |
---|
[124] | 878 | $addhost = 1; |
---|
[122] | 879 | |
---|
[124] | 880 | if( count( $this->filters ) > 0 ) { |
---|
| 881 | |
---|
| 882 | $mynjobs = $node->getJobs(); |
---|
| 883 | |
---|
| 884 | if( count( $mynjobs ) > 0 ) { |
---|
| 885 | |
---|
| 886 | foreach( $mynjobs as $myjob ) { |
---|
| 887 | |
---|
| 888 | foreach( $this->filters as $filtername => $filtervalue ) { |
---|
| 889 | |
---|
| 890 | //printf("filter bla %s = %s\n", $filtername,$filtervalue ); |
---|
| 891 | |
---|
| 892 | if( $filtername!=null && $filtername!='' ) { |
---|
| 893 | |
---|
| 894 | if( $filtername == 'jobid' && !$node->hasJob( $filtervalue) ) { |
---|
| 895 | $addhost = 0; |
---|
| 896 | //printf("host %s has no job %s\n", $hostname, $filtervalue); |
---|
| 897 | } else if( $filtername != 'jobid' ) { |
---|
| 898 | //printf("myjob is %s\n", $myjob ); |
---|
| 899 | if( $jobs[$myjob][$filtername] != $filtervalue ) { |
---|
| 900 | //printf("host %s has no job with %s=%s\n", $hostname, $filtername, $filtervalue); |
---|
| 901 | $addhost = 0; |
---|
| 902 | } |
---|
| 903 | } |
---|
| 904 | } |
---|
| 905 | } |
---|
| 906 | } |
---|
| 907 | } else |
---|
| 908 | $addhost = 0; |
---|
| 909 | } |
---|
| 910 | |
---|
| 911 | if( $addhost ) |
---|
[122] | 912 | $filtered_nodes[] = $hostname; |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | return $filtered_nodes; |
---|
| 916 | } |
---|
| 917 | |
---|
[106] | 918 | function draw() { |
---|
[110] | 919 | |
---|
[124] | 920 | //printf("stopt met uitvoer"); |
---|
| 921 | //return; |
---|
| 922 | |
---|
[110] | 923 | global $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH; |
---|
| 924 | |
---|
[107] | 925 | $mydatag = $this->dataget; |
---|
[106] | 926 | $mydatag->parseXML(); |
---|
| 927 | |
---|
[110] | 928 | //$max_width = 250; |
---|
| 929 | //$node_width = 11; |
---|
[106] | 930 | |
---|
[110] | 931 | $max_width = $SMALL_CLUSTERIMAGE_MAXWIDTH; |
---|
| 932 | $node_width = $SMALL_CLUSTERIMAGE_NODEWIDTH; |
---|
| 933 | |
---|
| 934 | //printf( "cmaxw %s nmaxw %s", $SMALL_CLUSTERIMAGE_MAXWIDTH, $SMALL_CLUSTERIMAGE_NODEWIDTH ); |
---|
| 935 | |
---|
[106] | 936 | $nodes = $mydatag->getNodes(); |
---|
[111] | 937 | $nodes_hosts = array_keys( $nodes ); |
---|
[106] | 938 | |
---|
| 939 | $nodes_nr = count( $nodes ); |
---|
| 940 | |
---|
| 941 | $nodes_size = $nodes_nr*$node_width; |
---|
| 942 | $node_rows = 0; |
---|
| 943 | |
---|
| 944 | if( $nodes_size > $max_width ) { |
---|
[107] | 945 | $nodes_per_row = ( (int) ($max_width/$node_width) ); |
---|
[106] | 946 | } else { |
---|
| 947 | $nodes_per_row = $nodes_size; |
---|
| 948 | $node_rows = 1; |
---|
| 949 | } |
---|
| 950 | |
---|
| 951 | if( $nodes_per_row < $nodes_nr ) { |
---|
[107] | 952 | $node_rows = ( (int) ($nodes_nr/$nodes_per_row) ); |
---|
| 953 | $node_rest = fmod( $nodes_nr, $nodes_per_row ); |
---|
| 954 | //printf( "nodesnr %d noderest %f\n", $nodes_nr, $node_rest ); |
---|
| 955 | if( $node_rest > 0 ) { |
---|
[106] | 956 | $node_rows++; |
---|
[107] | 957 | //printf( "noderows %d\n", $node_rows ); |
---|
[106] | 958 | } |
---|
| 959 | } |
---|
| 960 | |
---|
[107] | 961 | //printf( "imagecreate: %dx%d", ($nodes_per_row*$node_width), ($node_rows*$node_width) ); |
---|
[171] | 962 | //$image = imageCreateTrueColor( ($nodes_per_row*$node_width)+1, ($node_rows*$node_width)+1 ); |
---|
| 963 | $image = imageCreateTrueColor( $max_width, ($node_rows*$node_width)+1 ); |
---|
[107] | 964 | $colorwhite = imageColorAllocate( $image, 255, 255, 255 ); |
---|
| 965 | imageFill( $image, 0, 0, $colorwhite ); |
---|
[106] | 966 | |
---|
[122] | 967 | $jobs = $mydatag->getJobs(); |
---|
| 968 | //printf("filtername = %s\n", $filtername ); |
---|
| 969 | $filtered_nodes = $this->filterNodes( $jobs, $nodes ); |
---|
| 970 | |
---|
| 971 | //print_r($filtered_nodes); |
---|
| 972 | |
---|
[106] | 973 | for( $n = 0; $n < $node_rows; $n++ ) { |
---|
| 974 | |
---|
| 975 | for( $m = 0; $m < $nodes_per_row; $m++ ) { |
---|
[107] | 976 | |
---|
| 977 | $x = ($m * $node_width); |
---|
| 978 | $y = ($n * $node_width); |
---|
| 979 | |
---|
[109] | 980 | $cur_node = ($n * $nodes_per_row) + ($m); |
---|
[111] | 981 | $host = $nodes_hosts[$cur_node]; |
---|
[107] | 982 | |
---|
[122] | 983 | |
---|
[111] | 984 | if( isset( $nodes[$host] ) ) { |
---|
| 985 | |
---|
| 986 | $nodes[$host]->setCoords( $x, $y ); |
---|
| 987 | $nodes[$host]->setImage( $image ); |
---|
[122] | 988 | |
---|
| 989 | if( !in_array( $host, $filtered_nodes ) ) |
---|
| 990 | $nodes[$host]->setShowinfo( 0 ); |
---|
| 991 | |
---|
[111] | 992 | $nodes[$host]->draw(); |
---|
| 993 | } |
---|
[106] | 994 | } |
---|
| 995 | } |
---|
| 996 | |
---|
[103] | 997 | header( 'Content-type: image/png' ); |
---|
[106] | 998 | imagePNG( $image ); |
---|
| 999 | imageDestroy( $image ); |
---|
[102] | 1000 | } |
---|
| 1001 | } |
---|
| 1002 | |
---|
[106] | 1003 | //$my_data = new DataGatherer(); |
---|
| 1004 | //$my_data->parseXML(); |
---|
| 1005 | //$my_data->printInfo(); |
---|
| 1006 | |
---|
[112] | 1007 | //$ic = new ClusterImage( "LISA Cluster" ); |
---|
| 1008 | //$ic->draw(); |
---|
[102] | 1009 | ?> |
---|