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