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