2 |
|
|
3 |
|
# ----------------------------------------------------------- |
4 |
|
# i-scream graph generation script |
5 |
< |
# http://www.i-scream.org.uk |
5 |
> |
# http://www.i-scream.org |
6 |
|
# |
7 |
|
# Generates graphs from rrd databases for i-scream data. |
8 |
|
# |
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"; |
202 |
|
RRDs::graph ("$imgdir/$machine/$type-1m.png", "--start=-2678400", @rrdcmd); |
203 |
|
my($err_1m) = RRDs::error; |
204 |
|
print STDERR "Error generating 1m graph for $machine/$type: $err_1m\n" if $err_1m; |
205 |
+ |
RRDs::graph ("$imgdir/$machine/$type-1y.png", "--start=-31536000", @rrdcmd); |
206 |
+ |
my($err_1y) = RRDs::error; |
207 |
+ |
print STDERR "Error generating 1y graph for $machine/$type: $err_1y\n" if $err_1y; |
208 |
|
return; |
209 |
|
} |
210 |
|
|