]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/cfgroot/graphs.pl
2 # Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed
3 # This is part of the IPFire Firewall
11 require '/var/ipfire/general-functions.pl';
12 require "${General::swroot}/lang.pl";
13 require "${General::swroot}/header.pl";
16 my $rrdlog = "/var/log/rrd";
17 my $graphs = "/srv/web/ipfire/html/graphs";
18 $ENV{PATH
}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
20 # Read the global settings files to get the current theme and after this load
21 # colors for this theme
24 my %mainsettings = ();
25 my %mbmonsettings = ();
26 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
27 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
30 # If the collection deamon is working and collecting mbmon data there will be
31 # some data source named after a common scheme, with the mbmonsettingsfile
32 # the user is able to deactivate some of this parameters, in case not to show
33 # false collected value´s may be disable. The user has the ability to enter
34 # custom graph names in order to change temp0 to cpu or motherboad
41 my @processesgraph = `ls -dA $rrdlog/collectd/localhost/processes-*/`;
42 if ( -e
"$rrdlog/collectd/localhost/mbmon" ){
43 @mbmongraphs = `ls $rrdlog/collectd/localhost/mbmon/`;
44 foreach (@mbmongraphs){
46 my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//;
47 $mbmonsettings{'LABEL-'.$name[0]}="$label";
48 $mbmonsettings{'LINE-'.$name[0]}="checked";
52 &General
::readhash
("${General::swroot}/mbmon/settings", \
%mbmonsettings);
56 if ((${Lang
::language
} eq 'el') ||
57 (${Lang
::language
} eq 'fa') ||
58 (${Lang
::language
} eq 'ru') ||
59 (${Lang
::language
} eq 'th') ||
60 (${Lang
::language
} eq 'vi') ||
61 (${Lang
::language
} eq 'zh') ||
62 (${Lang
::language
} eq 'zt')) {
63 eval `/bin/cat "${General::swroot}/langs/en.pl"`;
65 %tr=%Lang::tr
; # use translated version for other languages
68 # Generate the CPU Graph for the current period of time for values given by
69 # collectd atm only cpu average is displayed and only 1 or 2 cpu´s is working
73 my @command = ("$graphs/cpu-$period.png",
74 "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
75 "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
76 "--color", "SHADEA".$color{"color19"},
77 "--color", "SHADEB".$color{"color19"},
78 "--color", "BACK".$color{"color21"},
79 "-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}");
81 if ( -e
"$rrdlog/collectd/localhost/cpu-1/" ){
82 push(@command,"DEF:iowait0=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",
83 "DEF:nice0=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",
84 "DEF:interrupt0=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",
85 "DEF:steal0=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",
86 "DEF:user0=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",
87 "DEF:system0=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",
88 "DEF:idle0=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",
89 "DEF:irq0=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");
90 push(@command,"DEF:iowait1=$rrdlog/collectd/localhost/cpu-1/cpu-wait.rrd:value:AVERAGE",
91 "DEF:nice1=$rrdlog/collectd/localhost/cpu-1/cpu-nice.rrd:value:AVERAGE",
92 "DEF:interrupt1=$rrdlog/collectd/localhost/cpu-1/cpu-interrupt.rrd:value:AVERAGE",
93 "DEF:steal1=$rrdlog/collectd/localhost/cpu-1/cpu-steal.rrd:value:AVERAGE",
94 "DEF:user1=$rrdlog/collectd/localhost/cpu-1/cpu-user.rrd:value:AVERAGE",
95 "DEF:system1=$rrdlog/collectd/localhost/cpu-1/cpu-system.rrd:value:AVERAGE",
96 "DEF:idle1=$rrdlog/collectd/localhost/cpu-1/cpu-idle.rrd:value:AVERAGE",
97 "DEF:irq1=$rrdlog/collectd/localhost/cpu-1/cpu-softirq.rrd:value:AVERAGE");
98 push(@command,"CDEF:user=user0,user1,+",
99 "CDEF:nice=nice0,nice1,+",
100 "CDEF:interrupt=interrupt0,interrupt1,+",
101 "CDEF:steal=steal0,steal1,+",
102 "CDEF:system=system0,system1,+",
103 "CDEF:idle=idle0,idle1,+",
104 "CDEF:iowait=iowait0,iowait1,+",
105 "CDEF:irq=irq0,irq1,+");
108 push(@command,"DEF:iowait=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",
109 "DEF:nice=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",
110 "DEF:interrupt=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",
111 "DEF:steal=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",
112 "DEF:user=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",
113 "DEF:system=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",
114 "DEF:idle=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",
115 "DEF:irq=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");
117 push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+",
118 "CDEF:userpct=100,user,total,/,*",
119 "CDEF:nicepct=100,nice,total,/,*",
120 "CDEF:interruptpct=100,interrupt,total,/,*",
121 "CDEF:stealpct=100,steal,total,/,*",
122 "CDEF:systempct=100,system,total,/,*",
123 "CDEF:idlepct=100,idle,total,/,*",
124 "CDEF:iowaitpct=100,iowait,total,/,*",
125 "CDEF:irqpct=100,irq,total,/,*",
126 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
127 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
128 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
129 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
130 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
131 "AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr
{'cpu iowait usage'}),
132 "GPRINT:iowaitpct:MAX:%3.2lf%%",
133 "GPRINT:iowaitpct:AVERAGE:%3.2lf%%",
134 "GPRINT:iowaitpct:MIN:%3.2lf%%",
135 "GPRINT:iowaitpct:LAST:%3.2lf%%\\j",
136 "STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu irq usage'}),
137 "GPRINT:irqpct:MAX:%3.2lf%%",
138 "GPRINT:irqpct:AVERAGE:%3.2lf%%",
139 "GPRINT:irqpct:MIN:%3.2lf%%",
140 "GPRINT:irqpct:LAST:%3.2lf%%\\j",
141 "STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu nice usage'}),
142 "GPRINT:nicepct:MAX:%3.2lf%%",
143 "GPRINT:nicepct:AVERAGE:%3.2lf%%",
144 "GPRINT:nicepct:MIN:%3.2lf%%",
145 "GPRINT:nicepct:LAST:%3.2lf%%\\j",
146 "STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu interrupt usage'}),
147 "GPRINT:interruptpct:MAX:%3.2lf%%",
148 "GPRINT:interruptpct:AVERAGE:%3.2lf%%",
149 "GPRINT:interruptpct:MIN:%3.2lf%%",
150 "GPRINT:interruptpct:LAST:%3.2lf%%\\j",
151 "STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu steal usage'}),
152 "GPRINT:stealpct:MAX:%3.2lf%%",
153 "GPRINT:stealpct:AVERAGE:%3.2lf%%",
154 "GPRINT:stealpct:MIN:%3.2lf%%",
155 "GPRINT:stealpct:LAST:%3.2lf%%\\j",
156 "STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu user usage'}),
157 "GPRINT:userpct:MAX:%3.2lf%%",
158 "GPRINT:userpct:AVERAGE:%3.2lf%%",
159 "GPRINT:userpct:MIN:%3.2lf%%",
160 "GPRINT:userpct:LAST:%3.2lf%%\\j",
161 "STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu system usage'}),
162 "GPRINT:systempct:MAX:%3.2lf%%",
163 "GPRINT:systempct:AVERAGE:%3.2lf%%",
164 "GPRINT:systempct:MIN:%3.2lf%%",
165 "GPRINT:systempct:LAST:%3.2lf%%\\j",
166 "STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu idle usage'}),
167 "GPRINT:idlepct:MAX:%3.2lf%%",
168 "GPRINT:idlepct:AVERAGE:%3.2lf%%",
169 "GPRINT:idlepct:MIN:%3.2lf%%",
170 "GPRINT:idlepct:LAST:%3.2lf%%\\j");
172 RRDs
::graph
(@command);
173 $ERROR = RRDs
::error
;
174 print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
177 # Generate the Load Graph for the current period of time for values given by collecd
179 sub updateloadgraph
{
182 RRDs
::graph
("$graphs/load-$period.png",
183 "--start", "-1$period", "-aPNG",
184 "-w 600", "-h 125", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid",
185 "-t Load Average $Lang::tr{'graph per'} $Lang::tr{$period}", "-v $Lang::tr{'processes'}",
186 "--color", "SHADEA".$color{"color19"},
187 "--color", "SHADEB".$color{"color19"},
188 "--color", "BACK".$color{"color21"},
189 "DEF:load1=$rrdlog/collectd/localhost/load/load.rrd:shortterm:AVERAGE",
190 "DEF:load5=$rrdlog/collectd/localhost/load/load.rrd:midterm:AVERAGE",
191 "DEF:load15=$rrdlog/collectd/localhost/load/load.rrd:longterm:AVERAGE",
192 "AREA:load1".$color{"color13"}."A0:1 Minute:",
193 "GPRINT:load1:LAST:%5.2lf",
194 "AREA:load5".$color{"color18"}."A0:5 Minuten:",
195 "GPRINT:load5:LAST:%5.2lf",
196 "AREA:load15".$color{"color14"}."A0:15 Minuten:",
197 "GPRINT:load15:LAST:%5.2lf\\j",
198 "LINE1:load5".$color{"color13"},
199 "LINE1:load1".$color{"color18"});
200 $ERROR = RRDs
::error
;
201 print "Error in RRD::graph for load: $ERROR\n" if $ERROR;
204 # Generate the Memory and Swap Graph for the current period of time for values given by collecd
209 RRDs
::graph
("$graphs/memory-$period.png",
210 "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
211 "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
212 "--color", "SHADEA".$color{"color19"},
213 "--color", "SHADEB".$color{"color19"},
214 "--color", "BACK".$color{"color21"},
215 "-t $Lang::tr{'memory usage per'} $Lang::tr{$period}",
216 "DEF:used=$rrdlog/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",
217 "DEF:free=$rrdlog/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",
218 "DEF:buffer=$rrdlog/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",
219 "DEF:cache=$rrdlog/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",
220 "CDEF:total=used,free,cache,buffer,+,+,+",
221 "CDEF:usedpct=used,total,/,100,*",
222 "CDEF:bufferpct=buffer,total,/,100,*",
223 "CDEF:cachepct=cache,total,/,100,*",
224 "CDEF:freepct=free,total,/,100,*",
225 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
226 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
227 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
228 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
229 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
230 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used memory'}),
231 "GPRINT:usedpct:MAX:%3.2lf%%",
232 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
233 "GPRINT:usedpct:MIN:%3.2lf%%",
234 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
235 "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'buffered memory'}),
236 "GPRINT:bufferpct:MAX:%3.2lf%%",
237 "GPRINT:bufferpct:AVERAGE:%3.2lf%%",
238 "GPRINT:bufferpct:MIN:%3.2lf%%",
239 "GPRINT:bufferpct:LAST:%3.2lf%%\\j",
240 "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr
{'cached memory'}),
241 "GPRINT:cachepct:MAX:%3.2lf%%",
242 "GPRINT:cachepct:AVERAGE:%3.2lf%%",
243 "GPRINT:cachepct:MIN:%3.2lf%%",
244 "GPRINT:cachepct:LAST:%3.2lf%%\\j",
245 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free memory'}),
246 "GPRINT:freepct:MAX:%3.2lf%%",
247 "GPRINT:freepct:AVERAGE:%3.2lf%%",
248 "GPRINT:freepct:MIN:%3.2lf%%",
249 "GPRINT:freepct:LAST:%3.2lf%%\\j");
250 $ERROR = RRDs
::error
;
251 print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
253 RRDs
::graph
("$graphs/swap-$period.png",
254 "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
255 "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
256 "--color", "SHADEA".$color{"color19"},
257 "--color", "SHADEB".$color{"color19"},
258 "--color", "BACK".$color{"color21"},
259 "-t $Lang::tr{'swap usage per'} $Lang::tr{$period}",
260 "DEF:used=$rrdlog/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",
261 "DEF:free=$rrdlog/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",
262 "DEF:cached=$rrdlog/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",
263 "CDEF:total=used,free,cached,+,+",
264 "CDEF:usedpct=100,used,total,/,*",
265 "CDEF:freepct=100,free,total,/,*",
266 "CDEF:cachedpct=100,cached,total,/,*",
267 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
268 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
269 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
270 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
271 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
272 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used swap'}),
273 "GPRINT:usedpct:MAX:%3.2lf%%",
274 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
275 "GPRINT:usedpct:MIN:%3.2lf%%",
276 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
277 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free swap'}),
278 "GPRINT:freepct:MAX:%3.2lf%%",
279 "GPRINT:freepct:AVERAGE:%3.2lf%%",
280 "GPRINT:freepct:MIN:%3.2lf%%",
281 "GPRINT:freepct:LAST:%3.2lf%%\\j",
282 "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cached swap'}),
283 "GPRINT:cachedpct:MAX:%3.2lf%%",
284 "GPRINT:cachedpct:AVERAGE:%3.2lf%%",
285 "GPRINT:cachedpct:MIN:%3.2lf%%",
286 "GPRINT:cachedpct:LAST:%3.2lf%%\\j");
287 $ERROR = RRDs
::error
;
288 print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
291 # Generate the Disk Graph for the current period of time for values given by collecd
293 sub updatediskgraph
{
297 RRDs
::graph
("$graphs/disk-$disk-$period.png",
298 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",
299 "--alt-y-grid", "-w 600", "-h 125", "-r", "-z",
300 "--color", "SHADEA".$color{"color19"},
301 "--color", "SHADEB".$color{"color19"},
302 "--color", "BACK".$color{"color21"},
303 "-t $disk $Lang::tr{'disk access per'} $Lang::tr{$period}",
304 "DEF:read=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",
305 "DEF:write=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",
306 "CDEF:writen=write,-1,*",
307 "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
308 "CDEF:st=standby,INF,*",
309 "COMMENT:".sprintf("%-25s",$Lang::tr
{'caption'}),
310 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
311 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
312 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
313 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
314 "AREA:st".$color{"color20"}."A0:standby\\j",
315 "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'read bytes'}),
316 "GPRINT:read:MAX:%8.1lf %sBps",
317 "GPRINT:read:AVERAGE:%8.1lf %sBps",
318 "GPRINT:read:MIN:%8.1lf %sBps",
319 "GPRINT:read:LAST:%8.1lf %sBps\\j",
320 "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'written bytes'}),
321 "GPRINT:write:MAX:%8.1lf %sBps",
322 "GPRINT:write:AVERAGE:%8.1lf %sBps",
323 "GPRINT:write:MIN:%8.1lf %sBps",
324 "GPRINT:write:LAST:%8.1lf %sBps\\j");
325 $ERROR = RRDs
::error
;
326 print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
329 # Generate the Interface Graph for the current period of time for values given by collecd
332 my $interface = $_[0];
335 RRDs
::graph
("$graphs/$interface-$period.png",
336 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",
337 "--alt-y-grid", "-w 600", "-h 125", "-z", "-r",
338 "--color", "SHADEA".$color{"color19"},
339 "--color", "SHADEB".$color{"color19"},
340 "--color", "BACK".$color{"color21"},
341 "-t $Lang::tr{'traffic on'} $interface $Lang::tr{'graph per'} $Lang::tr{$period}",
342 "-v$Lang::tr{'bytes per second'}",
343 "DEF:incoming=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:rx:AVERAGE",
344 "DEF:outgoing=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:tx:AVERAGE",
345 "CDEF:outgoingn=outgoing,-1,*",
346 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
347 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
348 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
349 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
350 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
351 "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
352 "GPRINT:incoming:MAX:%8.1lf %sBps",
353 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
354 "GPRINT:incoming:MIN:%8.1lf %sBps",
355 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
356 "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
357 "GPRINT:outgoing:MAX:%8.1lf %sBps",
358 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
359 "GPRINT:outgoing:MIN:%8.1lf %sBps",
360 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j");
361 $ERROR = RRDs
::error
;
362 print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
365 # Generate the Firewall Graph for the current period of time for values given by collecd
367 sub updatefwhitsgraph
{
369 RRDs
::graph
("$graphs/fwhits-$period.png",
370 "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
371 "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}",
372 "--color", "SHADEA".$color{"color19"},
373 "--color", "SHADEB".$color{"color19"},
374 "--color", "BACK".$color{"color21"},
375 "-t $Lang::tr{'firewall hits per'} $Lang::tr{$period}",
376 "DEF:output=$rrdlog/collectd/localhost/iptables-filter-FORWARD/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
377 "DEF:input=$rrdlog/collectd/localhost/iptables-filter-INPUT/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
378 "DEF:newnotsyn=$rrdlog/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
379 "DEF:portscan=$rrdlog/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
380 "CDEF:amount=output,input,newnotsyn,+,+",
381 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
382 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
383 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
384 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
385 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
386 "AREA:amount".$color{"color24"}."A0:".sprintf("%-20s",$Lang::tr
{'firewallhits'}),
387 "GPRINT:amount:MAX:%8.1lf %sBps",
388 "GPRINT:amount:AVERAGE:%8.1lf %sBps",
389 "GPRINT:amount:MIN:%8.1lf %sBps",
390 "GPRINT:amount:LAST:%8.1lf %sBps\\j",
391 "STACK:portscan".$color{"color25"}."A0:".sprintf("%-20s",$Lang::tr
{'portscans'}),
392 "GPRINT:portscan:MAX:%8.1lf %sBps",
393 "GPRINT:portscan:MIN:%8.1lf %sBps",
394 "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
395 "GPRINT:portscan:LAST:%8.1lf %sBps\\j");
396 $ERROR = RRDs
::error
;
397 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
400 # Generate the Line Quality Graph for the current period of time for values given by collecd
404 RRDs
::graph
("$graphs/lq-$period.png",
405 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
406 "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-r", "-v ms",
407 "-t $Lang::tr{'linkq'} $Lang::tr{'graph per'} $Lang::tr{$period}",
408 "--color", "SHADEA".$color{"color19"},
409 "--color", "SHADEB".$color{"color19"},
410 "--color", "BACK".$color{"color21"},
411 "DEF:roundtrip=$rrdlog/collectd/localhost/ping/ping-gateway.rrd:ping:AVERAGE",
412 "COMMENT:$Lang::".sprintf("%-20s",$Lang::tr
{'caption'})."\\j",
413 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
414 "CDEF:r0=roundtrip,30,MIN",
415 "CDEF:r1=roundtrip,70,MIN",
416 "CDEF:r2=roundtrip,150,MIN",
417 "CDEF:r3=roundtrip,300,MIN",
418 "AREA:roundtrip".$color{"color25"}."A0:>300 ms",
419 "AREA:r3".$color{"color18"}."A0:150-300 ms",
420 "AREA:r2".$color{"color14"}."A0:70-150 ms",
421 "AREA:r1".$color{"color17"}."A0:30-70 ms",
422 "AREA:r0".$color{"color12"}."A0:<30 ms\\j",
423 "COMMENT:".sprintf("%-15s",$Lang::tr
{'maximal'}),
424 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
425 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
426 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
427 "LINE1:roundtrip#707070:",
428 "GPRINT:roundtrip:MAX:%3.2lf ms",
429 "GPRINT:roundtrip:AVERAGE:%3.2lf ms",
430 "GPRINT:roundtrip:MIN:%3.2lf ms",
431 "GPRINT:roundtrip:LAST:%3.2lf ms\\j");
432 $ERROR = RRDs
::error
;
433 print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
436 # Generate the Hdd Graph for the current period of time for values given by collecd
443 RRDs
::graph
("$graphs/hddtemp-$disk-$period.png",
444 "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
445 "--alt-y-grid", "-w 600", "-h 125",
446 "--color", "SHADEA".$color{"color19"},
447 "--color", "SHADEB".$color{"color19"},
448 "--color", "BACK".$color{"color21"},
449 "-t $disk $Lang::tr{'harddisk temperature'} $Lang::tr{'graph per'} $Lang::tr{$period}",
450 "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
451 "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
452 "CDEF:st=standby,INF,*",
453 "AREA:st".$color{"color20"}."A0:standby",
454 "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j",
455 "COMMENT:$Lang::tr{'maximal'}",
456 "COMMENT:$Lang::tr{'average'}",
457 "COMMENT:$Lang::tr{'minimal'}",
458 "COMMENT:$Lang::tr{'current'}\\j",
459 "GPRINT:temperature:MAX:%3.0lf Grad C",
460 "GPRINT:temperature:AVERAGE:%3.0lf Grad C",
461 "GPRINT:temperature:MIN:%3.0lf Grad C",
462 "GPRINT:temperature:LAST:%3.0lf Grad C\\j",
464 $ERROR = RRDs
::error
;
465 print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;
468 # Generate the QoS Graph for the current period of time
475 my %qossettings = ();
476 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
480 my $classfile = "/var/ipfire/qos/classes";
482 $qossettings{'DEV'} = $_[1];
483 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
484 $qossettings{'CLASSPRFX'} = '1';
486 $qossettings{'CLASSPRFX'} = '2';
489 if ( $period ne '3240' ){ $periodstring = "-1$period";}else{ $periodstring = "-".$period;}
490 if ( $period ne '3240' ){ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'}) ($Lang::tr{'graph per'} $Lang::tr{$period})";}else{ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'})";}
495 my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}-$period.png",
496 "--start", $periodstring, "-aPNG", "-i", "-z", "-W www.ipfire.org",
497 "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}",
498 "--color", "SHADEA".$color{"color19"},
499 "--color", "SHADEB".$color{"color19"},
500 "--color", "BACK".$color{"color21"},
501 "COMMENT:".sprintf("%-28s",$Lang::tr
{'caption'}),
502 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
503 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
504 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
505 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
508 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
511 foreach $classentry (sort @classes)
513 @classline = split( /\;/, $classentry );
514 if ( $classline[0] eq $qossettings{'DEV'} )
516 $color=random_hex_color
(6);
517 push(@command, "DEF:$classline[1]=$rrdlog/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
520 push(@command, "AREA:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));
522 push(@command, "STACK:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));
525 push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps");
526 push(@command, "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps");
527 push(@command, "GPRINT:$classline[1]:MIN:%8.1lf %sBps");
528 push(@command, "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");
532 RRDs
::graph
(@command);
533 $ERROR = RRDs
::error
;
537 # Generate the Temperature Graph for the current period of time for values given by collecd and mbmon
539 sub updatehwtempgraph
{
543 my @command = ("$graphs/mbmon-hwtemp-$period.png",
544 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
545 "--alt-y-grid", "-w 600", "-h 125",
546 "--color", "SHADEA".$color{"color19"},"--color",
547 "SHADEB".$color{"color19"},"--color",
548 "BACK".$color{"color21"},
549 "-t $Lang::tr{'mbmon temp'} $Lang::tr{'graph per'} $Lang::tr{$period}");
551 foreach(@mbmongraphs){
553 if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");
556 push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j");
557 foreach(@mbmongraphs){
559 if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color
(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}),
560 "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%3.2lf C\\j",);}
562 RRDs
::graph
(@command);
563 $ERROR = RRDs
::error
;
567 # Generate the Voltage Graph for the current period of time for values given by collecd and mbmon
569 sub updatehwvoltgraph
{
573 my @command = ("$graphs/mbmon-hwvolt-$period.png",
574 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
575 "--alt-y-grid", "-w 600", "-h 125",
576 "--color", "SHADEA".$color{"color19"},"--color",
577 "SHADEB".$color{"color19"},"--color",
578 "BACK".$color{"color21"},
579 "-t $Lang::tr{'mbmon volt'} $Lang::tr{'graph per'} $Lang::tr{$period}");
581 foreach(@mbmongraphs){
583 if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");}
585 push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j");
586 foreach(@mbmongraphs){
588 if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color
(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}),
589 "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%3.2lf V\\j",);}
591 RRDs
::graph
(@command);
592 $ERROR = RRDs
::error
;
596 # Generate the Load Graph for the current period of time for values given by collecd and mbmon
598 sub updatehwfangraph
{
602 my @command = ("$graphs/mbmon-hwfan-$period.png",
603 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
604 "--alt-y-grid", "-w 600", "-h 125",
605 "--color", "SHADEA".$color{"color19"},"--color",
606 "SHADEB".$color{"color19"},"--color",
607 "BACK".$color{"color21"},
608 "-t $Lang::tr{'mbmon fan'} $Lang::tr{'graph per'} $Lang::tr{$period}");
610 foreach(@mbmongraphs){
612 if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");}
614 push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j");
615 foreach(@mbmongraphs){
617 if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color
(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}),
618 "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%5.0lf RPM\\j",);}
620 RRDs
::graph
(@command);
621 $ERROR = RRDs
::error
;
625 sub updateprocessesgraph
{
630 my @command = ("$graphs/processes-$period.png",
631 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
632 "--alt-y-grid", "-w 600", "-h 125",
633 "--color", "SHADEA".$color{"color19"},"--color",
634 "SHADEB".$color{"color19"},"--color",
635 "BACK".$color{"color21"},
636 "-t $Lang::tr{'processes'} $Lang::tr{'graph per'} $Lang::tr{$period}");
638 foreach(@processesgraph){
639 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
640 push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");
641 push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");
642 push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");}
644 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
646 foreach(@processesgraph){
647 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
648 if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color
(6)."A0:".$name[1]);}
649 else {push(@command,"STACK:".$name[1].random_hex_color
(6)."A0:".$name[1]);}
652 RRDs
::graph
(@command);
653 $ERROR = RRDs
::error
;
658 my @command = ("$graphs/processesmem-$period.png",
659 "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
660 "--alt-y-grid", "-w 600", "-h 125",
661 "--color", "SHADEA".$color{"color19"},"--color",
662 "SHADEB".$color{"color19"},"--color",
663 "BACK".$color{"color21"},
664 "-t $Lang::tr{'processes'} $Lang::tr{'memory'} $Lang::tr{'graph per'} $Lang::tr{$period}");
666 foreach(@processesgraph){
667 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
668 push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");}
669 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
671 foreach(@processesgraph){
672 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
673 if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color
(6)."A0:".$name[1]);}
674 else {push(@command,"STACK:".$name[1].random_hex_color
(6)."A0:".$name[1]);}
677 RRDs
::graph
(@command);
678 $ERROR = RRDs
::error
;
682 # Generate a random color, used by Qos Graph to be independent from the amount of values
684 sub random_hex_color
{
686 $size = 6 if $size !~ /^3|6$/;
687 my @hex = ( 0 .. 9, 'a' .. 'f' );
689 push @color, @hex[rand(@hex)] for 1 .. $size;
690 return join('', '#', @color);