| 11 |
|
#------------------------------------------------------------ |
| 12 |
|
|
| 13 |
|
## TODO |
| 14 |
– |
# allow specification of lower/upper graph bounds |
| 15 |
– |
# -- then replace mem/swap/disk "total" line ;) |
| 16 |
– |
# fix mem/swap issues |
| 17 |
– |
# -- should be graphing "in use", not "free" |
| 14 |
|
# possibly make more configurable? |
| 15 |
|
# -- allow configurable periods of graphs |
| 16 |
|
# -- comments, types, etc |
| 63 |
|
if($rrd =~ /^(mem)\.rrd$/) { |
| 64 |
|
my(@data); |
| 65 |
|
my(@rawdata); |
| 66 |
< |
push @data, "AREA:$1:free:free#CCCCFF:free memory"; |
| 66 |
> |
# we don't actually want to display free memory, |
| 67 |
> |
# although we need it to do inuse... |
| 68 |
> |
push @data, "NONE:$1:free:free#CCCCFF:free memory"; |
| 69 |
|
push @data, "LINE2:$1:total:total#0000FF:total memory"; |
| 70 |
+ |
# calculate inuse |
| 71 |
+ |
push @rawdata, "CDEF:inuse=total,free,-"; |
| 72 |
+ |
# and add it to the graph |
| 73 |
+ |
push @rawdata, "AREA:inuse#CCCCFF:memory in use"; |
| 74 |
|
push @rawdata, "--base=1024"; |
| 75 |
|
&makegraph($machine, $1, "Memory Usage for $machine", \@data, \@rawdata); |
| 76 |
|
} |
| 93 |
|
if($rrd =~ /^(swap)\.rrd$/) { |
| 94 |
|
my(@data); |
| 95 |
|
my(@rawdata); |
| 96 |
< |
push @data, "AREA:$1:free:free#CCCCFF:free swap"; |
| 96 |
> |
# we don't actually want to display free swap, |
| 97 |
> |
# although we need it to do inuse... |
| 98 |
> |
push @data, "NONE:$1:free:free#CCCCFF:free swap"; |
| 99 |
|
push @data, "LINE2:$1:total:total#0000FF:total swap"; |
| 100 |
+ |
# calculate inuse |
| 101 |
+ |
push @rawdata, "CDEF:inuse=total,free,-"; |
| 102 |
+ |
# and add it to the graph |
| 103 |
+ |
push @rawdata, "AREA:inuse#CCCCFF:swap in use"; |
| 104 |
|
push @rawdata, "--base=1024"; |
| 105 |
|
&makegraph($machine, $1, "Swap Usage for $machine", \@data, \@rawdata); |
| 106 |
|
} |
| 157 |
|
# (eg. kernow CPU usage) |
| 158 |
|
# $dataref = a reference to an array containing information for the graph |
| 159 |
|
# elements of format: "gtype:rrdname:dsname:name#colour:comment with spaces" |
| 160 |
+ |
# (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted) |
| 161 |
|
# $rawcmdref = a reference to an array containing raw rrd commands |
| 162 |
|
# elements a single command each, no spaces |
| 163 |
|
# |
| 175 |
|
my(@rrdcmd); |
| 176 |
|
foreach my $dataitem (@data) { |
| 177 |
|
# dataitem should be: "gtype:rrdname:dsname:name#colour:comment with spaces" |
| 178 |
+ |
# (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted) |
| 179 |
|
if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(.*)$/) { |
| 180 |
< |
push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:MAX"; |
| 181 |
< |
push @rrdcmd, "$1:$4#$5:$6"; |
| 180 |
> |
push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:AVERAGE"; |
| 181 |
> |
if($1 ne "NONE") { |
| 182 |
> |
push @rrdcmd, "$1:$4#$5:$6"; |
| 183 |
> |
} |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
|
push @rrdcmd, "--title=$title"; |