Ignore:
Timestamp:
06/17/05 17:14:55 (19 years ago)
Author:
bastiaans
Message:

web/addons/toga/libtoga.php:

  • Small bugfixes
  • Added getRrdDirs and Files functions for graphs

web/addons/toga/templates/search.tpl:

  • Small rearrangement

web/addons/toga/index.php:

  • Outlining

web/addons/toga/search.php:

  • Fixed graphing output!


web/addons/toga/graph.php

  • Fixed to handle multiple RRD's from multiple timeperiods
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/graph.php

    r143 r145  
    11<?php
    2 /* $Id: graph.php,v 1.8 2005/02/18 14:20:35 knobi1 Exp $ */
    3 include_once "./conf.php";
    4 include_once "./get_context.php";
     2include_once "./libtoga.php";
    53
    64if ( !empty( $_GET ) ) {
     
    2018$sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]);
    2119
     20$cluster = $c;
     21$metricname = ($g) ? $g : $m;
     22$hostname = $h;
     23
    2224# Assumes we have a $start variable (set in get_context.php).
    23 if ($size == "small")
    24     {
    25       $height = 40;
    26       $width = 130;
    27     }
    28 else if ($size == "medium")
    29     {
    30       $height = 75;
    31       $width = 300;
    32     }
    33 else
    34     {
    35       $height = 100;
    36       $width = 400;
    37     }
    38 
    39 
    40 # This security fix was brought to my attention by Peter Vreugdenhil <petervre@sci.kun.nl>
    41 # Dont want users specifying their own malicious command via GET variables e.g.
    42 # http://ganglia.mrcluster.org/graph.php?graph=blob&command=whoami;cat%20/etc/passwd
    43 #
    44 if($command)
    45     {
    46       exit();
    47     }
    48 
    49 switch ($context)
    50 {
    51     case "meta":
    52       $rrd_dir = "$rrds/__SummaryInfo__";
    53       break;
    54     case "grid":
    55       $rrd_dir = "$rrds/$grid/__SummaryInfo__";
    56       break;
    57     case "cluster":
    58       $rrd_dir = "$rrds/$clustername/__SummaryInfo__";
    59       break;
    60     case "host":
    61       $rrd_dir = "$rrds/$clustername/$hostname";
    62       break;
    63     default:
    64       exit;
    65 }
    66 
    67 if ($graph)   /* Canned graph request */
    68     {
    69       if($graph == "cpu_report")
    70          {
    71             $style = "CPU";
    72 
    73             $upper_limit = "--upper-limit 100 --rigid";
    74             $lower_limit = "--lower-limit 0";
    75 
    76             $vertical_label = "--vertical-label Percent ";
    77 
    78             if($context != "host" )
    79                {
    80                   /* If we are not in a host context, then we need to calculate the average */
    81                   $series =
    82                   "DEF:'num_nodes'='${rrd_dir}/cpu_user.rrd':'num':AVERAGE "
    83                   ."DEF:'cpu_user'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
    84                   ."CDEF:'ccpu_user'=cpu_user,num_nodes,/ "
    85                   ."DEF:'cpu_nice'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
    86                   ."CDEF:'ccpu_nice'=cpu_nice,num_nodes,/ "
    87                   ."DEF:'cpu_system'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
    88                   ."CDEF:'ccpu_system'=cpu_system,num_nodes,/ "
    89                   ."DEF:'cpu_idle'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
    90                   ."CDEF:'ccpu_idle'=cpu_idle,num_nodes,/ "
    91                   ."AREA:'ccpu_user'#$cpu_user_color:'User CPU' "
    92                   ."STACK:'ccpu_nice'#$cpu_nice_color:'Nice CPU' "
    93                   ."STACK:'ccpu_system'#$cpu_system_color:'System CPU' ";
    94                   if (file_exists("$rrd_dir/cpu_wio.rrd")) {
    95                      $series .= "DEF:'cpu_wio'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
    96                      ."CDEF:'ccpu_wio'=cpu_wio,num_nodes,/ "
    97                      ."STACK:'ccpu_wio'#$cpu_wio_color:'WAIT CPU' ";
    98                   }
    99                   $series .= "STACK:'ccpu_idle'#$cpu_idle_color:'Idle CPU' ";
    100                }
    101             else
    102                {
    103                   $series ="DEF:'cpu_user'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
    104                   ."DEF:'cpu_nice'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
    105                   ."DEF:'cpu_system'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
    106                   ."DEF:'cpu_idle'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
    107                   ."AREA:'cpu_user'#$cpu_user_color:'User CPU' "
    108                   ."STACK:'cpu_nice'#$cpu_nice_color:'Nice CPU' "
    109                   ."STACK:'cpu_system'#$cpu_system_color:'System CPU' ";
    110                   if (file_exists("$rrd_dir/cpu_wio.rrd")) {
    111                      $series .= "DEF:'cpu_wio'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
    112                      ."STACK:'cpu_wio'#$cpu_wio_color:'WAIT CPU' ";
    113                   }
    114                   $series .= "STACK:'cpu_idle'#$cpu_idle_color:'Idle CPU' ";
    115                }
    116          }
    117       else if ($graph == "mem_report")
    118          {
    119             $style = "Memory";
    120 
    121             $lower_limit = "--lower-limit 0 --rigid";
    122             $extras = "--base 1024";
    123             $vertical_label = "--vertical-label Bytes";
    124 
    125             $series = "DEF:'mem_total'='${rrd_dir}/mem_total.rrd':'sum':AVERAGE "
    126                ."CDEF:'bmem_total'=mem_total,1024,* "
    127                ."DEF:'mem_shared'='${rrd_dir}/mem_shared.rrd':'sum':AVERAGE "
    128                ."CDEF:'bmem_shared'=mem_shared,1024,* "
    129                ."DEF:'mem_free'='${rrd_dir}/mem_free.rrd':'sum':AVERAGE "
    130                ."CDEF:'bmem_free'=mem_free,1024,* "
    131                ."DEF:'mem_cached'='${rrd_dir}/mem_cached.rrd':'sum':AVERAGE "
    132                ."CDEF:'bmem_cached'=mem_cached,1024,* "
    133                ."DEF:'mem_buffers'='${rrd_dir}/mem_buffers.rrd':'sum':AVERAGE "
    134                ."CDEF:'bmem_buffers'=mem_buffers,1024,* "
    135                ."CDEF:'bmem_used'='bmem_total','bmem_shared',-,'bmem_free',-,'bmem_cached',-,'bmem_buffers',- "
    136                ."AREA:'bmem_used'#$mem_used_color:'Memory Used' "
    137                ."STACK:'bmem_shared'#$mem_shared_color:'Memory Shared' "
    138                ."STACK:'bmem_cached'#$mem_cached_color:'Memory Cached' "
    139                ."STACK:'bmem_buffers'#$mem_buffered_color:'Memory Buffered' ";
    140             if (file_exists("$rrd_dir/swap_total.rrd")) {
    141                $series .= "DEF:'swap_total'='${rrd_dir}/swap_total.rrd':'sum':AVERAGE "
    142                ."DEF:'swap_free'='${rrd_dir}/swap_free.rrd':'sum':AVERAGE "
    143                ."CDEF:'bmem_swapped'='swap_total','swap_free',-,1024,* "
    144                ."STACK:'bmem_swapped'#$mem_swapped_color:'Memory Swapped' ";
    145             }
    146             $series .= "LINE2:'bmem_total'#$cpu_num_color:'Total In-Core Memory' ";
    147          }
    148       else if ($graph == "load_report")
    149          {
    150             $style = "Load";
    151 
    152             $lower_limit = "--lower-limit 0 --rigid";
    153             $vertical_label = "--vertical-label 'Load/Procs'";
    154 
    155             $series = "DEF:'load_one'='${rrd_dir}/load_one.rrd':'sum':AVERAGE "
    156                ."DEF:'proc_run'='${rrd_dir}/proc_run.rrd':'sum':AVERAGE "
    157                ."DEF:'cpu_num'='${rrd_dir}/cpu_num.rrd':'sum':AVERAGE ";
    158             if( $context != "host" )
    159                {
    160                   $series .="DEF:'num_nodes'='${rrd_dir}/cpu_num.rrd':'num':AVERAGE ";
    161                }
    162             $series .="AREA:'load_one'#$load_one_color:'1-min Load' ";
    163             if( $context != "host" )
    164                {
    165                   $series .= "LINE2:'num_nodes'#$num_nodes_color:'Nodes' ";
    166                }
    167             $series .="LINE2:'cpu_num'#$cpu_num_color:'CPUs' ";
    168             $series .="LINE2:'proc_run'#$proc_run_color:'Running Processes' ";
    169          }
    170       else if ($graph == "network_report")
    171          {
    172             $style = "Network";
    173 
    174             $lower_limit = "--lower-limit 0 --rigid";
    175             $extras = "--base 1024";
    176             $vertical_label = "--vertical-label 'Bytes/sec'";
    177 
    178             $series = "DEF:'bytes_in'='${rrd_dir}/bytes_in.rrd':'sum':AVERAGE "
    179                ."DEF:'bytes_out'='${rrd_dir}/bytes_out.rrd':'sum':AVERAGE "
    180                ."LINE2:'bytes_in'#$mem_cached_color:'In' "
    181                ."LINE2:'bytes_out'#$mem_used_color:'Out' ";
    182          }
    183       else if ($graph == "packet_report")
    184          {
    185             $style = "Packets";
    186 
    187             $lower_limit = "--lower-limit 0 --rigid";
    188             $extras = "--base 1024";
    189             $vertical_label = "--vertical-label 'Packets/sec'";
    190 
    191             $series = "DEF:'bytes_in'='${rrd_dir}/pkts_in.rrd':'sum':AVERAGE "
    192                ."DEF:'bytes_out'='${rrd_dir}/pkts_out.rrd':'sum':AVERAGE "
    193                ."LINE2:'bytes_in'#$mem_cached_color:'In' "
    194                ."LINE2:'bytes_out'#$mem_used_color:'Out' ";
    195          }
    196       else
    197          {
    198       /* Custom graph */
    199       $style = "";
    200 
    201       $subtitle = $metricname;
    202       if ($context == "host")
    203       {
    204           if ($size == "small")
    205               $prefix = $metricname;
    206           else
    207               $prefix = $hostname;
    208 
    209           $value = $value>1000 ? number_format($value) : number_format($value, 2);
    210 
    211           if ($range=="job") {
    212                $hrs = intval( -$jobrange / 3600 );
    213                $subtitle = "$prefix last ${hrs}h (now $value)";
    214           }
    215           else
    216               $subtitle = "$prefix last $range (now $value)";
    217       }
    218 
    219       if (is_numeric($max))
    220          $upper_limit = "--upper-limit '$max' ";
    221       if (is_numeric($min))
    222          $lower_limit ="--lower-limit '$min' ";
    223 
    224       if ($vlabel)
    225          $vertical_label = "--vertical-label '$vlabel'";
    226       else if ($upper_limit or $lower_limit)
    227          {
    228             $max = $max>1000 ? number_format($max) : number_format($max, 2);
    229             $min = $min>0 ? number_format($min,2) : $min;
    230 
    231             $vertical_label ="--vertical-label '$min - $max' ";
    232          }
    233 
    234       $rrd_file = "$rrd_dir/$metricname.rrd";
    235       $series = "DEF:'sum'='$rrd_file':'sum':AVERAGE "
    236          ."AREA:'sum'#$default_metric_color:'$subtitle' ";
    237       if ($jobstart)
    238          $series .= "VRULE:$jobstart#$jobstart_color ";
    239     }
    240 
    241 # Set the graph title.
    242 if($context == "meta")
    243    {
    244      $title = "$self $meta_designator $style last $range";
    245    }
    246 else if ($context == "grid")
    247   {
    248      $title = "$grid $meta_designator $style last $range";
    249   }
    250 else if ($context == "cluster")
    251    {
    252       $title = "$clustername $style last $range";
    253    }
    254 else
    255    {
    256     if ($size == "small")
    257       {
    258         # Value for this graph define a background color.
    259         if (!$load_color) $load_color = "ffffff";
    260         $background = "--color BACK#'$load_color'";
    261 
    262         $title = $hostname;
    263       }
    264     else if ($style)
    265        $title = "$hostname $style last $range";
    266     else
    267        $title = $metricname;
    268    }
    269 
    270 # Fix from Phil Radden, but step is not always 15 anymore.
    271 if ($range=="month")
    272    $end = floor($end / 672) * 672;
     25if ($size == "small") {
     26        $height = 40;
     27        $width = 130;
     28} else if ($size == "medium") {
     29        $height = 75;
     30        $width = 300;
     31} else {
     32        $height = 100;
     33        $width = 400;
     34}
     35
     36if($command) {
     37      $command = '';
     38}
     39
     40//printf( "cluster = %s hostname = %s metric = %s\n", $cluster, $hostname, $metricname );
     41
     42$trd = new TarchRrdGraph( $cluster, $hostname );
     43//$rrd_files = $trd->getRrdFiles( $metricname, $start, $stop );
     44
     45//print_r( $rrd_files );
     46
     47$graph = $metricname;
     48
     49if (isset($graph)) {
     50        $rrd_dirs = $trd->getRrdDirs( $start, $stop );
     51        $series = '';
     52
     53        if($graph == "cpu_report") {
     54                $style = "CPU";
     55                //printf("ik doe die shit!\n");
     56
     57                $upper_limit = "--upper-limit 100 --rigid";
     58                $lower_limit = "--lower-limit 0";
     59
     60                $vertical_label = "--vertical-label Percent ";
     61
     62                $def_nr = 0;
     63
     64                foreach( $rrd_dirs as $rrd_dir ) {
     65
     66                        if( $def_nr == 0 ) {
     67
     68                                $user_str = ":'User CPU'";
     69                                $nice_str = ":'Nice CPU'";
     70                                $system_str = ":'System CPU'";
     71                                $wio_str = ":'WAIT CPU'";
     72                                $idle_str = ":'Idle CPU'";
     73                        } else {
     74
     75                                $user_str = "";
     76                                $nice_str = "";
     77                                $system_str = "";
     78                                $wio_str = "";
     79                                $idle_str = "";
     80                        }
     81
     82                        $series .= "DEF:'cpu_user${def_nr}'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
     83                                ."DEF:'cpu_nice${def_nr}'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
     84                                ."DEF:'cpu_system${def_nr}'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
     85                                ."DEF:'cpu_idle${def_nr}'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
     86                                ."AREA:'cpu_user${def_nr}'#${cpu_user_color}${user_str} "
     87                                ."STACK:'cpu_nice${def_nr}'#${cpu_nice_color}${nice_str} "
     88                                ."STACK:'cpu_system${def_nr}'#${cpu_system_color}${system_str} ";
     89
     90                        if (file_exists("$rrd_dir/cpu_wio.rrd")) {
     91                                $series .= "DEF:'cpu_wio${def_nr}'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
     92                                        ."STACK:'cpu_wio${def_nr}'#${cpu_wio_color}${wio_str} ";
     93                        }
     94
     95                        $series .= "STACK:'cpu_idle${def_nr}'#${cpu_idle_color}${idle_str} ";
     96
     97                        $def_nr++;
     98                }
     99
     100        } else if ($graph == "mem_report") {
     101                $style = "Memory";
     102
     103                $lower_limit = "--lower-limit 0 --rigid";
     104                $extras = "--base 1024";
     105                $vertical_label = "--vertical-label Bytes";
     106
     107                $def_nr = 0;
     108
     109                foreach( $rrd_dirs as $rrd_dir ) {
     110
     111                        if( $def_nr == 0 ) {
     112
     113                                $memuse_str = ":'Memory Used'";
     114                                $memshared_str = ":'Memory Shared'";
     115                                $memcached_str = ":'Memory Cached'";
     116                                $membuff_str = ":'Memory Buffered'";
     117                                $memswap_str = ":'Memory Swapped'";
     118                                $total_str = ":'Total In-Core Memory'";
     119                        } else {
     120
     121                                $memuse_str = "";
     122                                $memshared_str = "";
     123                                $memcached_str = "";
     124                                $membuff_str = "";
     125                                $memswap_str = "";
     126                                $total_str = "";
     127                        }
     128
     129                        $series .= "DEF:'mem_total${def_nr}'='${rrd_dir}/mem_total.rrd':'sum':AVERAGE "
     130                                ."CDEF:'bmem_total${def_nr}'=mem_total${def_nr},1024,* "
     131                                ."DEF:'mem_shared${def_nr}'='${rrd_dir}/mem_shared.rrd':'sum':AVERAGE "
     132                                ."CDEF:'bmem_shared${def_nr}'=mem_shared${def_nr},1024,* "
     133                                ."DEF:'mem_free${def_nr}'='${rrd_dir}/mem_free.rrd':'sum':AVERAGE "
     134                                ."CDEF:'bmem_free${def_nr}'=mem_free${def_nr},1024,* "
     135                                ."DEF:'mem_cached${def_nr}'='${rrd_dir}/mem_cached.rrd':'sum':AVERAGE "
     136                                ."CDEF:'bmem_cached${def_nr}'=mem_cached${def_nr},1024,* "
     137                                ."DEF:'mem_buffers${def_nr}'='${rrd_dir}/mem_buffers.rrd':'sum':AVERAGE "
     138                                ."CDEF:'bmem_buffers${def_nr}'=mem_buffers${def_nr},1024,* "
     139                                ."CDEF:'bmem_used${def_nr}'='bmem_total${def_nr}','bmem_shared${def_nr}',-,'bmem_free${def_nr}',-,'bmem_cached${def_nr}',-,'bmem_buffers${def_nr}',- "
     140                                ."AREA:'bmem_used${def_nr}'#${mem_used_color}${memuse_str} "
     141                                ."STACK:'bmem_shared${def_nr}'#${mem_shared_color}${memshared_str} "
     142                                ."STACK:'bmem_cached${def_nr}'#${mem_cached_color}${memcached_str} "
     143                                ."STACK:'bmem_buffers${def_nr}'#${mem_buffered_color}${membuff_str} ";
     144
     145                        if (file_exists("$rrd_dir/swap_total.rrd")) {
     146                                $series .= "DEF:'swap_total${def_nr}'='${rrd_dir}/swap_total.rrd':'sum':AVERAGE "
     147                                        ."DEF:'swap_free${def_nr}'='${rrd_dir}/swap_free.rrd':'sum':AVERAGE "
     148                                        ."CDEF:'bmem_swapped${def_nr}'='swap_total${def_nr}','swap_free${def_nr}',-,1024,* "
     149                                        ."STACK:'bmem_swapped${def_nr}'#${mem_swapped_color}${memswap_str} ";
     150                        }
     151
     152                        $series .= "LINE2:'bmem_total${def_nr}'#${cpu_num_color}${total_str} ";
     153
     154                        $def_nr++;
     155                }
     156
     157        } else if ($graph == "load_report") {
     158                $style = "Load";
     159
     160                $lower_limit = "--lower-limit 0 --rigid";
     161                $vertical_label = "--vertical-label 'Load/Procs'";
     162
     163                $def_nr = 0;
     164
     165                foreach( $rrd_dirs as $rrd_dir ) {
     166
     167                        if( $def_nr == 0 ) {
     168
     169                                $load_str = ":'1-min Load'";
     170                                $cpu_str = ":'CPUs'";
     171                                $run_str = ":'Running Processes'";
     172                        } else {
     173
     174                        }
     175
     176                        $series .= "DEF:'load_one${def_nr}'='${rrd_dir}/load_one.rrd':'sum':AVERAGE "
     177                                ."DEF:'proc_run${def_nr}'='${rrd_dir}/proc_run.rrd':'sum':AVERAGE "
     178                                ."DEF:'cpu_num${def_nr}'='${rrd_dir}/cpu_num.rrd':'sum':AVERAGE ";
     179                        $series .="AREA:'load_one${def_nr}'#${load_one_color}${load_str} ";
     180                        $series .="LINE2:'cpu_num${def_nr}'#${cpu_num_color}${cpu_str} ";
     181                        $series .="LINE2:'proc_run${def_nr}'#${proc_run_color}${run_str} ";
     182
     183                        $def_nr++;
     184                }
     185
     186        } else if ($graph == "network_report") {
     187                $style = "Network";
     188
     189                $lower_limit = "--lower-limit 0 --rigid";
     190                $extras = "--base 1024";
     191                $vertical_label = "--vertical-label 'Bytes/sec'";
     192
     193                $def_nr = 0;
     194
     195                foreach( $rrd_dirs as $rrd_dir ) {
     196
     197                        if( $def_nr == 0 ) {
     198
     199                                $in_str = ":'In'";
     200                                $out_str = ":'Out'";
     201                        } else {
     202
     203                                $in_str = "";
     204                                $out_str = "";
     205                        }
     206
     207                        $series .= "DEF:'bytes_in${def_nr}'='${rrd_dir}/bytes_in.rrd':'sum':AVERAGE "
     208                                ."DEF:'bytes_out${def_nr}'='${rrd_dir}/bytes_out.rrd':'sum':AVERAGE "
     209                                ."LINE2:'bytes_in${def_nr}'#${mem_cached_color}${in_str} "
     210                                ."LINE2:'bytes_out${def_nr}'#${mem_used_color}${out_str} ";
     211
     212                        $def_nr++;
     213                }
     214
     215        } else if ($graph == "packet_report") {
     216                $style = "Packets";
     217
     218                $lower_limit = "--lower-limit 0 --rigid";
     219                $extras = "--base 1024";
     220                $vertical_label = "--vertical-label 'Packets/sec'";
     221
     222                $def_nr = 0;
     223
     224                foreach( $rrd_dirs as $rrd_dir ) {
     225
     226                        if( $def_nr == 0 ) {
     227
     228                                $in_str = ":'In'";
     229                                $out_str = ":'Out'";
     230                        } else {
     231
     232                                $in_str = "";
     233                                $out_str = "";
     234                        }
     235
     236                        $series .= "DEF:'bytes_in${def_nr}'='${rrd_dir}/pkts_in.rrd':'sum':AVERAGE "
     237                                ."DEF:'bytes_out${def_nr}'='${rrd_dir}/pkts_out.rrd':'sum':AVERAGE "
     238                                ."LINE2:'bytes_in${def_nr}'#${mem_cached_color}${in_str} "
     239                                ."LINE2:'bytes_out${def_nr}'#${mem_used_color}${out_str} ";
     240
     241                        $def_nr++;
     242                }
     243
     244        } else {
     245                /* Custom graph */
     246                $style = "";
     247
     248                $subtitle = $metricname;
     249                if ($context == "host") {
     250                        if ($size == "small")
     251                                $prefix = $metricname;
     252                        else
     253                                $prefix = $hostname;
     254
     255                        $value = $value>1000 ? number_format($value) : number_format($value, 2);
     256                }
     257
     258                //if ($range=="job") {
     259                //      $hrs = intval( -$jobrange / 3600 );
     260                //      $subtitle = "$prefix last ${hrs}h (now $value)";
     261                //} else
     262                //      $subtitle = "$prefix last $range (now $value)";
     263
     264                if (is_numeric($max))
     265                        $upper_limit = "--upper-limit '$max' ";
     266                if (is_numeric($min))
     267                        $lower_limit ="--lower-limit '$min' ";
     268
     269                if ($vlabel)
     270                        $vertical_label = "--vertical-label '$vlabel'";
     271                else {
     272                        if ($upper_limit or $lower_limit) {
     273                                $max = $max>1000 ? number_format($max) : number_format($max, 2);
     274                                $min = $min>0 ? number_format($min,2) : $min;
     275
     276                                $vertical_label ="--vertical-label '$min - $max' ";
     277                        }
     278                }
     279
     280                $def_nr = 0;
     281
     282                foreach( $rrd_dirs as $rrd_dir ) {
     283
     284                        if( $def_nr == 0 ) {
     285                                $title_str = ":'${subtitle}'";
     286                        } else {
     287                                $title_str = "";
     288                        }
     289
     290                        $rrd_file = "$rrd_dir/$metricname.rrd";
     291                        $series .= "DEF:'sum${def_nr}'='$rrd_file':'sum':AVERAGE "
     292                                ."AREA:'sum${def_nr}'#${default_metric_color}${title_str} ";
     293
     294                        $def_nr++;
     295                }
     296
     297        }
     298        if( $series != '' ) {
     299                if ($job_start)
     300                        $series .= "VRULE:${job_start}#${jobstart_color} ";
     301                if ($job_stop)
     302                        $series .= "VRULE:${job_stop}#${jobstart_color} ";
     303        }
     304}
     305
     306//$title = "$hostname $style $metricname";
     307$title = "$hostname";
     308
     309//# Set the graph title.
     310//if($context == "meta") {
     311//      $title = "$self $meta_designator $style last $range";
     312//} else if ($context == "grid") {
     313//      $title = "$grid $meta_designator $style last $range";
     314//} else if ($context == "cluster") {
     315//      $title = "$clustername $style last $range";
     316//} else {
     317//      if ($size == "small") {
     318//              # Value for this graph define a background color.
     319//              if (!$load_color) $load_color = "ffffff";
     320//                      $background = "--color BACK#'$load_color'";
     321
     322//              $title = $hostname;
     323//      } else {
     324//              if ($style)
     325//                      $title = "$hostname $style last $range";
     326//              else
     327//                      $title = $metricname;
     328//      }
     329//}
    273330
    274331#
    275332# Generate the rrdtool graph command.
    276333#
    277 $command = RRDTOOL . " graph - --start $start --end $end ".
    278    "--width $width --height $height $upper_limit $lower_limit ".
    279    "--title '$title' $vertical_label $extras $background ".
    280    $series;
     334$command = RRDTOOL . " graph - --start $start --end $stop ".
     335        "--width $width --height $height $upper_limit $lower_limit ".
     336        "--title '$title' $vertical_label $extras $background ".
     337        $series;
    281338
    282339$debug=0;
    283340
    284341# Did we generate a command?   Run it.
    285 if($command)
    286  {
    287    /*Make sure the image is not cached*/
    288    header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // Date in the past
    289    header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
    290    header ("Cache-Control: no-cache, must-revalidate");   // HTTP/1.1
    291    header ("Pragma: no-cache");                     // HTTP/1.0
    292    if ($debug) {
    293      header ("Content-type: text/html");
    294      print "$command\n\n\n\n\n";
    295     }
    296    else {
    297      header ("Content-type: image/gif");
    298      passthru($command);
    299     }
    300  }
    301 
     342if($command) {
     343        /*Make sure the image is not cached*/
     344        header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // Date in the past
     345        header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
     346        header ("Cache-Control: no-cache, must-revalidate");   // HTTP/1.1
     347        header ("Pragma: no-cache");                     // HTTP/1.0
     348        if ($debug) {
     349                header ("Content-type: text/html");
     350                print "$command\n\n\n\n\n";
     351        } else {
     352                header ("Content-type: image/gif");
     353                passthru($command);
     354        }
     355}
    302356?>
    303 
Note: See TracChangeset for help on using the changeset viewer.