2 |
|
|
3 |
|
# |
4 |
|
# i-scream central monitoring system |
5 |
+ |
# http://www.i-scream.org.uk |
6 |
|
# Copyright (C) 2000-2002 i-scream |
7 |
|
# |
8 |
|
# This program is free software; you can redistribute it and/or |
146 |
|
if($rrd =~ /^(mem)\.rrd$/) { |
147 |
|
my(@data); |
148 |
|
my(@rawdata); |
149 |
< |
# we don't actually want to display free memory, |
150 |
< |
# although we need it to do inuse... |
149 |
> |
# we don't actually want to display free or total memory, |
150 |
> |
# although we need it to work out peruse... |
151 |
|
push @data, "NONE:$1:free:free#CCCCFF:NONE:free memory"; |
152 |
< |
push @data, "LINE2:$1:total:total#0000FF:NONE:total memory\\n"; |
153 |
< |
# calculate inuse |
154 |
< |
push @rawdata, "CDEF:inuse=total,free,-"; |
152 |
> |
push @data, "NONE:$1:total:total#0000FF:NONE:total memory\\n"; |
153 |
> |
# calculate peruse - note that we only use 'free' if it's less than total |
154 |
> |
# (this is to avoid negative percentages :) |
155 |
> |
push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*"; |
156 |
|
# and add it to the graph |
157 |
< |
push @rawdata, "AREA:inuse#CCCCFF:memory in use"; |
157 |
> |
push @rawdata, "AREA:peruse#CCCCFF:% memory in use"; |
158 |
> |
push @rawdata, "--upper-limit=100"; |
159 |
|
push @rawdata, "--base=1024"; |
160 |
|
# add some nice values to the legend |
161 |
< |
&addlegend(\@rawdata, "inuse"); |
162 |
< |
&makegraph($machine, $1, "Memory Usage for $machine", "megabytes", \@data, \@rawdata); |
161 |
> |
&addlegend(\@rawdata, "peruse"); |
162 |
> |
# put the total memory on the graph so we can map percentages to real values |
163 |
> |
push @rawdata, "GPRINT:total:LAST:Current total memory\\: \%.2lf %sb\\c"; |
164 |
> |
&makegraph($machine, $1, "Memory Usage for $machine", "% memory in use", \@data, \@rawdata); |
165 |
|
} |
166 |
|
if($rrd =~ /^(load)\.rrd$/) { |
167 |
|
my(@data); |
182 |
|
if($rrd =~ /^(swap)\.rrd$/) { |
183 |
|
my(@data); |
184 |
|
my(@rawdata); |
185 |
< |
# we don't actually want to display free swap, |
186 |
< |
# although we need it to do inuse... |
185 |
> |
# we don't actually want to display free or total swap, |
186 |
> |
# although we need it to work out peruse... |
187 |
|
push @data, "NONE:$1:free:free#CCCCFF:NONE:free swap"; |
188 |
< |
push @data, "LINE2:$1:total:total#0000FF:NONE:total swap\\n"; |
189 |
< |
# calculate inuse |
190 |
< |
push @rawdata, "CDEF:inuse=total,free,-"; |
188 |
> |
push @data, "NONE:$1:total:total#0000FF:NONE:total swap\\n"; |
189 |
> |
# calculate peruse - note that we only use 'free' if it's less than total |
190 |
> |
# (this is to avoid negative percentages :) |
191 |
> |
push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*"; |
192 |
|
# and add it to the graph |
193 |
< |
push @rawdata, "AREA:inuse#CCCCFF:swap in use"; |
193 |
> |
push @rawdata, "AREA:peruse#CCCCFF:% swap in use"; |
194 |
> |
push @rawdata, "--upper-limit=100"; |
195 |
|
push @rawdata, "--base=1024"; |
196 |
|
# add some nice values to the legend |
197 |
< |
&addlegend(\@rawdata, "inuse"); |
198 |
< |
&makegraph($machine, $1, "Swap Usage for $machine", "megabytes", \@data, \@rawdata); |
197 |
> |
&addlegend(\@rawdata, "peruse"); |
198 |
> |
# put the total swap on the graph so we can map percentages to real values |
199 |
> |
push @rawdata, "GPRINT:total:LAST:Current total swap\\: \%.2lf %sb\\c"; |
200 |
> |
&makegraph($machine, $1, "Swap Usage for $machine", "% swap in use", \@data, \@rawdata); |
201 |
|
} |
202 |
|
if($rrd =~ /^(users)\.rrd$/) { |
203 |
|
my(@data); |
204 |
|
push @data, "AREA:$1:count:count#CCCCFF:OK:user count"; |
205 |
|
&makegraph($machine, $1, "User Count for $machine", "no. of users", \@data); |
206 |
|
} |
207 |
< |
if($rrd =~ /^(disk)-(\S+).rrd$/) { |
207 |
> |
if($rrd =~ /^(paging)\.rrd$/) { |
208 |
|
my(@data); |
209 |
+ |
push @data, "LINE2:$1:pageins:pageins#00FF00:OK:pages paged in "; |
210 |
+ |
push @data, "LINE2:$1:pageouts:pageouts#0000FF:OK:pages paged out"; |
211 |
+ |
&makegraph($machine, $1, "Paging on $machine", "pages per second", \@data); |
212 |
+ |
} |
213 |
+ |
if($rrd =~ /^(disk)-(\S+)\.rrd$/) { |
214 |
+ |
my(@data); |
215 |
|
my(@rawdata); |
216 |
< |
push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:NONE:total size\\n"; |
217 |
< |
push @data, "AREA:$1-$2:used:used#CCCCFF:OK:used space"; |
216 |
> |
# we need this lot for our calculations, but we'll never show them |
217 |
> |
push @data, "NONE:$1-$2:total:total#0000FF:NONE:total size\\n"; |
218 |
> |
push @data, "NONE:$1-$2:used:used#CCCCFF:NONE:used space"; |
219 |
> |
push @data, "NONE:$1-$2:totalinodes:totalinodes#000000:NONE:total inodes"; |
220 |
> |
push @data, "NONE:$1-$2:freeinodes:freeinodes#000000:NONE:free inodes"; |
221 |
> |
# calculate peruse, add it to the graph, and add a legend |
222 |
> |
push @rawdata, "CDEF:peruse=used,total,/,100,*"; |
223 |
> |
push @rawdata, "AREA:peruse#CCCCFF:% disk used "; |
224 |
> |
&addlegend(\@rawdata, "peruse"); |
225 |
> |
# put the total space on the graph so we can map percentages to real values |
226 |
> |
push @rawdata, "GPRINT:total:LAST:Current total space\\: \%.2lf %sb\\c"; |
227 |
> |
# calculate perinodeuse, add it to the graph, and add a legend |
228 |
> |
push @rawdata, "CDEF:perinodeuse=totalinodes,freeinodes,totalinodes,LT,freeinodes,0,IF,-,totalinodes,/,100,*"; |
229 |
> |
push @rawdata, "LINE2:perinodeuse#FF4444:% inodes used"; |
230 |
> |
push @rawdata, "--upper-limit=100"; |
231 |
|
push @rawdata, "--base=1024"; |
232 |
+ |
&addlegend(\@rawdata, "perinodeuse"); |
233 |
+ |
# put the total inodes on the graph so we can map percentages to real values |
234 |
+ |
push @rawdata, "GPRINT:totalinodes:LAST:Current total inodes\\: \%.2lf %s\\c"; |
235 |
+ |
# some name tidting |
236 |
|
my($type) = $1; |
237 |
|
my($name) = $2; |
238 |
|
my($nicename) = $2; |
239 |
|
$nicename =~ s/$hex_slash/\//g; |
240 |
|
$nicename =~ s/$hex_underscore/_/g; |
241 |
< |
&makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", "kilobytes", \@data, \@rawdata); |
241 |
> |
&makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", "% usage", \@data, \@rawdata); |
242 |
|
} |
243 |
+ |
if($rrd =~ /^(diskio)-(\S+)\.rrd$/) { |
244 |
+ |
my(@data); |
245 |
+ |
my(@rawdata); |
246 |
+ |
push @data, "LINE2:$1-$2:rbytes:rbytes#00FF00:OK:read bytes "; |
247 |
+ |
push @data, "LINE2:$1-$2:wbytes:wbytes#0000FF:OK:write bytes"; |
248 |
+ |
push @rawdata, "--base=1024"; |
249 |
+ |
&makegraph($machine, "$1-$2", "Disk IO for $machine on $2", "bytes per second", \@data, \@rawdata); |
250 |
+ |
} |
251 |
+ |
if($rrd =~ /^(net)-(\S+)\.rrd$/) { |
252 |
+ |
my(@data); |
253 |
+ |
my(@rawdata); |
254 |
+ |
push @data, "LINE2:$1-$2:rx:rx#00FF00:OK:received bytes "; |
255 |
+ |
push @data, "LINE2:$1-$2:tx:tx#0000FF:OK:transfered bytes"; |
256 |
+ |
push @rawdata, "--base=1024"; |
257 |
+ |
&makegraph($machine, "$1-$2", "Network IO for $machine on $2", "bytes per second", \@data, \@rawdata); |
258 |
+ |
} |
259 |
|
# probably a queue with a name like this :) |
260 |
|
if($rrd =~ /^(\d+)_0\.rrd$/) { |
261 |
|
my(@data); |
418 |
|
push @$dataref, "GPRINT:$name:LAST:Current\\: \%8.2lf %s"; |
419 |
|
push @$dataref, "GPRINT:$name:AVERAGE:Average\\: \%8.2lf %s"; |
420 |
|
push @$dataref, "GPRINT:$name:MAX:Max\\: \%8.2lf %s\\n"; |
373 |
– |
#push @$dataref, "GPRINT:$name:MIN:Min\\: \%8.2lf %s\\n"; |
421 |
|
} |
422 |
|
|
423 |
|
# hacky subroutine to return a colour |