ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/reports/rrdgraphing/graph.pl
(Generate patch)

Comparing projects/cms/source/reports/rrdgraphing/graph.pl (file contents):
Revision 1.14 by tdb, Sun Aug 1 10:40:32 2004 UTC vs.
Revision 1.19 by tdb, Wed Jun 29 10:26:40 2005 UTC

# Line 35 | Line 35
35   #  -- allow configurable periods of graphs
36   #  -- comments, types, etc
37  
38 BEGIN {
39    push (@INC, "/usr/local/packages/rrdtool/lib/perl5/site_perl/5.8.2/sun4-solaris");
40 }
41
38   my($version) = '$Id$';
39  
40   $| = 1;
# Line 49 | Line 45 | use RRDs;
45  
46   # define variables that will be read from the config
47   # nb. keep this insync with the config file!
48 < use vars qw{
49 <    $imgdir $rrddir                    
48 > use vars qw{
49 >    $imgdir $rrddir
50      $maxrrdage $maximgage $deleterrds $deleteimgs
51 <    $hex_slash $hex_underscore  
51 >    $hex_slash $hex_underscore $hex_space $hex_colon $hex_bslash $hex_rbracket
52 >    $hex_lbracket $hex_plus $hex_hash
53      $rrdstep $retry_wait
54      $verbose $quiet
55   };
# Line 143 | Line 140 | foreach my $machine (@rrddirlist) {
140              push @data, "STACK:$1:iowait:iowait#FF0000:OK:iowait cpu";
141              push @data, "STACK:$1:kernel:kernel#00FFFF:OK:kernel cpu";
142              push @data, "STACK:$1:user:user#0000FF:OK:user cpu  ";
143 <            #push @data, "STACK:$1:idle:idle#00FF00:OK:idle cpu  ";
143 >            push @data, "LINE2:$1:idle:idle#00FF00:OK:idle cpu  ";
144              push @rawdata, "--upper-limit=100";
145              &makegraph($machine, $1, "CPU Usage for $machine", "% cpu time", \@data, \@rawdata);
146          }
147 +        if($rrd =~ /^(uptime)\.rrd$/) {
148 +            my(@data);
149 +            push @data, "LINE2:$1:uptime:uptime#0000FF:OK:uptime";
150 +            &makegraph($machine, $1, "Uptime for $machine", "uptime in seconds", \@data);
151 +        }
152          if($rrd =~ /^(mem)\.rrd$/) {
153              my(@data);
154              my(@rawdata);
# Line 155 | Line 157 | foreach my $machine (@rrddirlist) {
157              push @data, "NONE:$1:free:free#CCCCFF:NONE:free memory";
158              push @data, "NONE:$1:total:total#0000FF:NONE:total memory\\n";
159              push @data, "NONE:$1:cache:cache#0000FF:NONE:cache memory\\n";
160 <            # calculate peruse - note that we only use 'free' if it's less than total
161 <            # (this is to avoid negative percentages :)
162 <            push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*";
163 <            push @rawdata, "CDEF:percacuse=cache,total,LT,cache,0,IF,total,/,100,*";
160 >            # calculate peruse - note that we only use 'free' if it's
161 >            # less or equal to total (this is to avoid negative percentages :)
162 >            push @rawdata, "CDEF:peruse=total,free,total,LE,free,0,IF,-,total,/,100,*";
163 >            push @rawdata, "CDEF:percacuse=cache,total,LE,cache,0,IF,total,/,100,*";
164              # and add it to the graph
165              push @rawdata, "AREA:peruse#CCCCFF:% memory in use";
166              &addlegend(\@rawdata, "peruse");
# Line 183 | Line 185 | foreach my $machine (@rrddirlist) {
185              push @data, "STACK:$1:zombie:zombie#FF0000:OK:zombie processes  ";
186              push @data, "STACK:$1:cpu:cpu#00FF00:OK:cpu processes     ";
187              push @data, "STACK:$1:sleeping:sleeping#0000FF:OK:sleeping processes";
188 <            #push @data, "LINE2:$1:total:total#FF00FF:OK:total processes   ";
188 >            push @data, "LINE2:$1:total:total#FF00FF:OK:total processes   ";
189              &makegraph($machine, $1, "Processes on $machine", "no. of processes", \@data);
190          }
191          if($rrd =~ /^(swap)\.rrd$/) {
# Line 193 | Line 195 | foreach my $machine (@rrddirlist) {
195              # although we need it to work out peruse...
196              push @data, "NONE:$1:free:free#CCCCFF:NONE:free swap";
197              push @data, "NONE:$1:total:total#0000FF:NONE:total swap\\n";
198 <            # calculate peruse - note that we only use 'free' if it's less than total
199 <            # (this is to avoid negative percentages :)
200 <            push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*";
198 >            # calculate peruse - note that we only use 'free' if it's
199 >            # less or equal to total (this is to avoid negative percentages :)
200 >            push @rawdata, "CDEF:peruse=total,free,total,LE,free,0,IF,-,total,/,100,*";
201              # and add it to the graph
202              push @rawdata, "AREA:peruse#CCCCFF:% swap in use";
203              push @rawdata, "--upper-limit=100";
# Line 245 | Line 247 | foreach my $machine (@rrddirlist) {
247              my($nicename) = $2;
248              $nicename =~ s/$hex_slash/\//g;
249              $nicename =~ s/$hex_underscore/_/g;
250 +            $nicename =~ s/$hex_bslash/\\/g;
251 +            $nicename =~ s/$hex_space/ /g;
252 +            $nicename =~ s/$hex_colon/:/g;
253              &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", "% usage", \@data, \@rawdata);
254          }
255          if($rrd =~ /^(diskio)-(\S+)\.rrd$/) {
# Line 253 | Line 258 | foreach my $machine (@rrddirlist) {
258              push @data, "AREA:$1-$2:rbytes:rbytes#00FF00:OK:read bytes ";
259              push @data, "LINE2:$1-$2:wbytes:wbytes#0000FF:OK:write bytes";
260              push @rawdata, "--base=1024";
261 <            &makegraph($machine, "$1-$2", "Disk IO for $machine on $2", "bytes per second", \@data, \@rawdata);
261 >            # some name tidying
262 >            my($type) = $1;
263 >            my($name) = $2;
264 >            my($nicename) = $2;
265 >            $nicename =~ s/$hex_slash/\//g;
266 >            $nicename =~ s/$hex_underscore/_/g;
267 >            $nicename =~ s/$hex_bslash/\\/g;
268 >            $nicename =~ s/$hex_space/ /g;
269 >            $nicename =~ s/$hex_colon/:/g;
270 >            &makegraph($machine, "$type-$name", "Disk IO for $machine on $nicename", "bytes per second", \@data, \@rawdata);
271          }
272          if($rrd =~ /^(net)-(\S+)\.rrd$/) {
273              my(@data);
# Line 261 | Line 275 | foreach my $machine (@rrddirlist) {
275              push @data, "AREA:$1-$2:rx:rx#00FF00:OK:received bytes  ";
276              push @data, "LINE2:$1-$2:tx:tx#0000FF:OK:transfered bytes";
277              push @rawdata, "--base=1024";
278 <            &makegraph($machine, "$1-$2", "Network IO for $machine on $2", "bytes per second", \@data, \@rawdata);
278 >            # some name tidying
279 >            my($type) = $1;
280 >            my($name) = $2;
281 >            my($nicename) = $2;
282 >            $nicename =~ s/$hex_slash/\//g;
283 >            $nicename =~ s/$hex_underscore/_/g;
284 >            $nicename =~ s/$hex_bslash/\\/g;
285 >            $nicename =~ s/$hex_space/ /g;
286 >            $nicename =~ s/$hex_colon/:/g;
287 >            $nicename =~ s/$hex_lbracket/(/g;
288 >            $nicename =~ s/$hex_rbracket/)/g;
289 >            $nicename =~ s/$hex_plus/+/g;
290 >            $nicename =~ s/$hex_hash/#/g;
291 >            &makegraph($machine, "$type-$name", "Network IO for $machine on $nicename", "bytes per second", \@data, \@rawdata);
292          }
293          if($rrd =~ /^(mailq)-(\S+)\.rrd$/) {
294              my(@data);
# Line 311 | Line 338 | if($deleteimgs) {
338      my(@imgdirlist) = sort grep { -d "$imgdir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR);
339      closedir DIR;
340  
341 <    # look through each directoty, as they might
341 >    # look through each directory, as they might
342      # contain images for a particular machine
343      foreach my $machine (@imgdirlist) {
344          # Read the contents of the directory

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines