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.11 by tdb, Mon Oct 21 13:02:58 2002 UTC vs.
Revision 1.14 by tdb, Sun Aug 1 10:40:32 2004 UTC

# Line 2 | Line 2
2  
3   #
4   # i-scream central monitoring system
5 < # http://www.i-scream.org.uk
5 > # http://www.i-scream.org
6   # Copyright (C) 2000-2002 i-scream
7   #
8   # This program is free software; you can redistribute it and/or
# Line 22 | Line 22
22  
23   # -----------------------------------------------------------
24   # i-scream graph generation script
25 < # http://www.i-scream.org.uk
25 > # http://www.i-scream.org
26   #
27   # Generates graphs from rrd databases for i-scream data.
28   #
# 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 +
42   my($version) = '$Id$';
43  
44   $| = 1;
# Line 101 | Line 105 | if($opts{q}) {
105   # Read the contents of the base directory
106   # and pull out the list of subdirectories (except . and .. :)
107   opendir(DIR, $rrddir);
108 < my(@rrddirlist) = grep { -d "$rrddir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR);
108 > my(@rrddirlist) = sort grep { -d "$rrddir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR);
109   closedir DIR;
110  
111 < # look through each directoty, as they might
111 > # look through each directory, as they might
112   # contain rrds for a particular machine
113   foreach my $machine (@rrddirlist) {
114      # Read the contents of the directory
# Line 135 | Line 139 | foreach my $machine (@rrddirlist) {
139          if($rrd =~ /^(cpu)\.rrd$/) {
140              my(@data);
141              my(@rawdata);
142 <            push @data, "LINE2:$1:idle:idle#00FF00:OK:idle cpu  ";
143 <            push @data, "LINE2:$1:user:user#0000FF:OK:user cpu  ";
144 <            push @data, "LINE2:$1:kernel:kernel#00FFFF:OK:kernel cpu";
145 <            push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu  ";
146 <            push @data, "LINE2:$1:iowait:iowait#FF0000:OK:iowait cpu";
142 >            push @data, "AREA:$1:swap:swap#FF00FF:OK:swap cpu  ";
143 >            push @data, "STACK:$1:iowait:iowait#FF0000:OK:iowait cpu";
144 >            push @data, "STACK:$1:kernel:kernel#00FFFF:OK:kernel cpu";
145 >            push @data, "STACK:$1:user:user#0000FF:OK:user cpu  ";
146 >            #push @data, "STACK:$1:idle:idle#00FF00:OK:idle cpu  ";
147              push @rawdata, "--upper-limit=100";
148              &makegraph($machine, $1, "CPU Usage for $machine", "% cpu time", \@data, \@rawdata);
149          }
# Line 150 | Line 154 | foreach my $machine (@rrddirlist) {
154              # although we need it to work out peruse...
155              push @data, "NONE:$1:free:free#CCCCFF:NONE:free memory";
156              push @data, "NONE:$1:total:total#0000FF:NONE:total memory\\n";
157 +            push @data, "NONE:$1:cache:cache#0000FF:NONE:cache memory\\n";
158              # calculate peruse - note that we only use 'free' if it's less than total
159              # (this is to avoid negative percentages :)
160              push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*";
161 +            push @rawdata, "CDEF:percacuse=cache,total,LT,cache,0,IF,total,/,100,*";
162              # and add it to the graph
163              push @rawdata, "AREA:peruse#CCCCFF:% memory in use";
158            push @rawdata, "--upper-limit=100";
159            # add some nice values to the legend
164              &addlegend(\@rawdata, "peruse");
165 +            push @rawdata, "LINE2:percacuse#0000FF:% memory cache ";
166 +            &addlegend(\@rawdata, "percacuse");
167 +            push @rawdata, "--upper-limit=100";
168 +            push @rawdata, "--base=1024";
169              # put the total memory on the graph so we can map percentages to real values
170 <            push @rawdata, "GPRINT:total:LAST:Current total memory\\: \%.2lf %sMb\\c";
170 >            push @rawdata, "GPRINT:total:LAST:Current total memory\\: \%.2lf %sb\\c";
171              &makegraph($machine, $1, "Memory Usage for $machine", "% memory in use", \@data, \@rawdata);
172          }
173          if($rrd =~ /^(load)\.rrd$/) {
# Line 171 | Line 179 | foreach my $machine (@rrddirlist) {
179          }
180          if($rrd =~ /^(proc)\.rrd$/) {
181              my(@data);
182 <            push @data, "LINE2:$1:cpu:cpu#00FF00:OK:cpu processes     ";
183 <            push @data, "LINE2:$1:sleeping:sleeping#0000FF:OK:sleeping processes";
184 <            push @data, "LINE2:$1:stopped:stopped#00FFFF:OK:stopped processes ";
185 <            push @data, "LINE2:$1:total:total#FF00FF:OK:total processes   ";
186 <            push @data, "LINE2:$1:zombie:zombie#FF0000:OK:zombie processes  ";
182 >            push @data, "AREA:$1:stopped:stopped#00FFFF:OK:stopped processes ";
183 >            push @data, "STACK:$1:zombie:zombie#FF0000:OK:zombie processes  ";
184 >            push @data, "STACK:$1:cpu:cpu#00FF00:OK:cpu processes     ";
185 >            push @data, "STACK:$1:sleeping:sleeping#0000FF:OK:sleeping processes";
186 >            #push @data, "LINE2:$1:total:total#FF00FF:OK:total processes   ";
187              &makegraph($machine, $1, "Processes on $machine", "no. of processes", \@data);
188          }
189          if($rrd =~ /^(swap)\.rrd$/) {
# Line 191 | Line 199 | foreach my $machine (@rrddirlist) {
199              # and add it to the graph
200              push @rawdata, "AREA:peruse#CCCCFF:% swap in use";
201              push @rawdata, "--upper-limit=100";
202 +            push @rawdata, "--base=1024";
203              # add some nice values to the legend
204              &addlegend(\@rawdata, "peruse");
205              # put the total swap on the graph so we can map percentages to real values
206 <            push @rawdata, "GPRINT:total:LAST:Current total swap\\: \%.2lf %sMb\\c";
206 >            push @rawdata, "GPRINT:total:LAST:Current total swap\\: \%.2lf %sb\\c";
207              &makegraph($machine, $1, "Swap Usage for $machine", "% swap in use", \@data, \@rawdata);
208          }
209          if($rrd =~ /^(users)\.rrd$/) {
# Line 204 | Line 213 | foreach my $machine (@rrddirlist) {
213          }
214          if($rrd =~ /^(paging)\.rrd$/) {
215              my(@data);
216 <            push @data, "LINE2:$1:swapins:swapins#00FF00:OK:swap pages in ";
217 <            push @data, "LINE2:$1:swapouts:swapouts#0000FF:OK:swap pages out";
216 >            push @data, "AREA:$1:pageins:pageins#00FF00:OK:pages paged in ";
217 >            push @data, "LINE2:$1:pageouts:pageouts#0000FF:OK:pages paged out";
218              &makegraph($machine, $1, "Paging on $machine", "pages per second", \@data);
219          }
220 <        if($rrd =~ /^(disk)-(\S+).rrd$/) {
220 >        if($rrd =~ /^(disk)-(\S+)\.rrd$/) {
221              my(@data);
222              my(@rawdata);
223              # we need this lot for our calculations, but we'll never show them
224 <            push @data, "NONE:$1-$2:kbytes:kbytes#0000FF:NONE:total size\\n";
224 >            push @data, "NONE:$1-$2:total:total#0000FF:NONE:total size\\n";
225              push @data, "NONE:$1-$2:used:used#CCCCFF:NONE:used space";
226              push @data, "NONE:$1-$2:totalinodes:totalinodes#000000:NONE:total inodes";
227              push @data, "NONE:$1-$2:freeinodes:freeinodes#000000:NONE:free inodes";
228              # calculate peruse, add it to the graph, and add a legend
229 <            push @rawdata, "CDEF:peruse=used,kbytes,/,100,*";
229 >            push @rawdata, "CDEF:peruse=used,total,/,100,*";
230              push @rawdata, "AREA:peruse#CCCCFF:% disk used  ";
231              &addlegend(\@rawdata, "peruse");
232              # put the total space on the graph so we can map percentages to real values
233 <            push @rawdata, "GPRINT:kbytes:LAST:Current total space\\: \%.2lf %sKb\\c";
233 >            push @rawdata, "GPRINT:total:LAST:Current total space\\: \%.2lf %sb\\c";
234              # calculate perinodeuse, add it to the graph, and add a legend
235              push @rawdata, "CDEF:perinodeuse=totalinodes,freeinodes,totalinodes,LT,freeinodes,0,IF,-,totalinodes,/,100,*";
236              push @rawdata, "LINE2:perinodeuse#FF4444:% inodes used";
237              push @rawdata, "--upper-limit=100";
238 +            push @rawdata, "--base=1024";
239              &addlegend(\@rawdata, "perinodeuse");
240              # put the total inodes on the graph so we can map percentages to real values
241              push @rawdata, "GPRINT:totalinodes:LAST:Current total inodes\\: \%.2lf %s\\c";
# Line 237 | Line 247 | foreach my $machine (@rrddirlist) {
247              $nicename =~ s/$hex_underscore/_/g;
248              &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", "% usage", \@data, \@rawdata);
249          }
250 +        if($rrd =~ /^(diskio)-(\S+)\.rrd$/) {
251 +            my(@data);
252 +            my(@rawdata);
253 +            push @data, "AREA:$1-$2:rbytes:rbytes#00FF00:OK:read bytes ";
254 +            push @data, "LINE2:$1-$2:wbytes:wbytes#0000FF:OK:write bytes";
255 +            push @rawdata, "--base=1024";
256 +            &makegraph($machine, "$1-$2", "Disk IO for $machine on $2", "bytes per second", \@data, \@rawdata);
257 +        }
258 +        if($rrd =~ /^(net)-(\S+)\.rrd$/) {
259 +            my(@data);
260 +            my(@rawdata);
261 +            push @data, "AREA:$1-$2:rx:rx#00FF00:OK:received bytes  ";
262 +            push @data, "LINE2:$1-$2:tx:tx#0000FF:OK:transfered bytes";
263 +            push @rawdata, "--base=1024";
264 +            &makegraph($machine, "$1-$2", "Network IO for $machine on $2", "bytes per second", \@data, \@rawdata);
265 +        }
266 +        if($rrd =~ /^(mailq)-(\S+)\.rrd$/) {
267 +            my(@data);
268 +            my(@rawdata);
269 +            push @data, "LINE2:$1-$2:size:size#0000FF:OK:messages";
270 +            &makegraph($machine, "$1-$2", "Mail Queue ($2) Size for $machine", "messages in queue", \@data, \@rawdata);
271 +        }
272          # probably a queue with a name like this :)
273          if($rrd =~ /^(\d+)_0\.rrd$/) {
274              my(@data);
# Line 276 | Line 308 | if($deleteimgs) {
308      # Read the contents of the graphs directory
309      # and pull out the list of subdirectories (except . and .. :)
310      opendir(DIR, $imgdir);
311 <    my(@imgdirlist) = grep { -d "$imgdir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR);
311 >    my(@imgdirlist) = sort grep { -d "$imgdir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR);
312      closedir DIR;
313  
314      # look through each directoty, as they might
# Line 399 | Line 431 | sub addlegend() {
431      push @$dataref, "GPRINT:$name:LAST:Current\\: \%8.2lf %s";
432      push @$dataref, "GPRINT:$name:AVERAGE:Average\\: \%8.2lf %s";
433      push @$dataref, "GPRINT:$name:MAX:Max\\: \%8.2lf %s\\n";
402    #push @$dataref, "GPRINT:$name:MIN:Min\\: \%8.2lf %s\\n";
434   }
435  
436   # hacky subroutine to return a colour

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines