51 |
|
chomp $rrd; |
52 |
|
if($rrd =~ /^(cpu)\.rrd$/) { |
53 |
|
my(@data); |
54 |
+ |
my(@rawdata); |
55 |
|
push @data, "LINE2:$1:idle:idle#00FF00:idle cpu"; |
56 |
|
push @data, "LINE2:$1:user:user#0000FF:user cpu"; |
57 |
|
push @data, "LINE2:$1:kernel:kernel#00FFFF:kernel cpu"; |
58 |
|
push @data, "LINE2:$1:swap:swap#FF00FF:swap cpu"; |
59 |
|
push @data, "LINE2:$1:iowait:iowait#FF0000:iowait cpu"; |
60 |
< |
&makegraph($machine, $1, "CPU Usage for $machine", \@data); |
60 |
> |
push @rawdata, "--upper-limit=100"; |
61 |
> |
&makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata); |
62 |
|
} |
63 |
|
if($rrd =~ /^(mem)\.rrd$/) { |
64 |
|
my(@data); |
65 |
< |
push @data, "LINE2:$1:free:free#00FF00:free memory"; |
65 |
> |
my(@rawdata); |
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 |
< |
&makegraph($machine, $1, "Memory Usage for $machine", \@data); |
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 |
|
} |
77 |
|
if($rrd =~ /^(load)\.rrd$/) { |
78 |
|
my(@data); |
79 |
< |
push @data, "LINE2:$1:load1:load1#00FF00:1 minute load average"; |
80 |
< |
push @data, "LINE2:$1:load5:load5#0000FF:5 minute load average"; |
81 |
< |
push @data, "LINE2:$1:load15:load15#FF0000:15 minute load average"; |
79 |
> |
push @data, "LINE2:$1:load1:load1#CCCCFF:1 minute load average"; |
80 |
> |
push @data, "LINE2:$1:load5:load5#7777FF:5 minute load average"; |
81 |
> |
push @data, "LINE2:$1:load15:load15#0000FF:15 minute load average"; |
82 |
|
&makegraph($machine, $1, "Loads for $machine", \@data); |
83 |
|
} |
84 |
|
if($rrd =~ /^(proc)\.rrd$/) { |
92 |
|
} |
93 |
|
if($rrd =~ /^(swap)\.rrd$/) { |
94 |
|
my(@data); |
95 |
< |
push @data, "LINE2:$1:free:free#00FF00:free swap"; |
95 |
> |
my(@rawdata); |
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 |
< |
&makegraph($machine, $1, "Swap Usage for $machine", \@data); |
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 |
|
} |
107 |
|
if($rrd =~ /^(users)\.rrd$/) { |
108 |
|
my(@data); |
109 |
< |
push @data, "LINE2:$1:count:count#00FF00:user count"; |
109 |
> |
push @data, "AREA:$1:count:count#CCCCFF:user count"; |
110 |
|
&makegraph($machine, $1, "User Count for $machine", \@data); |
111 |
|
} |
112 |
|
if($rrd =~ /^(disk)-(\S+).rrd$/) { |
113 |
|
my(@data); |
114 |
+ |
my(@rawdata); |
115 |
|
push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:total size"; |
116 |
< |
push @data, "LINE2:$1-$2:used:used#00FF00:used"; |
116 |
> |
push @data, "AREA:$1-$2:used:used#CCCCFF:used"; |
117 |
> |
push @rawdata, "--base=1024"; |
118 |
|
my($type) = $1; |
119 |
|
my($name) = $2; |
120 |
|
my($nicename) = $2; |
121 |
|
$nicename =~ s/$hex_slash/\//g; |
122 |
|
$nicename =~ s/$hex_underscore/_/g; |
123 |
< |
&makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data); |
123 |
> |
&makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data, \@rawdata); |
124 |
|
} |
125 |
|
# probably a queue with a name like this :) |
126 |
|
if($rrd =~ /^(\d+)_0\.rrd$/) { |
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"; |
187 |
|
push @rrdcmd, "--imgformat=PNG"; |
188 |
|
push @rrdcmd, "--lower-limit=0"; |
189 |
+ |
# not entirely convinced this is good... |
190 |
+ |
push @rrdcmd, "--alt-autoscale-max"; |
191 |
|
# add any further raw commands |
192 |
|
push @rrdcmd, @rawcmd; |
193 |
|
RRDs::graph ("$imgdir/$machine/$type-3h.png", "--start=-10800", @rrdcmd); |