source: trunk/web/addons/job_monarch/overview.php @ 203

Last change on this file since 203 was 203, checked in by bastiaans, 18 years ago

Renamed: web/addons/toga -> web/addons/job_monarch

web/templates/job_monarch/cluster_extra.tpl:

  • changed addon path
File size: 17.2 KB
RevLine 
[113]1<?php
[126]2global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url, $sh;
[138]3global $hosts_up, $m, $start, $end, $filterorder;
[114]4
[140]5//$tpl->assign("_ROOT.summary", "" );
6
[163]7$data_gatherer = new DataGatherer( $clustername );
[114]8
[117]9//$tpl->assign( "self", "./index.php" );
[116]10$tpl->assign( "clustername", $clustername );
11
[129]12if( $TARCHD )
13        $tpl->assign( "cluster_url", rawurlencode($clustername) );
14
[114]15$data_gatherer->parseXML();
[117]16
[114]17$heartbeat = $data_gatherer->getHeartbeat();
18$jobs = $data_gatherer->getJobs();
[126]19$gnodes = $data_gatherer->getNodes();
[124]20$cpus = $data_gatherer->getCpus();
[114]21
[122]22$filter_image_url = "";
23
[119]24foreach( $filter as $filtername => $filtervalue ) {
25        $tpl->assign( "f_".$filtername, $filtervalue );
[122]26        $filter_image_url .= "&$filtername=$filtervalue";
[119]27}
28
[122]29$tpl->assign( "clusterimage", "./image.php?c=".rawurlencode($clustername)."&view=big-clusterimage".$filter_image_url );
[138]30$tpl->assign( "f_order", $filterorder );
[122]31
[126]32if( array_key_exists( "id", $filter ) )
[127]33        $piefilter = 'id';
[126]34else if( array_key_exists( "user", $filter ) )
[127]35        $piefilter = 'user';
[126]36else if( array_key_exists( "queue", $filter ) )
[127]37        $piefilter = 'queue';
[114]38
[127]39$pie = drawPie();
[114]40$tpl->assign("pie", $pie );
41
[122]42//if( !array_key_exists( 'id', $filter ) ) {
43
44//      $graph_args = "c=$cluster_url&$get_metric_string&st=$cluster[LOCALTIME]";
45//      $tpl->newBlock( "average_graphs" );
46//      $tpl->assign( "graph_args", $graph_args );
47//}
48
[120]49function timeToEpoch( $time ) {
50
51        $time_fields = explode( ':', $time );
52
53        if( count($time_fields) == 3 ) {
54
55                $hours = $time_fields[0];
56                $minutes = $time_fields[1];
57                $seconds = $time_fields[2];
58
[128]59        } else if( count($time_fields) == 2 ) {
60
61                $hours = 0;
62                $minutes = $time_fields[0];
63                $seconds = $time_fields[1];
64
65        } else if( count($time_fields) == 1 ) {
66
67                $hours = 0;
68                $minutes = 0;
69                $seconds = $time_fields[0];
[120]70        }
[128]71
72        $myepoch = intval( $seconds + (intval( $minutes * 60 )) + (intval( $hours * 3600 )) );
73
74        return $myepoch;
[120]75}
76
[114]77function makeTime( $time ) {
78
79        $days = intval( $time / 86400 );
[128]80        $time = ($days>0) ? $time % ($days * 86400) : $time;
[115]81
[128]82        //printf( "time = %s, days = %s\n", $time, $days );
83
84        $date_str = '';
85        $day_str = '';
86
[114]87        if( $days > 0 ) {
88                if( $days > 1 )
[128]89                        $day_str .= $days . ' days';
[114]90                else
[128]91                        $day_str .= $days . ' day';
[114]92        }
[115]93
[114]94        $hours = intval( $time / 3600 );
[115]95        $time = $hours ? $time % ($hours * 3600) : $time;
96
[128]97        //printf( "time = %s, days = %s, hours = %s\n", $time, $days, $hours );
98
[114]99        if( $hours > 0 ) {
100                $date_str .= $hours . ':';
[128]101                $date_unit = 'hours';
[114]102        }
[115]103               
[114]104        $minutes = intval( $time / 60 );
[115]105        $seconds = $minutes ? $time % ($minutes * 60) : $time;
106
[114]107        if( $minutes > 0 ) {
[115]108
109                if( $minutes >= 10 )
110                        $date_str .= $minutes . ':';
111                else
112                        $date_str .= '0' . $minutes . ':';
113
[114]114                $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
[128]115        } else {
116                if($hours > 0 ) {
117                        $date_str .= '00:';
118                        $date_unit = (!isset($date_unit)) ? 'minutes' : $date_unit;
119                }
[114]120        }
[115]121
[128]122
[114]123        $date_unit = (!isset($date_unit)) ? 'seconds' : $date_unit;
124
[115]125        if( $seconds > 0 ) {
126
127                if( $seconds >= 10 )
128                        $date_str .= $seconds . ' ' . $date_unit;
129                else
130                        $date_str .= '0' . $seconds . ' ' . $date_unit;
131                       
[128]132        } else if ( $hours > 0 or $minutes > 0 )
133
[115]134                $date_str .= '00 ' . $date_unit;
135
[128]136        if( $days > 0) {
137
138                if( $hours > 0 or $minutes > 0 or $seconds > 0 )
139                        $date_str = $day_str . ' - ' . $date_str;
140                else
141                        $date_str = $day_str;
142        }
143
[114]144        return $date_str;
145}
146
147function makeDate( $time ) {
148        return strftime( "%a %d %b %Y %H:%M:%S", $time );
149}
150
151function colorRed( $color ) {
152        return substr( $color, 0, 2 );
153}
154function colorGreen( $color ) {
155        return substr( $color, 2, 2 );
156}
157function colorBlue( $color ) {
158        return substr( $color, 4, 2 );
159}
160
161function colorDiffer( $first, $second ) {
162
163        // Make sure these two colors differ atleast 50 R/G/B
164        $min_diff = 50;
165
[147]166        $c1r = hexDec( colorRed( $first ) );
167        $c1g = hexDec( colorGreen( $first ) );
168        $c1b = hexDec( colorBlue( $first ) );
[114]169
[147]170        $c2r = hexDec( colorRed( $second ) );
171        $c2g = hexDec( colorGreen( $second ) );
172        $c2b = hexDec( colorBlue( $second ) );
[114]173
174        $rdiff = ($c1r >= $c2r) ? $c1r - $c2r : $c2r - $c1r;
175        $gdiff = ($c1g >= $c2g) ? $c1g - $c2g : $c2g - $c1g;
176        $bdiff = ($c1b >= $c2b) ? $c1b - $c2b : $c2b - $c1b;
177
178        if( $rdiff >= $min_diff or $gdiff >= $min_diff or $bdiff >= $min_diff )
179                return TRUE;
180        else
181                return FALSE;
182}
183
184function randomColor( $known_colors ) {
185
[147]186        $start = "004E00";
187       
188        $start_red = colorRed( $start );
189        $start_green = colorGreen( $start );
190        $start_blue = colorBlue( $start );
191       
192        $end = "FFFFFF";
[114]193
[147]194        $end_red = colorRed( $end );
195        $end_green = colorGreen( $end );
196        $end_blue = colorBlue( $end );
[114]197
[147]198        $change_color = TRUE;
[114]199
[147]200        while( $change_color ) {
[114]201
[147]202                $change_color = FALSE;
[114]203
[147]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 ) );
[114]207
[147]208                $new = decHex( $new_red ) . decHex( $new_green ) . decHex( $new_blue );
[114]209
[147]210                foreach( $known_colors as $old )
[114]211
[147]212                        if( !colorDiffer( $new, $old ) )
[114]213
[147]214                                $change_color = TRUE;
[114]215        }
216
217        // Whoa! Actually found a good color ;)
[147]218        return $new;
[114]219}
220
[126]221function drawJobPie() {
222}
[114]223
[126]224function drawUserPie() {
[124]225
[126]226}
227
228function drawQueuePie() {
229
230}
231
232
[127]233function drawPie() {
[124]234
[127]235        global $jobs, $gnodes, $piefilter, $filter;
[114]236
[126]237        $nodes = $gnodes;
[127]238
239        if( isset($piefilter) ) 
240                $pie_args = "title=" . rawurlencode("Cluster ".$piefilter." usage");
241        else
242                $pie_args = "title=" . rawurlencode("Cluster queue usage");
243               
[114]244        $pie_args .= "&size=250x150";
245
246        $queues = array();
247        $nr_jobs = count( $jobs );
248        $nr_nodes = count( $nodes );
249
250        $emptynodes = 0;
251
[123]252        $job_weight = array();
253
[114]254        foreach( $nodes as $node ) {
255
256                $myjobs = $node->getJobs();
257
258                if( count( $myjobs ) == 0 )
259                        $emptynodes++;
260        }
[123]261        $used_nodes = $nr_nodes - $emptynodes;
[114]262
263        $empty_percentage = ($emptynodes / $nr_nodes) * 100;
264        $job_percentage = 100 - $empty_percentage; 
265
[127]266        $qcolors = array();
[114]267        $color = randomColor( $qcolors );
268        $qcolors[] = $color;
269        $pie_args .= "&free=$empty_percentage,$color";
270
[127]271        if( isset( $piefilter ) )
272                $filterpie = array();
273
[123]274        foreach( $nodes as $node ) {
[114]275
[123]276                $node_jobs = $node->getJobs();
277                $nr_node_jobs = count( $node_jobs );
278                $myhost = $node->getHostname();
[114]279
[123]280                foreach( $node_jobs as $myjob ) {
[114]281
[123]282                        // Determine the weight of this job on the node it is running
283                        // - what percentage of the node is in use by this job
284                        //
285                        $job_weight[$myjob] = ( 100 / count( $node_jobs ) ) / 100;
286                        $qname = $jobs[$myjob][queue];
287
[127]288                        if( isset($piefilter) ) {
289                                $countjob = 1;
290                                if( $piefilter == 'id' ) {
291                                        if( $myjob != $filter[$piefilter] )
292                                                $countjob = 0;
293                                } else if( $piefilter == 'user' ) {
294                                        if( $jobs[$myjob][owner] != $filter[$piefilter] )
295                                                $countjob = 0;
296                                } else {
297                                        if( $jobs[$myjob][$piefilter] != $filter[$piefilter] )
298                                                $countjob = 0;
299                                }
300
301                                if( $countjob ) {
302
303                                        if( !isset( $filterpie[$filter[$piefilter]] ) )
304                                                $filterpie[$filter[$piefilter]] = $job_weight[$myjob];
305                                        else
306                                                $filterpie[$filter[$piefilter]] = $filterpie[$filter[$piefilter]] + $job_weight[$myjob];
307                                } else {
308                                        if( !isset( $filterpie["other"] ) )
309                                                $filterpie["other"] = $job_weight[$myjob];
310                                        else
311                                                $filterpie["other"] = $filterpie["other"] + $job_weight[$myjob];
312
313                                }
314                               
315                        } else {
316
317                                if( !isset( $queues[$qname] ) )
318                                        $queues[$qname] = $job_weight[$myjob];
319                                else
320                                        $queues[$qname] = $queues[$qname] + $job_weight[$myjob];
321                        }
[114]322                }
323        }
324
[127]325        //$qcolors = array();
326        if( isset( $piefilter ) )
327                $graphvals = $filterpie;
328        else
329                $graphvals = $queues;
[114]330
[127]331        foreach( $graphvals as $name => $totalweight) {
332
[123]333                $percentage = ( $totalweight / $used_nodes ) * $job_percentage;
334               
[114]335                $color = randomColor( $qcolors );
336                $qcolors[] = $color;
[127]337                $pie_args .= "&$name=$percentage,$color";
[114]338        }
339        $pie = "../../pie.php?$pie_args";
340
341        return $pie;
342}
343
344
[117]345function sortJobs( $jobs, $sortby, $sortorder ) {
[114]346
[117]347        $sorted = array();
[114]348
[117]349        $cmp = create_function( '$a, $b', 
350                "global \$sortby, \$sortorder;".
[116]351
[117]352                "if( \$a == \$b ) return 0;".
[116]353
[117]354                "if (\$sortorder==\"desc\")".
355                        "return ( \$a < \$b ) ? 1 : -1;".
356                "else if (\$sortorder==\"asc\")".
357                        "return ( \$a > \$b ) ? 1 : -1;" );
358
359        foreach( $jobs as $jobid => $jobattrs ) {
360
361                        $state = $jobattrs[status];
362                        $user = $jobattrs[owner];
363                        $queue = $jobattrs[queue];
364                        $name = $jobattrs[name];
365                        $req_cpu = $jobattrs[requested_time];
366                        $req_memory = $jobattrs[requested_memory];
[135]367
368                        if( $state == 'R' )
369                                $nodes = count( $jobattrs[nodes] );
370                        else
371                                $nodes = $jobattrs[nodes];
372
[117]373                        $ppn = (int) $jobattrs[ppn] ? $jobattrs[ppn] : 1;
374                        $cpus = $nodes * $ppn;
375                        $start_time = (int) $jobattrs[start_timestamp];
376                        $runningtime = $report_time - $start_time;
377
378                        switch( $sortby ) {
379                                case "id":
380                                        $sorted[$jobid] = $jobid;
381                                        break;
382
383                                case "state":
384                                        $sorted[$jobid] = $state;
385                                        break;
386
387                                case "user":
388                                        $sorted[$jobid] = $user;
389                                        break;
390
391                                case "queue":
392                                        $sorted[$jobid] = $queue;
393                                        break;
394
395                                case "name":
396                                        $sorted[$jobid] = $name;
397                                        break;
398
399                                case "req_cpu":
[128]400                                        $sorted[$jobid] = timeToEpoch( $req_cpu );
[117]401                                        break;
402
403                                case "req_mem":
404                                        $sorted[$jobid] = $req_memory;
405                                        break;
406
407                                case "nodes":
408                                        $sorted[$jobid] = $nodes;
409                                        break;
410
411                                case "cpus":
412                                        $sorted[$jobid] = $cpus;
413                                        break;
414
415                                case "start":
416                                        $sorted[$jobid] = $start_time;
417                                        break;
418
419                                case "runningtime":
420                                        $sorted[$jobid] = $runningtime;
421                                        break;
422
423                                default:
424                                        break;
425
426                        }
427        }
428
[128]429        //uasort( $sorted, $cmp );
430        if( $sortorder == "asc" )
431                arsort( $sorted );
432        else if( $sortorder == "desc" )
433                asort( $sorted );
[117]434
435        return $sorted;
436}
437
438function makeOverview() {
439
440        global $jobs, $nodes, $heartbeat, $clustername, $tpl;
[126]441        global $sortorder, $sortby, $filter, $sh, $hc, $m;
442        global $cluster_url, $get_metric_string, $host_url, $metrics;
[129]443        global $start, $end, $reports, $gnodes, $default_showhosts;
[117]444
[126]445        $metricname = $m;
446
[117]447        $tpl->assign("sortorder", $sortorder );
448        $tpl->assign("sortby", $sortby );
449
450        $sorted_jobs = sortJobs( $jobs, $sortby, $sortorder );
451
[118]452        $even = 1;
453
[135]454        $used_jobs = 0;
455        $used_cpus = 0;
456        $used_nodes = 0;
[124]457
[135]458        $all_used_nodes = array();
[124]459
[135]460        $avail_nodes = count( $gnodes );
461        $avail_cpus = cluster_sum("cpu_num", $metrics);
462
463        $view_cpus = 0;
464        $view_jobs = 0;
465        $view_nodes = 0;
466
467        $view_used_nodes = array();
468
[117]469        foreach( $sorted_jobs as $jobid => $sortdec ) {
470
471                $report_time = $jobs[$jobid][reported];
472
[124]473                $nodes = count( $jobs[$jobid][nodes] );
474                $ppn = (int) $jobs[$jobid][ppn] ? $jobs[$jobid][ppn] : 1;
475                $cpus = $nodes * $ppn;
476
[135]477                foreach( $jobs[$jobid][nodes] as $tempnode )
478                        $all_used_nodes[] = $tempnode;
[124]479
[135]480                if( $jobs[$jobid][status] == 'R' ) {
481                        $used_cpus += $cpus;
482                        $used_jobs++;
483                }
484
[117]485                if( $report_time == $heartbeat ) {
486
[124]487                        $display_job = 1;
[117]488
[119]489                        foreach( $filter as $filtername=>$filtervalue ) {
[118]490
[124]491                                if( $filtername == 'id' && $jobid != $filtervalue )
492                                        $display_job = 0;
493                                else if( $filtername == 'state' && $jobs[$jobid][status] != $filtervalue )
494                                        $display_job = 0;
495                                else if( $filtername == 'queue' && $jobs[$jobid][queue] != $filtervalue )
496                                        $display_job = 0;
497                                else if( $filtername == 'user' && $jobs[$jobid][owner] != $filtervalue )
498                                        $display_job = 0;
[118]499                        }
500
[119]501                        if( $display_job ) {
[117]502
[119]503                                $tpl->newBlock("node");
504                                $tpl->assign( "clustername", $clustername );
505                                $tpl->assign("id", $jobid );
506                                $tpl->assign("state", $jobs[$jobid][status] );
507                                $tpl->assign("user", $jobs[$jobid][owner] );
508                                $tpl->assign("queue", $jobs[$jobid][queue] );
509                                $tpl->assign("name", $jobs[$jobid][name] );
[126]510                                $domain = $jobs[$jobid][domain];
[120]511                                $tpl->assign("req_cpu", makeTime( timeToEpoch( $jobs[$jobid][requested_time] ) ) );
[119]512                                $tpl->assign("req_memory", $jobs[$jobid][requested_memory] );
[135]513
514                                if( $jobs[$jobid][status] == 'R' )
515                                        $nodes = count( $jobs[$jobid][nodes] );
516                                else if( $jobs[$jobid][status] == 'Q' )
517                                        $nodes = $jobs[$jobid][nodes];
518
[119]519                                $ppn = (int) $jobs[$jobid][ppn] ? $jobs[$jobid][ppn] : 1;
520                                $cpus = $nodes * $ppn;
521                                $tpl->assign("nodes", $nodes );
522                                $tpl->assign("cpus", $cpus );
523                                $start_time = (int) $jobs[$jobid][start_timestamp];
[126]524                                $job_start = $start_time;
[119]525
[135]526                                $view_cpus += $cpus;
527                                $view_jobs++;
[124]528
[135]529                                if( $jobs[$jobid][status] == 'R' )
530                                        foreach( $jobs[$jobid][nodes] as $tempnode )
531                                                $view_used_nodes[] = $tempnode;
532                                else if( $jobs[$jobid][status] == 'Q' )
533                                        $view_nodes += $jobs[$jobid][nodes];
534
[119]535                                if( $even ) {
536
537                                        $tpl->assign("nodeclass", "even");
538                                        $even = 0;
539                                } else {
540
541                                        $tpl->assign("nodeclass", "odd");
542                                        $even = 1;
543                                }
544
545                                if( $start_time ) {
546
547                                        $runningtime = makeTime( $report_time - $start_time );
[126]548                                        $job_runningtime = $report_time - $start_time;
[119]549                                        $tpl->assign("started", makeDate( $start_time ) );
550                                        $tpl->assign("runningtime", $runningtime );
551                                }
[117]552                        }
[116]553                }
[114]554        }
[135]555        array_unique( $all_used_nodes );
556        array_unique( $view_used_nodes );
557        $used_nodes = count( $all_used_nodes );
558        $view_nodes += count( $view_used_nodes );
[124]559
[135]560        //$tpl->assignGlobal("cpus_nr", $overview_cpus );
561        //$tpl->assignGlobal("jobs_nr", $overview_jobs );
562
563        $tpl->assignGlobal("avail_nodes", $avail_nodes );
564        $tpl->assignGlobal("avail_cpus", $avail_cpus );
565
566        $tpl->assignGlobal("used_nodes", $used_nodes );
567        $tpl->assignGlobal("used_jobs", $used_jobs );
568        $tpl->assignGlobal("used_cpus", $used_cpus );
569
570        $tpl->assignGlobal("view_nodes", $view_nodes );
571        $tpl->assignGlobal("view_jobs", $view_jobs );
572        $tpl->assignGlobal("view_cpus", $view_cpus );
573
[124]574        $tpl->assignGlobal("report_time", makeDate( $heartbeat));
575       
[135]576        //$tpl->assignGlobal("f_cpus_nr", $f_cpus );
577        //$tpl->assignGlobal("f_jobs_nr", $f_jobs );
[126]578
[188]579        if( intval($view_jobs) == 1 and $start_time ) {
[126]580                $tpl->newBlock( "showhosts" );
581
582                # Present a width list
583                $cols_menu = "<SELECT NAME=\"hc\" OnChange=\"toga_form.submit();\">\n";
584
585                $hostcols = ($hc) ? $hc : 4;
586
587                foreach(range(1,25) as $cols) {
588                        $cols_menu .= "<OPTION VALUE=$cols ";
589                        if ($cols == $hostcols)
590                                $cols_menu .= "SELECTED";
591                        $cols_menu .= ">$cols\n";
592                }
593                $cols_menu .= "</SELECT>\n";
594
595                //$tpl->assign("cluster", $clustername);
596                $tpl->assign("metric","$metricname $units");
[127]597                $tpl->assign("id", $filter[id]);
[126]598                # Host columns menu defined in header.php
599                $tpl->assign("cols_menu", $cols_menu);
600
[129]601                $showhosts = isset($sh) ? $sh : $default_showhosts;
602                //if( !$showhosts) $showhosts = $default_showhosts;
[126]603                $tpl->assign("checked$showhosts", "checked");
604
605                if( $showhosts ) {
606                        //-----
607
608                        if( !isset($start) ) $start="jobstart";
609                        if( !isset($stop) ) $stop="now";
610                        //$tpl->assign("start", $start);
611                        //$tpl->assign("stop", $stop);
612
613                        $sorted_hosts = array();
614                        $hosts_up = $jobs[$filter[id]][nodes];
615
616                        $r = intval($job_runningtime * 1.25);
617
618                        $jobrange = ($job_runningtime < 3600) ? -3600 : -$r ;
619                        $jobstart = $report_time - $job_runningtime;
620
621                        if ($reports[$metricname])
622                                $metricval = "g";
623                        else
624                                $metricval = "m";
625                                               
626                        foreach ($hosts_up as $host ) {
[195]627
628                                $domain_len = 0 - strlen( $domain );
629                                if( substr( $host, $domain_len ) != $domain ) {
630                                        $host = $host. '.'.$domain;
631                                }
[126]632                                $cpus = $metrics[$host]["cpu_num"][VAL];
633                                if (!$cpus) $cpus=1;
634                                $load_one  = $metrics[$host]["load_one"][VAL];
635                                $load = ((float) $load_one)/$cpus;
636                                $host_load[$host] = $load;
637                                $percent_hosts[load_color($load)] += 1;
638                                if ($metricname=="load_one")
639                                        $sorted_hosts[$host] = $load;
640                                else
641                                        $sorted_hosts[$host] = $metrics[$host][$metricname][VAL];
642                        }
643                        switch ($sort) {
644                                case "descending":
645                                        arsort($sorted_hosts);
646                                        break;
647                                case "by hostname":
648                                        ksort($sorted_hosts);
649                                        break;
650                                default:
651                                case "ascending":
652                                        asort($sorted_hosts);
653                                        break;
654                        }
655
656                        //$sorted_hosts = array_merge($down_hosts, $sorted_hosts);
657
658                        # First pass to find the max value in all graphs for this
659                        # metric. The $start,$end variables comes from get_context.php,
660                        # included in index.php.
661                        list($min, $max) = find_limits($sorted_hosts, $metricname);
662
663                        # Second pass to output the graphs or metrics.
664                        $i = 1;
665                        foreach ( $sorted_hosts as $host=>$value  ) {
666                                $tpl->newBlock ("sorted_list");
667                                //$host = $host. '.'.$domain;
668                                $host_url = rawurlencode($host);
669                                $cluster_url = rawurlencode($clustername);
670
671                                $textval = "";
672                                //printf("host = %s, value = %s", $host, $value);
673                                //echo "$host: $value, ";
674                                $val = $metrics[$host][$metricname];
675                                $class = "metric";
[148]676                                $host_link="\"../../?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&js=$jobstart\"";
[126]677
678                                if ($val[TYPE]=="timestamp" or $always_timestamp[$metricname]) {
679                                        $textval = date("r", $val[VAL]);
680                                } elseif ($val[TYPE]=="string" or $val[SLOPE]=="zero" or $always_constant[$metricname] or ($max_graphs > 0 and $i > $max_graphs )) {
681                                        $textval = "$val[VAL] $val[UNITS]";
682                                } else {
683                                        $load_color = load_color($host_load[$host]);
684                                        $graphargs = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&";
[193]685                                        $graphargs .= "z=small&c=$cluster_url&h=$host_url&l=$load_color" ."&v=$val[VAL]&r=job&jr=$jobrange&js=$jobstart";
686                                        if( $max > 0 ) {
687
688                                                $graphargs .= "&x=$max&n=$min";
689                                        }
[126]690                                }
691                                if ($textval) {
692                                        $cell="<td class=$class>".  "<b><a href=$host_link>$host</a></b><br>".  "<i>$metricname:</i> <b>$textval</b></td>";
693                                } else {
694                                        $cell="<td><a href=$host_link>".  "<img src=\"../../graph.php?$graphargs\" ".  "alt=\"$host\" height=112 width=225 border=0></a></td>";
695                                }
696
697                                $tpl->assign("metric_image", $cell);
698                                if (! ($i++ % $hostcols) )
699                                         $tpl->assign ("br", "</tr><tr>");
700                        }
701                }
702//---
703        }
[114]704}
[113]705?>
Note: See TracBrowser for help on using the repository browser.