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