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