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; |
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 |
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 |
|
} |
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"; |
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"; |
160 |
– |
# add some nice values to the legend |
161 |
– |
&addlegend(\@rawdata, "peruse"); |
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 %sb\\c"; |
171 |
|
&makegraph($machine, $1, "Memory Usage for $machine", "% memory in use", \@data, \@rawdata); |
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$/) { |
213 |
|
} |
214 |
|
if($rrd =~ /^(paging)\.rrd$/) { |
215 |
|
my(@data); |
216 |
< |
push @data, "LINE2:$1:pageins:pageins#00FF00:OK:pages paged in "; |
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 |
|
} |
250 |
|
if($rrd =~ /^(diskio)-(\S+)\.rrd$/) { |
251 |
|
my(@data); |
252 |
|
my(@rawdata); |
253 |
< |
push @data, "LINE2:$1-$2:rbytes:rbytes#00FF00:OK:read bytes "; |
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); |
258 |
|
if($rrd =~ /^(net)-(\S+)\.rrd$/) { |
259 |
|
my(@data); |
260 |
|
my(@rawdata); |
261 |
< |
push @data, "LINE2:$1-$2:rx:rx#00FF00:OK:received bytes "; |
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); |
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 |