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