]>
Commit | Line | Data |
---|---|---|
350b52c5 CS |
1 | # Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed |
2 | # Initialisation | |
3 | ||
4 | package Graphs; | |
5 | ||
6 | use strict; | |
7 | use RRDs; | |
8 | ||
9 | require '/var/ipfire/general-functions.pl'; | |
10 | require "${General::swroot}/lang.pl"; | |
11 | require "${General::swroot}/header.pl"; | |
12 | ||
13 | $General::version = '2.0b'; | |
14 | $General::swroot = '/var/ipfire'; | |
15 | ||
16 | my $ERROR; | |
17 | my $rrdlog = "/var/log/rrd"; | |
18 | my $graphs = "/srv/web/ipfire/html/graphs"; | |
19 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; | |
20 | ||
21 | my %color = (); | |
22 | my %mainsettings = (); | |
23 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
24 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
25 | ||
26 | my %mbmon_settings = (); | |
27 | &General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); | |
28 | ||
29 | my %mbmon_values = (); | |
cce90b0b CS |
30 | &General::readhash("/var/log/mbmon-values", \%mbmon_values); |
31 | ||
350b52c5 CS |
32 | my $key; |
33 | my $value; | |
34 | my @args = (); | |
35 | my $count = 0; | |
36 | ||
37 | use Encode 'from_to'; | |
38 | ||
39 | my %tr=(); | |
40 | if ((${Lang::language} eq 'el') || | |
41 | (${Lang::language} eq 'fa') || | |
42 | (${Lang::language} eq 'ru') || | |
43 | (${Lang::language} eq 'th') || | |
44 | (${Lang::language} eq 'vi') || | |
45 | (${Lang::language} eq 'zh') || | |
46 | (${Lang::language} eq 'zt')) { | |
47 | eval `/bin/cat "${General::swroot}/langs/en.pl"`; | |
48 | } else { | |
49 | %tr=%Lang::tr; # use translated version for other languages | |
50 | } | |
51 | ||
52 | ||
53 | sub updatecpugraph { | |
60412147 CS |
54 | my $period = $_[0]; |
55 | ||
56 | RRDs::graph ("$graphs/cpu-$period.png", | |
57 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
58 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
59 | "--color", "SHADEA".$color{"color19"}, | |
60 | "--color", "SHADEB".$color{"color19"}, | |
61 | "--color", "BACK".$color{"color21"}, | |
62 | "-t $tr{'cpu usage per'} $tr{$period}", | |
63 | "DEF:iowait=$rrdlog/cpu.rrd:iowait:AVERAGE", | |
64 | "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE", | |
65 | "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE", | |
66 | "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE", | |
67 | "DEF:irq=$rrdlog/cpu.rrd:irq:AVERAGE", | |
68 | "CDEF:total=user,system,idle,iowait,irq,+,+,+,+", | |
69 | "CDEF:userpct=100,user,total,/,*", | |
70 | "CDEF:systempct=100,system,total,/,*", | |
71 | "CDEF:idlepct=100,idle,total,/,*", | |
72 | "CDEF:iowaitpct=100,iowait,total,/,*", | |
73 | "CDEF:irqpct=100,irq,total,/,*", | |
249dda69 | 74 | "COMMENT:$tr{'caption'}\\t\\t\\t ", |
60412147 CS |
75 | "COMMENT:$tr{'maximal'}", |
76 | "COMMENT:$tr{'average'}", | |
249dda69 | 77 | "COMMENT:$tr{'minimal'}", |
60412147 | 78 | "COMMENT:$tr{'current'}\\j", |
249dda69 CS |
79 | "AREA:iowaitpct".$color{"color14"}.":$tr{'iowait'}", |
80 | "GPRINT:iowaitpct:MAX:%3.2lf%%", | |
81 | "GPRINT:iowaitpct:AVERAGE:%3.2lf%%", | |
82 | "GPRINT:iowaitpct:MIN:%3.2lf%%", | |
83 | "GPRINT:iowaitpct:LAST:%3.2lf%%\\j", | |
84 | "STACK:irqpct".$color{"color23"}.":$tr{'irq cpu usage'}", | |
85 | "GPRINT:irqpct:MAX:%3.2lf%%", | |
86 | "GPRINT:irqpct:AVERAGE:%3.2lf%%", | |
87 | "GPRINT:irqpct:MIN:%3.2lf%%", | |
88 | "GPRINT:irqpct:LAST:%3.2lf%%\\j", | |
89 | "STACK:userpct".$color{"color11"}.":$tr{'user cpu usage'}", | |
90 | "GPRINT:userpct:MAX:%3.2lf%%", | |
91 | "GPRINT:userpct:AVERAGE:%3.2lf%%", | |
92 | "GPRINT:userpct:MIN:%3.2lf%%", | |
93 | "GPRINT:userpct:LAST:%3.2lf%%\\j", | |
94 | "STACK:systempct".$color{"color13"}.":$tr{'system cpu usage'}", | |
95 | "GPRINT:systempct:MAX:%3.2lf%%", | |
96 | "GPRINT:systempct:AVERAGE:%3.2lf%%", | |
97 | "GPRINT:systempct:MIN:%3.2lf%%", | |
98 | "GPRINT:systempct:LAST:%3.2lf%%\\j", | |
99 | "STACK:idlepct".$color{"color12"}.":$tr{'idle cpu usage'}", | |
100 | "GPRINT:idlepct:MAX:%3.2lf%%", | |
101 | "GPRINT:idlepct:AVERAGE:%3.2lf%%", | |
102 | "GPRINT:idlepct:MIN:%3.2lf%%", | |
103 | "GPRINT:idlepct:LAST:%3.2lf%%\\j"); | |
60412147 CS |
104 | $ERROR = RRDs::error; |
105 | print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; | |
350b52c5 CS |
106 | } |
107 | ||
108 | sub updateloadgraph { | |
60412147 CS |
109 | my $period = $_[0]; |
110 | ||
111 | RRDs::graph ("$graphs/load-$period.png", | |
112 | "--start", "-1$period", "-aPNG", | |
113 | "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid", | |
114 | "-t Load Average", | |
115 | "--color", "SHADEA".$color{"color19"}, | |
116 | "--color", "SHADEB".$color{"color19"}, | |
117 | "--color", "BACK".$color{"color21"}, | |
118 | "DEF:load1=$rrdlog/load.rrd:load1:AVERAGE", | |
119 | "DEF:load5=$rrdlog/load.rrd:load5:AVERAGE", | |
120 | "DEF:load15=$rrdlog/load.rrd:load15:AVERAGE", | |
121 | "AREA:load1".$color{"color13"}.":1 Minute, letzter:", | |
122 | "GPRINT:load1:LAST:%5.2lf", | |
123 | "AREA:load5".$color{"color18"}.":5 Minuten, letzter:", | |
124 | "GPRINT:load5:LAST:%5.2lf", | |
125 | "AREA:load15".$color{"color14"}.":15 Minuten, letzter:", | |
126 | "GPRINT:load15:LAST:%5.2lf\\j", | |
127 | "LINE1:load5".$color{"color13"}, | |
128 | "LINE1:load1".$color{"color18"}); | |
129 | $ERROR = RRDs::error; | |
130 | print "Error in RRD::graph for load: $ERROR\n" if $ERROR; | |
350b52c5 CS |
131 | } |
132 | ||
133 | sub updatememgraph { | |
60412147 CS |
134 | my $period = $_[0]; |
135 | ||
136 | RRDs::graph ("$graphs/memory-$period.png", | |
137 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
138 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
139 | "--color", "SHADEA".$color{"color19"}, | |
140 | "--color", "SHADEB".$color{"color19"}, | |
141 | "--color", "BACK".$color{"color21"}, | |
142 | "-t $tr{'memory usage per'} $tr{$period}", | |
143 | "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE", | |
144 | "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE", | |
145 | "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE", | |
146 | "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE", | |
147 | "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE", | |
148 | "CDEF:total=used,free,+", | |
149 | "CDEF:used2=used,buffer,cache,shared,+,+,-", | |
150 | "CDEF:usedpct=100,used2,total,/,*", | |
151 | "CDEF:sharedpct=100,shared,total,/,*", | |
152 | "CDEF:bufferpct=100,buffer,total,/,*", | |
153 | "CDEF:cachepct=100,cache,total,/,*", | |
154 | "CDEF:freepct=100,free,total,/,*", | |
249dda69 CS |
155 | "COMMENT:$tr{'caption'}\\t\\t\\t", |
156 | "COMMENT:$tr{'maximal'}", | |
157 | "COMMENT:$tr{'average'}", | |
158 | "COMMENT:$tr{'minimal'}", | |
159 | "COMMENT:$tr{'current'}\\j", | |
60412147 | 160 | "AREA:usedpct".$color{"color11"}.":$tr{'used memory'}", |
249dda69 CS |
161 | "GPRINT:usedpct:MAX:%3.2lf%%", |
162 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
163 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
164 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
60412147 | 165 | "STACK:sharedpct".$color{"color13"}.":$tr{'shared memory'}", |
249dda69 CS |
166 | "GPRINT:sharedpct:MAX:%3.2lf%%", |
167 | "GPRINT:sharedpct:AVERAGE:%3.2lf%%", | |
168 | "GPRINT:sharedpct:MIN:%3.2lf%%", | |
169 | "GPRINT:sharedpct:LAST:%3.2lf%%\\j", | |
60412147 | 170 | "STACK:bufferpct".$color{"color23"}.":$tr{'buffered memory'}", |
249dda69 CS |
171 | "GPRINT:bufferpct:MAX:%3.2lf%%", |
172 | "GPRINT:bufferpct:AVERAGE:%3.2lf%%", | |
173 | "GPRINT:bufferpct:MIN:%3.2lf%%", | |
174 | "GPRINT:bufferpct:LAST:%3.2lf%%\\j", | |
60412147 | 175 | "STACK:cachepct".$color{"color14"}.":$tr{'cached memory'}", |
249dda69 CS |
176 | "GPRINT:cachepct:MAX:%3.2lf%%", |
177 | "GPRINT:cachepct:AVERAGE:%3.2lf%%", | |
178 | "GPRINT:cachepct:MIN:%3.2lf%%", | |
179 | "GPRINT:cachepct:LAST:%3.2lf%%\\j", | |
180 | "STACK:freepct".$color{"color12"}.":$tr{'free memory'}", | |
181 | "GPRINT:freepct:MAX:%3.2lf%%", | |
182 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
183 | "GPRINT:freepct:MIN:%3.2lf%%", | |
184 | "GPRINT:freepct:LAST:%3.2lf%%\\j"); | |
60412147 CS |
185 | $ERROR = RRDs::error; |
186 | print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; | |
187 | ||
188 | RRDs::graph ("$graphs/swap-$period.png", | |
189 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
190 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
191 | "--color", "SHADEA".$color{"color19"}, | |
192 | "--color", "SHADEB".$color{"color19"}, | |
193 | "--color", "BACK".$color{"color21"}, | |
194 | "-t $tr{'swap usage per'} $tr{$period}", | |
195 | "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE", | |
196 | "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE", | |
197 | "CDEF:total=used,free,+", | |
198 | "CDEF:usedpct=100,used,total,/,*", | |
199 | "CDEF:freepct=100,free,total,/,*", | |
249dda69 | 200 | "COMMENT:$tr{'caption'}\\t\\t", |
60412147 CS |
201 | "COMMENT:$tr{'maximal'}", |
202 | "COMMENT:$tr{'average'}", | |
249dda69 | 203 | "COMMENT:$tr{'minimal'}", |
60412147 | 204 | "COMMENT:$tr{'current'}\\j", |
249dda69 CS |
205 | "AREA:usedpct".$color{"color11"}.":$tr{'used swap'}", |
206 | "GPRINT:usedpct:MAX:%3.2lf%%", | |
207 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
208 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
209 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
210 | "STACK:freepct".$color{"color12"}.":$tr{'free swap'}", | |
211 | "GPRINT:freepct:MAX:%3.2lf%%", | |
212 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
213 | "GPRINT:freepct:MIN:%3.2lf%%", | |
214 | "GPRINT:freepct:LAST:%3.2lf%%\\j"); | |
60412147 CS |
215 | $ERROR = RRDs::error; |
216 | print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; | |
350b52c5 CS |
217 | } |
218 | ||
219 | sub updatediskgraph { | |
60412147 CS |
220 | my $period = $_[0]; |
221 | my $disk = $_[1]; | |
222 | ||
223 | RRDs::graph ("$graphs/disk-$disk-$period.png", | |
224 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
225 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
226 | "--color", "SHADEA".$color{"color19"}, | |
227 | "--color", "SHADEB".$color{"color19"}, | |
228 | "--color", "BACK".$color{"color21"}, | |
229 | "-t $tr{'disk access per'} $tr{$period} $disk", | |
230 | "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE", | |
231 | "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE", | |
232 | "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}", | |
233 | "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j", | |
234 | "COMMENT: \\j", | |
235 | "COMMENT:$tr{'maximal'}", | |
236 | "COMMENT:$tr{'average'}", | |
237 | "COMMENT:$tr{'current'}\\j", | |
238 | "GPRINT:read:MAX:$tr{'read sectors'}\\:%8.0lf", | |
239 | "GPRINT:read:AVERAGE:$tr{'read sectors'}\\:%8.0lf", | |
240 | "GPRINT:read:LAST:$tr{'read sectors'}\\:%8.0lf\\j", | |
241 | "GPRINT:write:MAX:$tr{'written sectors'}\\:%8.0lf", | |
242 | "GPRINT:write:AVERAGE:$tr{'written sectors'}\\:%8.0lf", | |
243 | "GPRINT:write:LAST:$tr{'written sectors'}\\:%8.0lf\\j"); | |
244 | $ERROR = RRDs::error; | |
245 | print "Error in RRD::graph for disk: $ERROR\n" if $ERROR; | |
350b52c5 CS |
246 | } |
247 | ||
248 | sub updateifgraph { | |
249 | my $interface = $_[0]; | |
250 | my $period = $_[1]; | |
251 | ||
252 | RRDs::graph ("$graphs/$interface-$period.png", | |
253 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
254 | "--alt-y-grid", "-w 600", "-h 100", | |
255 | "--color", "SHADEA".$color{"color19"}, | |
256 | "--color", "SHADEB".$color{"color19"}, | |
257 | "--color", "BACK".$color{"color21"}, | |
258 | "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})", | |
259 | "-v$tr{'bytes per second'}", | |
260 | "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE", | |
261 | "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE", | |
262 | "AREA:incoming".$color{"color11"}.":$tr{'incoming traffic in bytes per second'}", | |
afbda815 | 263 | "AREA:outgoing".$color{"color12"}.":$tr{'outgoing traffic in bytes per second'}\\j", |
350b52c5 CS |
264 | "COMMENT: \\j", |
265 | "COMMENT:$tr{'maximal'}", | |
266 | "COMMENT:$tr{'average'}", | |
249dda69 | 267 | "COMMENT:$tr{'minimal'}", |
350b52c5 CS |
268 | "COMMENT:$tr{'current'}\\j", |
269 | "GPRINT:incoming:MAX:$tr{'in'}\\:%8.3lf %sBps", | |
270 | "GPRINT:incoming:AVERAGE:$tr{'in'}\\:%8.3lf %sBps", | |
249dda69 | 271 | "GPRINT:incoming:MIN:$tr{'in'}\\:%8.3lf %sBps", |
350b52c5 CS |
272 | "GPRINT:incoming:LAST:$tr{'in'}\\:%8.3lf %sBps\\j", |
273 | "GPRINT:outgoing:MAX:$tr{'out'}\\:%8.3lf %sBps", | |
274 | "GPRINT:outgoing:AVERAGE:$tr{'out'}\\:%8.3lf %sBps", | |
249dda69 | 275 | "GPRINT:outgoing:MIN:$tr{'out'}\\:%8.3lf %sBps", |
350b52c5 CS |
276 | "GPRINT:outgoing:LAST:$tr{'out'}\\:%8.3lf %sBps\\j"); |
277 | $ERROR = RRDs::error; | |
278 | print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR; | |
279 | } | |
280 | ||
281 | sub updatefwhitsgraph { | |
3c5695fe | 282 | my $period = $_[0]; |
350b52c5 | 283 | |
3c5695fe CS |
284 | RRDs::graph ("$graphs/firewallhits-$period-area.png", |
285 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
286 | "--alt-y-grid", "-w 600", "-h 100", | |
350b52c5 CS |
287 | "--color", "SHADEA".$color{"color19"}, |
288 | "--color", "SHADEB".$color{"color19"}, | |
289 | "--color", "BACK".$color{"color21"}, | |
3c5695fe | 290 | "-t $tr{'firewall hits per'} $tr{$period}", |
350b52c5 | 291 | "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE", |
350b52c5 | 292 | "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE", |
249dda69 CS |
293 | "COMMENT:$tr{'caption'}\\t\\t\\t", |
294 | "COMMENT:$tr{'maximal'}", | |
295 | "COMMENT:$tr{'average'}", | |
296 | "COMMENT:$tr{'minimal'}", | |
297 | "COMMENT:$tr{'current'}\\j", | |
3c5695fe | 298 | "AREA:amount".$color{"color24"}.":$tr{'firewallhits'}/5 min", |
249dda69 CS |
299 | "GPRINT:amount:MAX:%2.2lf %S", |
300 | "GPRINT:amount:AVERAGE:%2.2lf %S", | |
301 | "GPRINT:amount:MIN:%2.2lf %S", | |
302 | "GPRINT:amount:LAST:%2.2lf %S\\j", | |
303 | "STACK:portamount".$color{"color25"}.":$tr{'portscans'}/5 min", | |
304 | "GPRINT:portamount:MAX:%2.2lf %S", | |
305 | "GPRINT:portamount:MIN:%2.2lf %S", | |
306 | "GPRINT:portamount:AVERAGE:%2.2lf %S", | |
307 | "GPRINT:portamount:LAST:%2.2lf %S\\j"); | |
350b52c5 CS |
308 | $ERROR = RRDs::error; |
309 | print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR; | |
310 | } | |
311 | ||
312 | sub updatelqgraph { | |
313 | my $period = $_[0]; | |
314 | RRDs::graph ("$graphs/lq-$period.png", | |
315 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
316 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
317 | "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})", | |
318 | "--lazy", | |
319 | "--color", "SHADEA".$color{"color19"}, | |
320 | "--color", "SHADEB".$color{"color19"}, | |
321 | "--color", "BACK".$color{"color21"}, | |
322 | "-v ms / pkts (% x10)", | |
323 | "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE", | |
324 | "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE", | |
325 | "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/", | |
326 | "CDEF:loss10=loss,10,*", | |
327 | "CDEF:r0=roundtrip,30,MIN", | |
328 | "CDEF:r1=roundtrip,70,MIN", | |
329 | "CDEF:r2=roundtrip,150,MIN", | |
330 | "CDEF:r3=roundtrip,300,MIN", | |
331 | "AREA:roundtrip".$color{"color25"}.":>300 ms", | |
332 | "AREA:r3".$color{"color18"}.":150-300 ms", | |
333 | "AREA:r2".$color{"color14"}.":70-150 ms", | |
334 | "AREA:r1".$color{"color17"}.":30-70 ms", | |
335 | "AREA:r0".$color{"color12"}.":<30 ms", | |
336 | "AREA:loss10".$color{"color13"}.":Packet loss (x10)\\j", | |
337 | "COMMENT: \\j", | |
338 | "COMMENT:$tr{'maximal'}", | |
339 | "COMMENT:$tr{'average'}", | |
249dda69 | 340 | "COMMENT:$tr{'minimal'}", |
350b52c5 CS |
341 | "COMMENT:$tr{'current'}\\j", |
342 | "LINE1:roundtrip#707070:", | |
343 | "GPRINT:roundtrip:MAX:Time\\:%3.2lf ms", | |
344 | "GPRINT:roundtrip:AVERAGE:Time\\:%3.2lf ms", | |
249dda69 | 345 | "GPRINT:roundtrip:MIN:Time\\:%3.2lf ms", |
350b52c5 CS |
346 | "GPRINT:roundtrip:LAST:Time\\:%3.2lf ms\\j", |
347 | "GPRINT:loss:MAX:Loss\\:%3.2lf%%", | |
348 | "GPRINT:loss:AVERAGE:Loss\\:%3.2lf%%", | |
249dda69 | 349 | "GPRINT:loss:MIN:Loss\\:%3.2lf%%", |
350b52c5 CS |
350 | "GPRINT:loss:LAST:Loss\\:%3.2lf%%\\j" |
351 | ); | |
352 | $ERROR = RRDs::error; | |
353 | print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR; | |
354 | } | |
355 | ||
356 | sub updatehddgraph { | |
cce90b0b | 357 | |
350b52c5 CS |
358 | my $disk = $_[0]; |
359 | my $period = $_[1]; | |
360 | ||
361 | RRDs::graph ("$graphs/hddtemp-$disk-$period.png", | |
362 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
363 | "--alt-y-grid", "-w 600", "-h 100", | |
364 | "--color", "SHADEA".$color{"color19"}, | |
365 | "--color", "SHADEB".$color{"color19"}, | |
366 | "--color", "BACK".$color{"color21"}, | |
367 | "-t $tr{'harddisk temperature'} ($tr{'graph per'} $tr{$period})", | |
368 | "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE", | |
249dda69 CS |
369 | "AREA:temperature".$color{"color11"}.":$tr{'hdd temperature in'} C\\j", |
370 | "COMMENT:$tr{'maximal'}", | |
371 | "COMMENT:$tr{'average'}", | |
372 | "COMMENT:$tr{'minimal'}", | |
373 | "COMMENT:$tr{'current'}\\j", | |
374 | "GPRINT:temperature:MAX:%2.0lf Grad C", | |
375 | "GPRINT:temperature:AVERAGE:%2.0lf Grad C", | |
376 | "GPRINT:temperature:MIN:%2.0lf Grad C", | |
377 | "GPRINT:temperature:LAST:%2.0lf Grad C\\j", | |
350b52c5 | 378 | ); |
249dda69 | 379 | $ERROR = RRDs::error; |
350b52c5 CS |
380 | print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR; |
381 | } | |
382 | ||
383 | sub updatetempgraph | |
384 | { | |
385 | my $type = "temp"; | |
386 | my $period = $_[0]; | |
dced81b2 | 387 | my $count = "11"; |
cce90b0b CS |
388 | |
389 | @args = ("$graphs/mbmon-$type-$period.png", | |
390 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
350b52c5 CS |
391 | "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", |
392 | "--color", "SHADEA".$color{"color19"}, | |
393 | "--color", "SHADEB".$color{"color19"}, | |
394 | "--color", "BACK".$color{"color21"}, | |
249dda69 CS |
395 | "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})", |
396 | "COMMENT:$tr{'caption'}\\t\\t", | |
397 | "COMMENT:$tr{'maximal'}", | |
398 | "COMMENT:$tr{'average'}", | |
399 | "COMMENT:$tr{'minimal'}", | |
400 | "COMMENT:$tr{'current'}\\j",); | |
cce90b0b | 401 | |
350b52c5 CS |
402 | foreach $key ( sort(keys %mbmon_values) ) |
403 | { | |
404 | if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) | |
405 | { | |
406 | if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) | |
407 | { | |
408 | $mbmon_settings{'LABEL-'.$key} = $key; | |
409 | } | |
cce90b0b | 410 | push (@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); |
249dda69 CS |
411 | push (@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} Grad C"); |
412 | push (@args, "GPRINT:$key:MAX:%3.1lf"); | |
413 | push (@args, "GPRINT:$key:AVERAGE:%3.1lf"); | |
414 | push (@args, "GPRINT:$key:MIN:%3.1lf"); | |
415 | push (@args, "GPRINT:$key:LAST:%3.1lf\\j"); | |
dced81b2 | 416 | $count++; |
cce90b0b | 417 | } |
350b52c5 | 418 | } |
249dda69 | 419 | |
cce90b0b | 420 | RRDs::graph ( @args ); |
350b52c5 CS |
421 | $ERROR = RRDs::error; |
422 | print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; | |
350b52c5 CS |
423 | } |
424 | ||
425 | sub updatefangraph | |
426 | { | |
427 | my $type = "fan"; | |
428 | my $period = $_[0]; | |
dced81b2 | 429 | my $count = "11"; |
350b52c5 CS |
430 | |
431 | @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", | |
432 | "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", | |
433 | "--color", "SHADEA".$color{"color19"}, | |
434 | "--color", "SHADEB".$color{"color19"}, | |
435 | "--color", "BACK".$color{"color21"}, | |
249dda69 CS |
436 | "-t $tr{'mbmon fan'} ($tr{'graph per'} $tr{$period})", |
437 | "COMMENT:$tr{'caption'}\\t\\t", | |
438 | "COMMENT:$tr{'maximal'}", | |
439 | "COMMENT:$tr{'average'}", | |
440 | "COMMENT:$tr{'minimal'}", | |
441 | "COMMENT:$tr{'current'}\\j",); | |
350b52c5 | 442 | |
350b52c5 CS |
443 | foreach $key ( sort(keys %mbmon_values) ) |
444 | { | |
445 | if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) | |
446 | { | |
447 | if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) | |
448 | { | |
449 | $mbmon_settings{'LABEL-'.$key} = $key; | |
450 | } | |
451 | ||
452 | push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); | |
249dda69 CS |
453 | push(@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} rpm"); |
454 | push(@args, "GPRINT:$key:MAX:%5.0lf"); | |
455 | push(@args, "GPRINT:$key:AVERAGE:%5.0lf"); | |
456 | push(@args, "GPRINT:$key:MIN:%5.0lf"); | |
457 | push(@args, "GPRINT:$key:LAST:%5.0lf\\j"); | |
dced81b2 | 458 | $count++; |
350b52c5 CS |
459 | } |
460 | } | |
350b52c5 CS |
461 | RRDs::graph ( @args ); |
462 | $ERROR = RRDs::error; | |
463 | print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; | |
350b52c5 CS |
464 | } |
465 | ||
466 | sub updatevoltgraph | |
467 | { | |
468 | my $type = "volt"; | |
469 | my $period = $_[0]; | |
dced81b2 | 470 | my $count = "11"; |
350b52c5 CS |
471 | |
472 | @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", | |
473 | "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", | |
474 | "--color", "SHADEA".$color{"color19"}, | |
475 | "--color", "SHADEB".$color{"color19"}, | |
476 | "--color", "BACK".$color{"color21"}, | |
249dda69 CS |
477 | "-t $tr{'mbmon volt'} ($tr{'graph per'} $tr{$period})", |
478 | "COMMENT:$tr{'caption'}\\t", | |
479 | "COMMENT:$tr{'maximal'}", | |
480 | "COMMENT:$tr{'average'}", | |
481 | "COMMENT:$tr{'minimal'}", | |
482 | "COMMENT:$tr{'current'}\\j",); | |
350b52c5 | 483 | |
350b52c5 CS |
484 | foreach $key ( sort(keys %mbmon_values) ) |
485 | { | |
486 | my $v = substr($key,0,1); | |
487 | if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') ) | |
488 | { | |
489 | if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) | |
490 | { | |
491 | $mbmon_settings{'LABEL-'.$key} = $key; | |
492 | } | |
493 | ||
494 | push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); | |
249dda69 CS |
495 | push(@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} Volt"); |
496 | push(@args, "GPRINT:$key:MAX:%3.2lf"); | |
497 | push(@args, "GPRINT:$key:AVERAGE:%3.2lf"); | |
498 | push(@args, "GPRINT:$key:MIN:%3.2lf"); | |
499 | push(@args, "GPRINT:$key:LAST:%3.2lf\\j"); | |
dced81b2 | 500 | $count++; |
350b52c5 CS |
501 | } |
502 | } | |
503 | ||
350b52c5 CS |
504 | RRDs::graph ( @args ); |
505 | $ERROR = RRDs::error; | |
506 | print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; | |
350b52c5 | 507 | } |