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 |
141 |
|
push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu "; |
142 |
|
push @data, "LINE2:$1:iowait:iowait#FF0000:OK:iowait cpu"; |
143 |
|
push @rawdata, "--upper-limit=100"; |
144 |
< |
&makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata); |
144 |
> |
&makegraph($machine, $1, "CPU Usage for $machine", "% cpu time", \@data, \@rawdata); |
145 |
|
} |
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", \@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); |
168 |
|
push @data, "LINE2:$1:load1:load1#CCCCFF:OK: 1 min load average"; |
169 |
|
push @data, "LINE2:$1:load5:load5#7777FF:OK: 5 min load average"; |
170 |
|
push @data, "LINE2:$1:load15:load15#0000FF:OK:15 min load average"; |
171 |
< |
&makegraph($machine, $1, "Loads for $machine", \@data); |
171 |
> |
&makegraph($machine, $1, "Loads for $machine", "load average", \@data); |
172 |
|
} |
173 |
|
if($rrd =~ /^(proc)\.rrd$/) { |
174 |
|
my(@data); |
177 |
|
push @data, "LINE2:$1:stopped:stopped#00FFFF:OK:stopped processes "; |
178 |
|
push @data, "LINE2:$1:total:total#FF00FF:OK:total processes "; |
179 |
|
push @data, "LINE2:$1:zombie:zombie#FF0000:OK:zombie processes "; |
180 |
< |
&makegraph($machine, $1, "Processes on $machine", \@data); |
180 |
> |
&makegraph($machine, $1, "Processes on $machine", "no. of processes", \@data); |
181 |
|
} |
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", \@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", \@data); |
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", \@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); |
266 |
|
push @data, "LINE2:$baserrd\_$i:size:size$i" . &get_colour($i) . ":OK:queue$i size "; |
267 |
|
++$i; |
268 |
|
} |
269 |
< |
push @data, "LINE2:$baserrd\_0:total:total#FF0000:OK:packets/sec"; |
269 |
> |
push @data, "LINE2:$baserrd\_0:total:total#FF0000:OK:packets/sec "; |
270 |
|
my($comment); |
271 |
|
if(-f "$rrddir/$machine/$baserrd.def") { |
272 |
|
open(DEF, "$rrddir/$machine/$baserrd.def"); |
274 |
|
chomp $comment if defined $comment; |
275 |
|
} |
276 |
|
$comment = "unknown queue" if not defined $comment; |
277 |
< |
&makegraph($machine, $baserrd, $comment, \@data, \@rawdata); |
277 |
> |
&makegraph($machine, $baserrd, $comment, "", \@data, \@rawdata); |
278 |
|
} |
279 |
|
} |
280 |
|
# have a last check, maybe we can remove the directory now? |
343 |
|
# (eg. cpu) |
344 |
|
# $title = the title for the graph |
345 |
|
# (eg. kernow CPU usage) |
346 |
+ |
# $vlabel = the vertical label to apply to the left side of the graph |
347 |
+ |
# (eg. kb/s) |
348 |
|
# $dataref = a reference to an array containing information for the graph |
349 |
|
# elements of format: "gtype:rrdname:dsname:name#colour:legend:comment with spaces" |
350 |
|
# (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted) |
354 |
|
# |
355 |
|
|
356 |
|
sub makegraph() { |
357 |
< |
my($machine, $type, $title, $dataref, $rawcmdref) = @_; |
357 |
> |
my($machine, $type, $title, $vlabel, $dataref, $rawcmdref) = @_; |
358 |
|
# pass in these arrays by reference |
359 |
|
my(@data) = @$dataref if defined $dataref; |
360 |
|
my(@rawcmd) = @$rawcmdref if defined $rawcmdref; |
383 |
|
push @rrdcmd, "--title=$title"; |
384 |
|
push @rrdcmd, "--imgformat=PNG"; |
385 |
|
push @rrdcmd, "--lower-limit=0"; |
386 |
+ |
push @rrdcmd, "--vertical-label=$vlabel"; |
387 |
|
# not entirely convinced this is good... |
388 |
|
push @rrdcmd, "--alt-autoscale-max"; |
389 |
|
# add any further raw commands |
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"; |
370 |
– |
#push @$dataref, "GPRINT:$name:MIN:Min\\: \%8.2lf %s\\n"; |
421 |
|
} |
422 |
|
|
423 |
|
# hacky subroutine to return a colour |