[113] | 1 | <?php |
---|
[225] | 2 | /* |
---|
| 3 | * |
---|
| 4 | * This file is part of Jobmonarch |
---|
| 5 | * |
---|
[732] | 6 | * Copyright (C) 2006-2013 Ramon Bastiaans |
---|
[225] | 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: overview.php 828 2013-04-12 13:46:51Z ramonb $ |
---|
[225] | 23 | */ |
---|
| 24 | |
---|
[753] | 25 | global $GANGLIA_PATH, $clustername, $tpl_data, $filter, $cluster, $get_metric_string, $cluster_url, $sh; |
---|
[299] | 26 | global $hosts_up, $m, $start, $end, $filterorder, $COLUMN_REQUESTED_MEMORY, $COLUMN_QUEUED, $COLUMN_NODES, $hostname, $piefilter; |
---|
[409] | 27 | global $longtitle, $title, $range; |
---|
[114] | 28 | |
---|
[753] | 29 | include_once "./dwoo/dwooAutoload.php"; |
---|
[116] | 30 | |
---|
[753] | 31 | global $dwoo; |
---|
| 32 | |
---|
| 33 | $tpl = new Dwoo_Template_File("templates/overview.tpl"); |
---|
[822] | 34 | $tpl_data = array(); |
---|
[753] | 35 | |
---|
[822] | 36 | $tpl_data[ "clustername"]= $clustername ; |
---|
[753] | 37 | |
---|
[206] | 38 | if( $JOB_ARCHIVE ) |
---|
[328] | 39 | { |
---|
[822] | 40 | $tpl_data[ "cluster_url"]= rawurlencode($clustername) ; |
---|
[328] | 41 | } |
---|
[129] | 42 | |
---|
[738] | 43 | $rjqj_start = null; |
---|
[732] | 44 | $ds = new DataSource(); |
---|
| 45 | $myxml_data = $ds->getData(); |
---|
[328] | 46 | |
---|
[764] | 47 | //print_r( $myxml_data ); |
---|
| 48 | |
---|
[732] | 49 | $data_gatherer = new DataGatherer( $clustername ); |
---|
[326] | 50 | $data_gatherer->parseXML( $myxml_data ); |
---|
[117] | 51 | |
---|
[732] | 52 | $heartbeat = $data_gatherer->getHeartbeat(); |
---|
| 53 | $jobs = $data_gatherer->getJobs(); |
---|
| 54 | $gnodes = $data_gatherer->getNodes(); |
---|
| 55 | $cpus = $data_gatherer->getCpus(); |
---|
| 56 | $use_fqdn = $data_gatherer->getUsingFQDN(); |
---|
[114] | 57 | |
---|
[743] | 58 | //print_r( $gnodes ); |
---|
| 59 | |
---|
[328] | 60 | function setupFilterSettings() |
---|
| 61 | { |
---|
| 62 | |
---|
[764] | 63 | global $tpl_data, $filter, $clustername, $piefilter, $data_gatherer, $myxml_data, $filterorder, $_SESSION, $data_gatherer; |
---|
| 64 | global $jobs, $gnodes; |
---|
[122] | 65 | |
---|
[719] | 66 | $filter_image_url = ""; |
---|
[119] | 67 | |
---|
[719] | 68 | foreach( $filter as $filtername => $filtervalue ) |
---|
| 69 | { |
---|
[822] | 70 | $tpl_data[ $filtername ] = $filtervalue; |
---|
[328] | 71 | |
---|
[719] | 72 | $filter_image_url .= "&$filtername=$filtervalue"; |
---|
| 73 | } |
---|
[114] | 74 | |
---|
[719] | 75 | session_start(); |
---|
[326] | 76 | |
---|
[719] | 77 | unset( $_SESSION["data"] ); |
---|
[732] | 78 | $_SESSION["data"] = &$myxml_data; |
---|
[328] | 79 | |
---|
[732] | 80 | $ic = new ClusterImage( $myxml_data, $clustername ); |
---|
[328] | 81 | |
---|
[764] | 82 | $ic->setJobs( $jobs ); |
---|
| 83 | $ic->setNodes( $gnodes ); |
---|
[719] | 84 | $ic->setBig(); |
---|
| 85 | $ic->setNoimage(); |
---|
| 86 | $ic->draw(); |
---|
[326] | 87 | |
---|
[822] | 88 | $tpl_data[ "clusterimage"]= "./image.php?". session_name() . "=" . session_id() ."&c=".rawurlencode($clustername)."&j_view=big-clusterimage".$filter_image_url; |
---|
[326] | 89 | |
---|
[822] | 90 | $tpl_data[ "node_clustermap"]= "yes"; |
---|
| 91 | $tpl_data[ "node_area_map"]= $ic->getImagemapArea(); |
---|
[326] | 92 | |
---|
[822] | 93 | $tpl_data[ "order"]= $filterorder; |
---|
[263] | 94 | } |
---|
[122] | 95 | |
---|
[328] | 96 | function timeToEpoch( $time ) |
---|
| 97 | { |
---|
[732] | 98 | $time_fields = explode( ':', $time ); |
---|
[120] | 99 | |
---|
[719] | 100 | if( count( $time_fields ) == 3 ) |
---|
| 101 | { |
---|
[732] | 102 | $hours = $time_fields[0]; |
---|
| 103 | $minutes = $time_fields[1]; |
---|
| 104 | $seconds = $time_fields[2]; |
---|
[120] | 105 | |
---|
[719] | 106 | } |
---|
| 107 | else if( count( $time_fields ) == 2 ) |
---|
| 108 | { |
---|
[732] | 109 | $hours = 0; |
---|
| 110 | $minutes = $time_fields[0]; |
---|
| 111 | $seconds = $time_fields[1]; |
---|
[120] | 112 | |
---|
[719] | 113 | } |
---|
| 114 | else if( count( $time_fields ) == 1 ) |
---|
| 115 | { |
---|
[732] | 116 | $hours = 0; |
---|
| 117 | $minutes = 0; |
---|
| 118 | $seconds = $time_fields[0]; |
---|
[719] | 119 | } |
---|
[128] | 120 | |
---|
[732] | 121 | $myepoch = intval( $seconds + (intval( $minutes * 60 )) + (intval( $hours * 3600 )) ); |
---|
[128] | 122 | |
---|
[719] | 123 | return $myepoch; |
---|
[120] | 124 | } |
---|
| 125 | |
---|
[328] | 126 | function colorRed( $color ) |
---|
| 127 | { |
---|
[719] | 128 | return substr( $color, 0, 2 ); |
---|
[114] | 129 | } |
---|
[328] | 130 | |
---|
| 131 | function colorGreen( $color ) |
---|
| 132 | { |
---|
[719] | 133 | return substr( $color, 2, 2 ); |
---|
[114] | 134 | } |
---|
[328] | 135 | |
---|
| 136 | function colorBlue( $color ) |
---|
| 137 | { |
---|
[719] | 138 | return substr( $color, 4, 2 ); |
---|
[114] | 139 | } |
---|
| 140 | |
---|
[328] | 141 | function colorDiffer( $first, $second ) |
---|
| 142 | { |
---|
[719] | 143 | // Make sure these two colors differ atleast 50 R/G/B |
---|
| 144 | $min_diff = 50; |
---|
[114] | 145 | |
---|
[732] | 146 | $c1r = hexDec( colorRed( $first ) ); |
---|
| 147 | $c1g = hexDec( colorGreen( $first ) ); |
---|
| 148 | $c1b = hexDec( colorBlue( $first ) ); |
---|
[114] | 149 | |
---|
[732] | 150 | $c2r = hexDec( colorRed( $second ) ); |
---|
| 151 | $c2g = hexDec( colorGreen( $second ) ); |
---|
| 152 | $c2b = hexDec( colorBlue( $second ) ); |
---|
[114] | 153 | |
---|
[732] | 154 | $rdiff = ($c1r >= $c2r) ? $c1r - $c2r : $c2r - $c1r; |
---|
| 155 | $gdiff = ($c1g >= $c2g) ? $c1g - $c2g : $c2g - $c1g; |
---|
| 156 | $bdiff = ($c1b >= $c2b) ? $c1b - $c2b : $c2b - $c1b; |
---|
[114] | 157 | |
---|
[719] | 158 | if( $rdiff >= $min_diff or $gdiff >= $min_diff or $bdiff >= $min_diff ) |
---|
| 159 | { |
---|
| 160 | return TRUE; |
---|
[328] | 161 | |
---|
[719] | 162 | } |
---|
| 163 | else |
---|
| 164 | { |
---|
| 165 | return FALSE; |
---|
| 166 | } |
---|
[114] | 167 | } |
---|
| 168 | |
---|
[328] | 169 | function randomColor( $known_colors ) |
---|
| 170 | { |
---|
[719] | 171 | // White (000000) would be invisible |
---|
[732] | 172 | $start = "004E00"; |
---|
[719] | 173 | |
---|
[732] | 174 | $start_red = colorRed( $start ); |
---|
| 175 | $start_green = colorGreen( $start ); |
---|
| 176 | $start_blue = colorBlue( $start ); |
---|
[719] | 177 | |
---|
[732] | 178 | $end = "FFFFFF"; |
---|
[114] | 179 | |
---|
[732] | 180 | $end_red = colorRed( $end ); |
---|
| 181 | $end_green = colorGreen( $end ); |
---|
[719] | 182 | $end_blue = colorBlue( $end ); |
---|
[114] | 183 | |
---|
[732] | 184 | $change_color= TRUE; |
---|
[114] | 185 | |
---|
[719] | 186 | while( $change_color ) |
---|
| 187 | { |
---|
[732] | 188 | $change_color= FALSE; |
---|
[114] | 189 | |
---|
[719] | 190 | $new_red = rand( hexDec( $start_red ), hexDec( $end_red ) ); |
---|
[732] | 191 | $new_green = rand( hexDec( $start_green ), hexDec( $end_green ) ); |
---|
| 192 | $new_blue = rand( hexDec( $start_blue ), hexDec( $end_blue ) ); |
---|
[114] | 193 | |
---|
[719] | 194 | $new = decHex( $new_red ) . decHex( $new_green ) . decHex( $new_blue ); |
---|
[114] | 195 | |
---|
[719] | 196 | foreach( $known_colors as $old ) |
---|
| 197 | { |
---|
| 198 | if( !colorDiffer( $new, $old ) ) |
---|
| 199 | { |
---|
| 200 | $change_color = TRUE; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | } |
---|
[114] | 204 | |
---|
[719] | 205 | // Whoa! Actually found a good color ;) |
---|
| 206 | return $new; |
---|
[114] | 207 | } |
---|
| 208 | |
---|
[328] | 209 | function sortJobs( $jobs, $sortby, $sortorder ) |
---|
| 210 | { |
---|
[719] | 211 | $sorted = array(); |
---|
[114] | 212 | |
---|
[719] | 213 | $cmp = create_function( '$a, $b', |
---|
| 214 | "global \$sortby, \$sortorder;". |
---|
[116] | 215 | |
---|
[719] | 216 | "if( \$a == \$b ) return 0;". |
---|
[116] | 217 | |
---|
[719] | 218 | "if (\$sortorder==\"desc\")". |
---|
[818] | 219 | "return ( \$a > \$b ) ? 1 : -1;". |
---|
[719] | 220 | "else if (\$sortorder==\"asc\")". |
---|
[818] | 221 | "return ( \$a < \$b ) ? 1 : -1;" ); |
---|
[117] | 222 | |
---|
[719] | 223 | if( isset( $jobs ) && count( $jobs ) > 0 ) |
---|
| 224 | { |
---|
| 225 | foreach( $jobs as $jobid => $jobattrs ) |
---|
| 226 | { |
---|
[732] | 227 | $state = $jobattrs['status']; |
---|
| 228 | $owner = $jobattrs['owner']; |
---|
| 229 | $queue = $jobattrs['queue']; |
---|
| 230 | $name = $jobattrs['name']; |
---|
| 231 | $req_cpu = $jobattrs['requested_time']; |
---|
| 232 | $req_memory= $jobattrs['requested_memory']; |
---|
[117] | 233 | |
---|
[719] | 234 | if( $state == 'R' ) |
---|
| 235 | { |
---|
| 236 | $nodes = count( $jobattrs['nodes'] ); |
---|
| 237 | } |
---|
| 238 | else |
---|
| 239 | { |
---|
| 240 | $nodes = $jobattrs['nodes']; |
---|
| 241 | } |
---|
[117] | 242 | |
---|
[719] | 243 | $ppn = (int) $jobattrs['ppn'] ? $jobattrs['ppn'] : 1; |
---|
[731] | 244 | $cpus = $nodes * $ppn; |
---|
| 245 | $queued_time = (int) $jobattrs['queued_timestamp']; |
---|
| 246 | $start_time = (int) $jobattrs['start_timestamp']; |
---|
| 247 | $runningtime = $report_time - $start_time; |
---|
[117] | 248 | |
---|
[719] | 249 | switch( $sortby ) |
---|
| 250 | { |
---|
| 251 | case "id": |
---|
| 252 | $sorted[$jobid] = $jobid; |
---|
| 253 | break; |
---|
[117] | 254 | |
---|
[719] | 255 | case "state": |
---|
| 256 | $sorted[$jobid] = $state; |
---|
| 257 | break; |
---|
[117] | 258 | |
---|
[719] | 259 | case "owner": |
---|
| 260 | $sorted[$jobid] = $owner; |
---|
| 261 | break; |
---|
[117] | 262 | |
---|
[719] | 263 | case "queue": |
---|
| 264 | $sorted[$jobid] = $queue; |
---|
| 265 | break; |
---|
[117] | 266 | |
---|
[719] | 267 | case "name": |
---|
| 268 | $sorted[$jobid] = $name; |
---|
| 269 | break; |
---|
[117] | 270 | |
---|
[719] | 271 | case "req_cpu": |
---|
| 272 | $sorted[$jobid] = timeToEpoch( $req_cpu ); |
---|
| 273 | break; |
---|
[117] | 274 | |
---|
[719] | 275 | case "req_mem": |
---|
| 276 | $sorted[$jobid] = $req_memory; |
---|
| 277 | break; |
---|
[117] | 278 | |
---|
[719] | 279 | case "nodes": |
---|
| 280 | $sorted[$jobid] = $nodes; |
---|
| 281 | break; |
---|
[117] | 282 | |
---|
[719] | 283 | case "cpus": |
---|
| 284 | $sorted[$jobid] = $cpus; |
---|
| 285 | break; |
---|
[245] | 286 | |
---|
[719] | 287 | case "queued": |
---|
| 288 | $sorted[$jobid] = $queued_time; |
---|
| 289 | break; |
---|
[117] | 290 | |
---|
[719] | 291 | case "start": |
---|
| 292 | $sorted[$jobid] = $start_time; |
---|
| 293 | break; |
---|
[117] | 294 | |
---|
[719] | 295 | case "runningtime": |
---|
| 296 | $sorted[$jobid] = $runningtime; |
---|
| 297 | break; |
---|
[117] | 298 | |
---|
[719] | 299 | default: |
---|
| 300 | break; |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | } |
---|
[301] | 304 | |
---|
[719] | 305 | if( $sortorder == "asc" ) |
---|
| 306 | { |
---|
[818] | 307 | asort( $sorted ); |
---|
[719] | 308 | } |
---|
| 309 | else if( $sortorder == "desc" ) |
---|
| 310 | { |
---|
[818] | 311 | arsort( $sorted ); |
---|
[719] | 312 | } |
---|
[117] | 313 | |
---|
[719] | 314 | return $sorted; |
---|
[117] | 315 | } |
---|
| 316 | |
---|
[328] | 317 | function makeOverview() |
---|
| 318 | { |
---|
[753] | 319 | global $dwoo, $tpl, $tpl_data, $jobs, $nodes, $heartbeat, $clustername, $tpl_data; |
---|
[719] | 320 | global $sortorder, $sortby, $filter, $sh, $hc, $m, $range; |
---|
| 321 | global $cluster_url, $get_metric_string, $host_url, $metrics; |
---|
| 322 | global $start, $end, $reports, $gnodes, $default_showhosts; |
---|
| 323 | global $COLUMN_QUEUED, $COLUMN_REQUESTED_MEMORY, $COLUMN_NODES, $hostname; |
---|
[764] | 324 | global $cluster, $use_fqdn, $myxml_data, $data_gatherer; |
---|
[126] | 325 | |
---|
[719] | 326 | $metricname = $m; |
---|
[731] | 327 | if( isset($conf['default_metric']) and ($metricname =='') ) |
---|
| 328 | $metricname = $conf['default_metric']; |
---|
| 329 | else |
---|
| 330 | if( isset( $m ) ) |
---|
| 331 | $metricname = $m; |
---|
| 332 | else |
---|
| 333 | $metricname = "load_one"; |
---|
[328] | 334 | |
---|
[822] | 335 | $tpl_data["sortorder"]= $sortorder; |
---|
| 336 | $tpl_data["sortby"]= $sortby; |
---|
[117] | 337 | |
---|
[732] | 338 | $sorted_jobs = sortJobs( $jobs, $sortby, $sortorder ); |
---|
[117] | 339 | |
---|
[732] | 340 | $even = 1; |
---|
[118] | 341 | |
---|
[732] | 342 | $used_jobs = 0; |
---|
| 343 | $used_cpus = 0; |
---|
[719] | 344 | $used_nodes = 0; |
---|
[124] | 345 | |
---|
[732] | 346 | $queued_jobs = 0; |
---|
| 347 | $queued_nodes = 0; |
---|
| 348 | $queued_cpus = 0; |
---|
[208] | 349 | |
---|
[732] | 350 | $total_nodes = 0; |
---|
[719] | 351 | $total_cpus = 0; |
---|
| 352 | $total_jobs = 0; |
---|
[208] | 353 | |
---|
[719] | 354 | $all_used_nodes = array(); |
---|
[732] | 355 | $total_used_nodes = array(); |
---|
[124] | 356 | |
---|
[732] | 357 | $running_name_nodes = array(); |
---|
[208] | 358 | |
---|
[732] | 359 | $running_nodes = 0; |
---|
| 360 | $running_jobs = 0; |
---|
| 361 | $running_cpus = 0; |
---|
[208] | 362 | |
---|
[732] | 363 | $avail_nodes = count( $gnodes ); |
---|
[719] | 364 | $avail_cpus = cluster_sum("cpu_num", $metrics); |
---|
[135] | 365 | |
---|
[732] | 366 | $view_cpus = 0; |
---|
| 367 | $view_jobs = 0; |
---|
[719] | 368 | $view_nodes = 0; |
---|
[135] | 369 | |
---|
[732] | 370 | $all_nodes = 0; |
---|
| 371 | $all_jobs = 0; |
---|
| 372 | $all_cpus = 0; |
---|
[135] | 373 | |
---|
[732] | 374 | $view_name_nodes = array(); |
---|
[208] | 375 | |
---|
[719] | 376 | // Is the "requested memory" column enabled in the config |
---|
| 377 | // |
---|
| 378 | if( $COLUMN_REQUESTED_MEMORY ) |
---|
| 379 | { |
---|
[822] | 380 | $tpl_data[ "column_header_req_mem"]= "yes"; |
---|
[719] | 381 | } |
---|
[241] | 382 | |
---|
[719] | 383 | // Is the "nodes hostnames" column enabled in the config |
---|
| 384 | // |
---|
| 385 | if( $COLUMN_NODES ) |
---|
| 386 | { |
---|
[822] | 387 | $tpl_data[ "column_header_nodes"]= "yes"; |
---|
[719] | 388 | } |
---|
[299] | 389 | |
---|
[719] | 390 | // Is the "queued time" column enabled in the config |
---|
| 391 | // |
---|
| 392 | if( $COLUMN_QUEUED ) |
---|
| 393 | { |
---|
[822] | 394 | $tpl_data[ "column_header_queued"]= "yes" ; |
---|
[719] | 395 | } |
---|
[242] | 396 | |
---|
[732] | 397 | $last_displayed_job = null; |
---|
[263] | 398 | |
---|
[732] | 399 | $rjqj_host = null; |
---|
[406] | 400 | |
---|
[732] | 401 | $na_nodes = 0; |
---|
| 402 | $na_cpus = 0; |
---|
[512] | 403 | |
---|
[719] | 404 | foreach( $metrics as $bhost => $bmetric ) |
---|
| 405 | { |
---|
| 406 | foreach( $bmetric as $mname => $mval ) |
---|
| 407 | { |
---|
[726] | 408 | if( ( $mname == 'zplugin_monarch_rj' ) || ($mname == 'zplugin_monarch_qj') ) |
---|
[719] | 409 | { |
---|
[732] | 410 | $rjqj_host = $bhost; |
---|
[719] | 411 | } |
---|
| 412 | } |
---|
| 413 | } |
---|
[409] | 414 | |
---|
[719] | 415 | foreach( $gnodes as $ghost => $gnode ) |
---|
| 416 | { |
---|
| 417 | if( $gnode->isDown() || $gnode->isOffline() ) |
---|
| 418 | { |
---|
[732] | 419 | $na_nodes += 1; |
---|
| 420 | $na_cpus += $metrics[$ghost]['cpu_num']['VAL']; |
---|
[719] | 421 | } |
---|
| 422 | } |
---|
[516] | 423 | |
---|
[753] | 424 | $node_list = array(); |
---|
[409] | 425 | |
---|
[719] | 426 | foreach( $sorted_jobs as $jobid => $sortdec ) |
---|
| 427 | { |
---|
| 428 | $report_time = $jobs[$jobid]['reported']; |
---|
[117] | 429 | |
---|
[719] | 430 | if( $jobs[$jobid]['status'] == 'R' ) |
---|
| 431 | { |
---|
| 432 | $nodes = count( $jobs[$jobid]['nodes'] ); |
---|
| 433 | } |
---|
| 434 | else if( $jobs[$jobid]['status'] == 'Q' ) |
---|
| 435 | { |
---|
| 436 | $nodes = $jobs[$jobid]['nodes']; |
---|
| 437 | } |
---|
[208] | 438 | |
---|
[732] | 439 | $ppn = isset( $jobs[$jobid]['ppn'] ) ? $jobs[$jobid]['ppn'] : 1; |
---|
| 440 | $cpus = $nodes * $ppn; |
---|
[124] | 441 | |
---|
[719] | 442 | if( $report_time == $heartbeat ) |
---|
| 443 | { |
---|
| 444 | $display_job = 1; |
---|
[124] | 445 | |
---|
[719] | 446 | if( $jobs[$jobid]['status'] == 'R' ) |
---|
| 447 | { |
---|
| 448 | foreach( $jobs[$jobid]['nodes'] as $tempnode ) |
---|
| 449 | { |
---|
| 450 | $all_used_nodes[] = $tempnode; |
---|
| 451 | } |
---|
| 452 | } |
---|
[208] | 453 | |
---|
[719] | 454 | $used_cpus += $cpus; |
---|
[135] | 455 | |
---|
[719] | 456 | if( $jobs[$jobid]['status'] == 'R' ) |
---|
| 457 | { |
---|
| 458 | $running_cpus += $cpus; |
---|
[328] | 459 | |
---|
[719] | 460 | $running_jobs++; |
---|
[117] | 461 | |
---|
[719] | 462 | $found_node_job = 0; |
---|
[268] | 463 | |
---|
[719] | 464 | foreach( $jobs[$jobid]['nodes'] as $tempnode ) |
---|
| 465 | { |
---|
| 466 | $running_name_nodes[] = $tempnode; |
---|
[263] | 467 | |
---|
[719] | 468 | if( isset( $hostname ) && $hostname != '' ) |
---|
| 469 | { |
---|
| 470 | $domain_len = 0 - strlen( $jobs[$jobid]['domain'] ); |
---|
| 471 | $hostnode = $tempnode; |
---|
[328] | 472 | |
---|
[719] | 473 | if( $use_fqdn == 1) |
---|
| 474 | { |
---|
| 475 | if( substr( $hostnode, $domain_len ) != $jobs[$jobid]['domain'] ) |
---|
| 476 | { |
---|
| 477 | $hostnode = $hostnode. '.'. $jobs[$jobid]['domain']; |
---|
| 478 | } |
---|
| 479 | } |
---|
[263] | 480 | |
---|
[719] | 481 | if( $hostname == $hostnode ) |
---|
| 482 | { |
---|
| 483 | $found_node_job = 1; |
---|
| 484 | $display_job = 1; |
---|
| 485 | } |
---|
| 486 | else if( !$found_node_job ) |
---|
| 487 | { |
---|
| 488 | $display_job = 0; |
---|
| 489 | } |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
[117] | 493 | |
---|
[719] | 494 | if( $jobs[$jobid]['status'] == 'Q' ) |
---|
| 495 | { |
---|
| 496 | if( isset( $hostname ) && $hostname != '' ) |
---|
| 497 | { |
---|
| 498 | $display_job = 0; |
---|
| 499 | } |
---|
[263] | 500 | |
---|
[732] | 501 | $queued_cpus += $cpus; |
---|
| 502 | $queued_nodes += $nodes; |
---|
[328] | 503 | |
---|
[719] | 504 | $queued_jobs++; |
---|
| 505 | } |
---|
[208] | 506 | |
---|
[719] | 507 | foreach( $filter as $filtername=>$filtervalue ) |
---|
| 508 | { |
---|
| 509 | if( $filtername == 'id' && $jobid != $filtervalue ) |
---|
| 510 | { |
---|
| 511 | $display_job = 0; |
---|
| 512 | } |
---|
| 513 | else if( $filtername == 'state' && $jobs[$jobid]['status'] != $filtervalue ) |
---|
| 514 | { |
---|
| 515 | $display_job = 0; |
---|
| 516 | } |
---|
| 517 | else if( $filtername == 'queue' && $jobs[$jobid]['queue'] != $filtervalue ) |
---|
| 518 | { |
---|
| 519 | $display_job = 0; |
---|
| 520 | } |
---|
| 521 | else if( $filtername == 'owner' && $jobs[$jobid]['owner'] != $filtervalue ) |
---|
| 522 | { |
---|
| 523 | $display_job = 0; |
---|
| 524 | } |
---|
| 525 | } |
---|
[118] | 526 | |
---|
[753] | 527 | |
---|
[719] | 528 | if( $display_job ) |
---|
| 529 | { |
---|
[816] | 530 | unset( $job_loop ); |
---|
[753] | 531 | $job_loop = array(); |
---|
| 532 | $job_loop["clustername"] = $clustername; |
---|
[263] | 533 | |
---|
[753] | 534 | $job_loop["id"] = $jobid; |
---|
| 535 | |
---|
[719] | 536 | $last_displayed_job = $jobid; |
---|
[263] | 537 | |
---|
[753] | 538 | $job_loop["state"] = $jobs[$jobid]['status']; |
---|
[240] | 539 | |
---|
[719] | 540 | $fullstate = ''; |
---|
[328] | 541 | |
---|
[719] | 542 | if( $jobs[$jobid]['status'] == 'R' ) |
---|
| 543 | { |
---|
| 544 | $fullstate = "Running"; |
---|
| 545 | } |
---|
| 546 | else if( $jobs[$jobid]['status'] == 'Q' ) |
---|
| 547 | { |
---|
| 548 | $fullstate = "Queued"; |
---|
| 549 | } |
---|
[240] | 550 | |
---|
[753] | 551 | $job_loop["fullstate"] = $fullstate; |
---|
[719] | 552 | |
---|
[753] | 553 | $job_loop["owner"] = $jobs[$jobid]['owner']; |
---|
| 554 | $job_loop["queue"] = $jobs[$jobid]['queue']; |
---|
[240] | 555 | |
---|
[719] | 556 | $fulljobname = $jobs[$jobid]['name']; |
---|
[753] | 557 | $shortjobname = ''; |
---|
[240] | 558 | |
---|
[753] | 559 | $job_loop["fulljobname"] = $fulljobname; |
---|
[240] | 560 | |
---|
[719] | 561 | $fulljobname_fields = explode( ' ', $fulljobname ); |
---|
[311] | 562 | |
---|
[719] | 563 | $capjobname = 0; |
---|
[311] | 564 | |
---|
[719] | 565 | if( strlen( $fulljobname_fields[0] ) > 10 ) |
---|
| 566 | { |
---|
| 567 | $capjobname = 1; |
---|
| 568 | } |
---|
[311] | 569 | |
---|
[719] | 570 | if( $capjobname ) |
---|
| 571 | { |
---|
[753] | 572 | $job_loop[ "jobname_hint_start" ] = "yes"; |
---|
[240] | 573 | |
---|
[719] | 574 | $shortjobname = substr( $fulljobname, 0, 10 ) . '..'; |
---|
| 575 | } |
---|
| 576 | else |
---|
| 577 | { |
---|
| 578 | $shortjobname = $fulljobname; |
---|
| 579 | } |
---|
| 580 | |
---|
[753] | 581 | $job_loop["name"] = $shortjobname; |
---|
[240] | 582 | |
---|
[719] | 583 | if( $capjobname ) |
---|
| 584 | { |
---|
[753] | 585 | $job_loop[ "jobname_hint_end" ] = "yes"; |
---|
[719] | 586 | } |
---|
[240] | 587 | |
---|
[719] | 588 | $domain = $jobs[$jobid]['domain']; |
---|
[135] | 589 | |
---|
[753] | 590 | $job_loop["req_cpu"] = makeTime( timeToEpoch( $jobs[$jobid]['requested_time'] ) ); |
---|
[328] | 591 | |
---|
[719] | 592 | if( $COLUMN_REQUESTED_MEMORY ) |
---|
| 593 | { |
---|
[753] | 594 | $job_loop[ "column_req_mem" ] = "yes"; |
---|
| 595 | $job_loop["req_memory"] = $jobs[$jobid]['requested_memory']; |
---|
[719] | 596 | } |
---|
[135] | 597 | |
---|
[299] | 598 | |
---|
[719] | 599 | if( $COLUMN_QUEUED ) |
---|
| 600 | { |
---|
[753] | 601 | $job_loop[ "column_queued" ] = "yes"; |
---|
| 602 | $job_loop["queued"] = makeDate( $jobs[$jobid]['queued_timestamp'] ); |
---|
[719] | 603 | } |
---|
| 604 | if( $COLUMN_NODES ) |
---|
| 605 | { |
---|
[753] | 606 | $job_loop[ "column_nodes" ] = "yes"; |
---|
| 607 | //echo "colum nodes"; |
---|
[719] | 608 | } |
---|
[242] | 609 | |
---|
[732] | 610 | $ppn = isset( $jobs[$jobid]['ppn'] ) ? $jobs[$jobid]['ppn'] : 1; |
---|
| 611 | $cpus = $nodes * $ppn; |
---|
[119] | 612 | |
---|
[753] | 613 | $job_loop["nodes"] = $nodes; |
---|
| 614 | $job_loop["cpus"] = $cpus; |
---|
[328] | 615 | |
---|
[732] | 616 | $start_time= (int) $jobs[$jobid]['start_timestamp']; |
---|
| 617 | $job_start = $start_time; |
---|
[328] | 618 | |
---|
[738] | 619 | |
---|
[732] | 620 | $view_cpus += $cpus; |
---|
[328] | 621 | |
---|
[719] | 622 | $view_jobs++; |
---|
[124] | 623 | |
---|
[719] | 624 | if( $jobs[$jobid]['status'] == 'R' ) |
---|
| 625 | { |
---|
[763] | 626 | $job_runningtime = $heartbeat - $start_time; |
---|
[738] | 627 | if( $rjqj_start == null ) |
---|
| 628 | { |
---|
[763] | 629 | $rjqj_start = intval( $start_time - (intval( $job_runningtime * 0.10 ) ) ); |
---|
[738] | 630 | } |
---|
| 631 | else if( $start_time < $rjqj_start ) |
---|
| 632 | { |
---|
[763] | 633 | $rjqj_start = intval( $start_time - (intval( $job_runningtime * 0.10 ) ) ); |
---|
[738] | 634 | } |
---|
| 635 | |
---|
[719] | 636 | foreach( $jobs[$jobid]['nodes'] as $tempnode ) |
---|
| 637 | { |
---|
| 638 | $view_name_nodes[] = $tempnode; |
---|
| 639 | } |
---|
[299] | 640 | |
---|
[719] | 641 | if( $COLUMN_NODES ) |
---|
| 642 | { |
---|
[753] | 643 | $job_loop[ "column_nodes" ] = "yes"; |
---|
[328] | 644 | |
---|
[719] | 645 | $mynodehosts = array(); |
---|
[328] | 646 | |
---|
[730] | 647 | foreach( $jobs[$jobid]['nodes'] as $shortnode ) |
---|
[719] | 648 | { |
---|
| 649 | if( $use_fqdn == 1) |
---|
| 650 | { |
---|
[732] | 651 | $mynode = $shortnode.".".$jobs[$jobid]['domain']; |
---|
[719] | 652 | } |
---|
[732] | 653 | $myhost_href = "./?c=".$clustername."&h=".$mynode; |
---|
| 654 | $mynodehosts[] = "<A HREF=\"".$myhost_href."\">".$shortnode."</A>"; |
---|
[719] | 655 | } |
---|
[328] | 656 | |
---|
[732] | 657 | $nodes_hostnames = implode( " ", $mynodehosts ); |
---|
[328] | 658 | |
---|
[753] | 659 | $job_loop["nodes_hostnames"] = $nodes_hostnames; |
---|
[719] | 660 | } |
---|
| 661 | } |
---|
| 662 | else if( $jobs[$jobid]['status'] == 'Q' ) |
---|
| 663 | { |
---|
| 664 | $view_nodes += (int) $jobs[$jobid]['nodes']; |
---|
| 665 | } |
---|
[135] | 666 | |
---|
[719] | 667 | if( $even ) |
---|
| 668 | { |
---|
[753] | 669 | $job_loop["nodeclass"] = "even"; |
---|
[119] | 670 | |
---|
[719] | 671 | $even = 0; |
---|
| 672 | } |
---|
| 673 | else |
---|
| 674 | { |
---|
[753] | 675 | $job_loop["nodeclass"] = "odd"; |
---|
[119] | 676 | |
---|
[719] | 677 | $even = 1; |
---|
| 678 | } |
---|
[119] | 679 | |
---|
[719] | 680 | if( $start_time ) |
---|
| 681 | { |
---|
[732] | 682 | $runningtime = makeTime( $report_time - $start_time ); |
---|
[719] | 683 | $job_runningtime = $heartbeat - $start_time; |
---|
[119] | 684 | |
---|
[753] | 685 | $job_loop["started"] = makeDate( $start_time ); |
---|
| 686 | $job_loop["runningtime"] = $runningtime; |
---|
[719] | 687 | } |
---|
[815] | 688 | $node_list[] = &$job_loop; |
---|
[719] | 689 | } |
---|
[822] | 690 | $tpl_data["node_list"]= &$node_list ; |
---|
[719] | 691 | } |
---|
| 692 | } |
---|
[763] | 693 | if( intval($view_jobs) == 1 and $start_time ) |
---|
| 694 | { |
---|
| 695 | if( $last_displayed_job != null ) |
---|
| 696 | { |
---|
| 697 | $filter['id'] = $last_displayed_job; |
---|
| 698 | } |
---|
| 699 | } |
---|
[738] | 700 | // Running / queued amount jobs graph |
---|
| 701 | // |
---|
| 702 | if( $rjqj_host != null ) |
---|
| 703 | { |
---|
[761] | 704 | $rjqj_graphargs = "?z=overview-medium&c=$clustername&h=$rjqj_host&g=job_report&r=$range"; |
---|
[738] | 705 | if( $range == 'job' ) |
---|
| 706 | { |
---|
| 707 | $rjqj_end = time(); |
---|
[768] | 708 | |
---|
| 709 | if( $rjqj_start == null ) |
---|
| 710 | { // probably no running jobs in this view: only queued |
---|
| 711 | $rjqj_start = $rjqj_end - (24 * 3600); // default to 1 day |
---|
| 712 | } |
---|
[758] | 713 | $rjqj_title = rawurlencode( makeTime( ($rjqj_end - $rjqj_start) ) ); |
---|
| 714 | $rjqj_graphargs .= "&period_start=$rjqj_start&period_stop=$rjqj_end&t=$rjqj_title"; |
---|
[738] | 715 | } |
---|
| 716 | else |
---|
| 717 | { |
---|
| 718 | $rjqj_graphargs .= "&st=$cluster[LOCALTIME]"; |
---|
| 719 | } |
---|
[763] | 720 | if( intval($view_jobs) == 1 and $start_time ) |
---|
| 721 | { |
---|
| 722 | $job_start = $jobs[$last_displayed_job]['start_timestamp']; |
---|
| 723 | $rjqj_graphargs .= "&job_start=$start_time"; |
---|
| 724 | } |
---|
[208] | 725 | |
---|
[738] | 726 | $rjqj_str = "<A HREF=\"./graph.php$rjqj_graphargs\">"; |
---|
[796] | 727 | $rjqj_str .= "<IMG BORDER=0 SRC=\"./graph.php$rjqj_graphargs\">"; |
---|
[738] | 728 | $rjqj_str .= "</A>"; |
---|
| 729 | |
---|
[822] | 730 | $tpl_data[ "rjqj_graph"]= $rjqj_str ; |
---|
[738] | 731 | } |
---|
| 732 | |
---|
[719] | 733 | $all_used_nodes = array_unique( $all_used_nodes ); |
---|
[732] | 734 | $view_name_nodes = array_unique( $view_name_nodes ); |
---|
| 735 | $running_name_nodes = array_unique( $running_name_nodes ); |
---|
[124] | 736 | |
---|
[719] | 737 | $used_nodes = count( $all_used_nodes ); |
---|
[732] | 738 | $view_nodes += count( $view_name_nodes ); |
---|
| 739 | $running_nodes += count( $running_name_nodes ); |
---|
[208] | 740 | |
---|
[732] | 741 | $total_nodes = $queued_nodes + $running_nodes; |
---|
[719] | 742 | $total_cpus = $queued_cpus + $running_cpus; |
---|
| 743 | $total_jobs = $queued_jobs + $running_jobs; |
---|
[135] | 744 | |
---|
[719] | 745 | $free_nodes = $avail_nodes - $running_nodes - $na_nodes; |
---|
[732] | 746 | $free_nodes = ( $free_nodes >= 0 ) ? $free_nodes : 0; |
---|
| 747 | $free_cpus = $avail_cpus - $running_cpus - $na_cpus; |
---|
| 748 | $free_cpus = ( $free_cpus >= 0 ) ? $free_cpus : 0; |
---|
[208] | 749 | |
---|
[822] | 750 | $tpl_data[ "avail_nodes"]= $avail_nodes ; |
---|
| 751 | $tpl_data[ "avail_cpus"]= $avail_cpus ; |
---|
[208] | 752 | |
---|
[822] | 753 | $tpl_data[ "queued_nodes"]= $queued_nodes ; |
---|
| 754 | $tpl_data[ "queued_jobs"]= $queued_jobs ; |
---|
| 755 | $tpl_data[ "queued_cpus"]= $queued_cpus ; |
---|
[208] | 756 | |
---|
[719] | 757 | // Only display "Unavailable" in count overview there are any |
---|
| 758 | // |
---|
| 759 | if( $na_nodes > 0 ) |
---|
| 760 | { |
---|
[822] | 761 | $tpl_data[ "na_nodes"]= "yes"; |
---|
[512] | 762 | |
---|
[822] | 763 | $tpl_data[ "na_nodes"]= $na_nodes ; |
---|
| 764 | $tpl_data[ "na_cpus"]= $na_cpus ; |
---|
[719] | 765 | } |
---|
[517] | 766 | |
---|
[822] | 767 | $tpl_data[ "total_nodes"]= $total_nodes ; |
---|
| 768 | $tpl_data[ "total_jobs"]= $total_jobs ; |
---|
| 769 | $tpl_data[ "total_cpus"]= $total_cpus ; |
---|
[135] | 770 | |
---|
[822] | 771 | $tpl_data[ "running_nodes"]= $running_nodes ; |
---|
| 772 | $tpl_data[ "running_jobs"]= $running_jobs ; |
---|
| 773 | $tpl_data[ "running_cpus"]= $running_cpus ; |
---|
[208] | 774 | |
---|
[822] | 775 | $tpl_data[ "used_nodes"]= $used_nodes ; |
---|
| 776 | $tpl_data[ "used_jobs"]= $used_jobs ; |
---|
| 777 | $tpl_data[ "used_cpus"]= $used_cpus ; |
---|
[208] | 778 | |
---|
[822] | 779 | $tpl_data[ "free_nodes"]= $free_nodes ; |
---|
| 780 | $tpl_data[ "free_cpus"]= $free_cpus ; |
---|
[135] | 781 | |
---|
[822] | 782 | $tpl_data[ "view_nodes"]= $view_nodes ; |
---|
| 783 | $tpl_data[ "view_jobs"]= $view_jobs ; |
---|
| 784 | $tpl_data[ "view_cpus"]= $view_cpus ; |
---|
[126] | 785 | |
---|
[822] | 786 | $tpl_data[ "report_time"]= makeDate( $heartbeat); |
---|
[328] | 787 | |
---|
[263] | 788 | |
---|
[719] | 789 | global $longtitle, $title; |
---|
[406] | 790 | |
---|
[719] | 791 | $longtitle = "Batch Report :: Powered by Job Monarch!"; |
---|
| 792 | $title = "Batch Report"; |
---|
[406] | 793 | |
---|
[719] | 794 | makeHeader( 'overview', $title, $longtitle ); |
---|
[406] | 795 | |
---|
[719] | 796 | setupFilterSettings(); |
---|
[263] | 797 | |
---|
[719] | 798 | if( intval($view_jobs) == 1 and $start_time ) |
---|
| 799 | { |
---|
[822] | 800 | $tpl_data[ "showhosts"]= "yes" ; |
---|
[126] | 801 | |
---|
[719] | 802 | $showhosts = isset($sh) ? $sh : $default_showhosts; |
---|
[126] | 803 | |
---|
[822] | 804 | $tpl_data[ "checked$showhosts"]= "checked" ; |
---|
[126] | 805 | |
---|
[753] | 806 | $sorted_list = array(); |
---|
| 807 | |
---|
[719] | 808 | if( $showhosts ) |
---|
| 809 | { |
---|
| 810 | if( !isset( $start ) ) |
---|
| 811 | { |
---|
| 812 | $start ="jobstart"; |
---|
| 813 | } |
---|
| 814 | if( !isset( $stop ) ) |
---|
| 815 | { |
---|
| 816 | $stop ="now"; |
---|
| 817 | } |
---|
[126] | 818 | |
---|
[731] | 819 | $sorted_hosts = array(); |
---|
[719] | 820 | $hosts_up = $jobs[$filter['id']]['nodes']; |
---|
[126] | 821 | |
---|
[731] | 822 | $r = intval($job_runningtime * 1.2); |
---|
[126] | 823 | |
---|
[719] | 824 | $jobrange = -$r ; |
---|
| 825 | $jobstart = $start_time; |
---|
[402] | 826 | |
---|
[719] | 827 | if ( $reports[$metricname] ) |
---|
| 828 | { |
---|
| 829 | $metricval = "g"; |
---|
| 830 | } |
---|
| 831 | else |
---|
| 832 | { |
---|
| 833 | $metricval = "m"; |
---|
| 834 | } |
---|
| 835 | |
---|
| 836 | foreach ( $hosts_up as $host ) |
---|
| 837 | { |
---|
| 838 | $domain_len = 0 - strlen( $domain ); |
---|
[195] | 839 | |
---|
[719] | 840 | if( $use_fqdn ) |
---|
| 841 | { |
---|
| 842 | if( substr( $host, $domain_len ) != $domain ) |
---|
| 843 | { |
---|
| 844 | $host = $host . '.' . $domain; |
---|
| 845 | } |
---|
| 846 | } |
---|
[733] | 847 | $cpus = 0; |
---|
[328] | 848 | |
---|
[719] | 849 | $cpus = $metrics[$host]["cpu_num"]["VAL"]; |
---|
[328] | 850 | |
---|
[733] | 851 | if( $cpus == 0 ) |
---|
[719] | 852 | { |
---|
| 853 | $cpus = 1; |
---|
| 854 | } |
---|
[328] | 855 | |
---|
[719] | 856 | $load_one = $metrics[$host]["load_one"]['VAL']; |
---|
| 857 | $load = ((float) $load_one) / $cpus; |
---|
[731] | 858 | $host_load[$host] = $load; |
---|
[328] | 859 | |
---|
[719] | 860 | $percent_hosts[load_color($load)] ++; |
---|
[328] | 861 | |
---|
[719] | 862 | if ($metricname=="load_one") |
---|
| 863 | { |
---|
| 864 | $sorted_hosts[$host] = $load; |
---|
| 865 | } |
---|
| 866 | else |
---|
| 867 | { |
---|
| 868 | $sorted_hosts[$host] = $metrics[$host][$metricname]['VAL']; |
---|
| 869 | } |
---|
| 870 | } |
---|
[463] | 871 | |
---|
[719] | 872 | switch ( $sort ) |
---|
| 873 | { |
---|
| 874 | case "descending": |
---|
| 875 | arsort( $sorted_hosts ); |
---|
| 876 | break; |
---|
[328] | 877 | |
---|
[719] | 878 | case "by hostname": |
---|
| 879 | ksort( $sorted_hosts ); |
---|
| 880 | break; |
---|
[328] | 881 | |
---|
[719] | 882 | case "ascending": |
---|
| 883 | asort( $sorted_hosts ); |
---|
| 884 | break; |
---|
[328] | 885 | |
---|
[719] | 886 | default: |
---|
| 887 | break; |
---|
| 888 | } |
---|
[126] | 889 | |
---|
[719] | 890 | // First pass to find the max value in all graphs for this |
---|
| 891 | // metric. The $start,$end variables comes from get_context.php, |
---|
| 892 | // included in index.php. |
---|
| 893 | // |
---|
| 894 | list($min, $max) = find_limits($sorted_hosts, $metricname); |
---|
[126] | 895 | |
---|
[719] | 896 | // Second pass to output the graphs or metrics. |
---|
| 897 | $i = 1; |
---|
[126] | 898 | |
---|
[753] | 899 | $metric_loop = array(); |
---|
[719] | 900 | foreach ( $sorted_hosts as $host=>$value ) |
---|
| 901 | { |
---|
[731] | 902 | $host_url = rawurlencode( $host ); |
---|
| 903 | $cluster_url = rawurlencode( $clustername ); |
---|
[193] | 904 | |
---|
[719] | 905 | $textval = ""; |
---|
[328] | 906 | |
---|
[719] | 907 | $val = $metrics[$host][$metricname]; |
---|
[731] | 908 | $class = "metric"; |
---|
[328] | 909 | |
---|
[719] | 910 | if ( $val["TYPE"] == "timestamp" || $always_timestamp[$metricname] ) |
---|
| 911 | { |
---|
| 912 | $textval = date( "r", $val["VAL"] ); |
---|
| 913 | } |
---|
| 914 | elseif ( $val["TYPE"] == "string" || $val["SLOPE"] == "zero" || $always_constant[$metricname] || ($max_graphs > 0 and $i > $max_graphs )) |
---|
| 915 | { |
---|
| 916 | $textval = $val["VAL"] . " " . $val["UNITS"]; |
---|
| 917 | } |
---|
| 918 | else |
---|
| 919 | { |
---|
[731] | 920 | $job_start = $jobs[$last_displayed_job]['start_timestamp']; |
---|
[805] | 921 | $period_end = $cluster['LOCALTIME']; |
---|
| 922 | $runningtime = intval( $period_end ) - intval( $job_start ); |
---|
[719] | 923 | $load_color = load_color($host_load[$host]); |
---|
[731] | 924 | $period_start = intval( $job_start - (intval( $runningtime * 0.10 ) ) ); |
---|
| 925 | //printf("last job %s job start %s runningtime %s period start %s", $last_displayed_job, $jobstart, $job_runningtime, $period_start); |
---|
[719] | 926 | $graphargs = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&"; |
---|
[823] | 927 | $graphargs .= "z=overview-medium&c=$cluster_url&r=$range&h=$host_url&l=$load_color&v=".$val['VAL']."&job_start=$job_start&vl=".$val['UNITS']; |
---|
[739] | 928 | $host_link = "?j_view=overview-host&c=$cluster_url&r=$range&h=$host_url&job_start=$jobstart"; |
---|
| 929 | |
---|
| 930 | if( $range == 'job' ) |
---|
| 931 | { |
---|
| 932 | $graphargs .= "&period_start=$period_start&period_stop=$period_end"; |
---|
| 933 | $host_link .= "&period_start=$period_start&period_stop=$period_end"; |
---|
| 934 | } |
---|
| 935 | else |
---|
| 936 | { |
---|
| 937 | $graphargs .= "&st=$period_end"; |
---|
| 938 | $host_link .= "&st=$period_end"; |
---|
| 939 | } |
---|
[719] | 940 | if( $max > 0 ) |
---|
| 941 | { |
---|
| 942 | $graphargs .= "&x=$max&n=$min"; |
---|
| 943 | } |
---|
| 944 | } |
---|
| 945 | if ($textval) |
---|
| 946 | { |
---|
| 947 | $cell = "<td class=$class>". "<b><a href=$host_link>$host</a></b><br>". "<i>$metricname:</i> <b>$textval</b></td>"; |
---|
| 948 | } else { |
---|
[798] | 949 | $cell = "<A HREF=\"$host_link\">" . "<IMG SRC=\"./graph.php?$graphargs\" " . "ALT=\"$host\" BORDER=0></A>"; |
---|
[719] | 950 | } |
---|
[126] | 951 | |
---|
[753] | 952 | $metric_loop["metric_image"] = $cell; |
---|
[328] | 953 | |
---|
[757] | 954 | //if(! ($i++ % $hostcols) ) |
---|
| 955 | //{ |
---|
| 956 | // $metric_loop["br"] = "</tr><tr>"; |
---|
| 957 | //} |
---|
[753] | 958 | $sorted_list[] = $metric_loop; |
---|
[719] | 959 | } |
---|
[822] | 960 | $tpl_data["sorted_list"]= $sorted_list ; |
---|
[719] | 961 | } |
---|
| 962 | } |
---|
[753] | 963 | $dwoo->output($tpl, $tpl_data); |
---|
[114] | 964 | } |
---|
[753] | 965 | |
---|
[113] | 966 | ?> |
---|