97 |
|
$verbose = 0; |
98 |
|
} |
99 |
|
|
100 |
– |
|
100 |
|
# Read the contents of the base directory |
101 |
|
# and pull out the list of subdirectories (except . and .. :) |
102 |
|
opendir(DIR, $rrddir); |
134 |
|
if($rrd =~ /^(cpu)\.rrd$/) { |
135 |
|
my(@data); |
136 |
|
my(@rawdata); |
137 |
< |
push @data, "LINE2:$1:idle:idle#00FF00:OK:idle cpu"; |
138 |
< |
push @data, "LINE2:$1:user:user#0000FF:OK:user cpu"; |
137 |
> |
push @data, "LINE2:$1:idle:idle#00FF00:OK:idle cpu "; |
138 |
> |
push @data, "LINE2:$1:user:user#0000FF:OK:user cpu "; |
139 |
|
push @data, "LINE2:$1:kernel:kernel#00FFFF:OK:kernel cpu"; |
140 |
< |
push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu"; |
140 |
> |
push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu "; |
141 |
|
push @data, "LINE2:$1:iowait:iowait#FF0000:OK:iowait cpu"; |
142 |
|
push @rawdata, "--upper-limit=100"; |
143 |
|
&makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata); |
148 |
|
# we don't actually want to display free memory, |
149 |
|
# although we need it to do inuse... |
150 |
|
push @data, "NONE:$1:free:free#CCCCFF:NONE:free memory"; |
151 |
< |
push @data, "LINE2:$1:total:total#0000FF:NONE:total memory"; |
151 |
> |
push @data, "LINE2:$1:total:total#0000FF:NONE:total memory\\n"; |
152 |
|
# calculate inuse |
153 |
|
push @rawdata, "CDEF:inuse=total,free,-"; |
154 |
|
# and add it to the graph |
155 |
< |
push @rawdata, "AREA:inuse#CCCCFF:memory in use\\l"; |
155 |
> |
push @rawdata, "AREA:inuse#CCCCFF:memory in use"; |
156 |
|
push @rawdata, "--base=1024"; |
157 |
|
# add some nice values to the legend |
158 |
|
&addlegend(\@rawdata, "inuse"); |
160 |
|
} |
161 |
|
if($rrd =~ /^(load)\.rrd$/) { |
162 |
|
my(@data); |
163 |
< |
push @data, "LINE2:$1:load1:load1#CCCCFF:OK:1 minute load average"; |
164 |
< |
push @data, "LINE2:$1:load5:load5#7777FF:OK:5 minute load average"; |
165 |
< |
push @data, "LINE2:$1:load15:load15#0000FF:OK:15 minute load average"; |
163 |
> |
push @data, "LINE2:$1:load1:load1#CCCCFF:OK: 1 min load average"; |
164 |
> |
push @data, "LINE2:$1:load5:load5#7777FF:OK: 5 min load average"; |
165 |
> |
push @data, "LINE2:$1:load15:load15#0000FF:OK:15 min load average"; |
166 |
|
&makegraph($machine, $1, "Loads for $machine", \@data); |
167 |
|
} |
168 |
|
if($rrd =~ /^(proc)\.rrd$/) { |
169 |
|
my(@data); |
170 |
< |
push @data, "LINE2:$1:cpu:cpu#00FF00:OK:cpu processes"; |
170 |
> |
push @data, "LINE2:$1:cpu:cpu#00FF00:OK:cpu processes "; |
171 |
|
push @data, "LINE2:$1:sleeping:sleeping#0000FF:OK:sleeping processes"; |
172 |
< |
push @data, "LINE2:$1:stopped:stopped#00FFFF:OK:stopped processes"; |
173 |
< |
push @data, "LINE2:$1:total:total#FF00FF:OK:total processes"; |
174 |
< |
push @data, "LINE2:$1:zombie:zombie#FF0000:OK:zombie processes"; |
172 |
> |
push @data, "LINE2:$1:stopped:stopped#00FFFF:OK:stopped processes "; |
173 |
> |
push @data, "LINE2:$1:total:total#FF00FF:OK:total processes "; |
174 |
> |
push @data, "LINE2:$1:zombie:zombie#FF0000:OK:zombie processes "; |
175 |
|
&makegraph($machine, $1, "Processes on $machine", \@data); |
176 |
|
} |
177 |
|
if($rrd =~ /^(swap)\.rrd$/) { |
180 |
|
# we don't actually want to display free swap, |
181 |
|
# although we need it to do inuse... |
182 |
|
push @data, "NONE:$1:free:free#CCCCFF:NONE:free swap"; |
183 |
< |
push @data, "LINE2:$1:total:total#0000FF:NONE:total swap"; |
183 |
> |
push @data, "LINE2:$1:total:total#0000FF:NONE:total swap\\n"; |
184 |
|
# calculate inuse |
185 |
|
push @rawdata, "CDEF:inuse=total,free,-"; |
186 |
|
# and add it to the graph |
187 |
< |
push @rawdata, "AREA:inuse#CCCCFF:swap in use\\l"; |
187 |
> |
push @rawdata, "AREA:inuse#CCCCFF:swap in use"; |
188 |
|
push @rawdata, "--base=1024"; |
189 |
|
# add some nice values to the legend |
190 |
|
&addlegend(\@rawdata, "inuse"); |
198 |
|
if($rrd =~ /^(disk)-(\S+).rrd$/) { |
199 |
|
my(@data); |
200 |
|
my(@rawdata); |
201 |
< |
push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:NONE:total size"; |
202 |
< |
push @data, "AREA:$1-$2:used:used#CCCCFF:OK:used"; |
201 |
> |
push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:NONE:total size\\n"; |
202 |
> |
push @data, "AREA:$1-$2:used:used#CCCCFF:OK:used space"; |
203 |
|
push @rawdata, "--base=1024"; |
204 |
|
my($type) = $1; |
205 |
|
my($name) = $2; |
322 |
|
if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(\S+):(.*)$/) { |
323 |
|
push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:AVERAGE"; |
324 |
|
if($1 ne "NONE") { |
325 |
< |
push @rrdcmd, "$1:$4#$5:$7\\s"; |
325 |
> |
push @rrdcmd, "$1:$4#$5:$7"; |
326 |
|
if($6 ne "NONE") { |
327 |
|
# add some nice values to the legend |
328 |
|
&addlegend(\@rrdcmd, $4); |
364 |
|
# accepts reference to an array and a name |
365 |
|
sub addlegend() { |
366 |
|
my($dataref, $name) = @_; |
367 |
< |
push @$dataref, "GPRINT:$name:LAST:latest=\%lf\\r"; |
368 |
< |
push @$dataref, "GPRINT:$name:AVERAGE:average=\%lf"; |
369 |
< |
push @$dataref, "GPRINT:$name:MAX:max=\%lf"; |
370 |
< |
push @$dataref, "GPRINT:$name:MIN:min=\%lf\\r"; |
367 |
> |
push @$dataref, "GPRINT:$name:LAST:Current\\: \%8.2lf %s"; |
368 |
> |
push @$dataref, "GPRINT:$name:AVERAGE:Average\\: \%8.2lf %s"; |
369 |
> |
push @$dataref, "GPRINT:$name:MAX:Max\\: \%8.2lf %s\\n"; |
370 |
> |
#push @$dataref, "GPRINT:$name:MIN:Min\\: \%8.2lf %s\\n"; |
371 |
|
} |
372 |
|
|
373 |
|
# hacky subroutine to return a colour |