2 # Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed
3 ###############################################################################
5 # IPFire.org - A linux based firewall #
6 # Copyright (C) 2005-2010 IPFire Team #
8 # This program is free software: you can redistribute it and/or modify #
9 # it under the terms of the GNU General Public License as published by #
10 # the Free Software Foundation, either version 3 of the License, or #
11 # (at your option) any later version. #
13 # This program is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16 # GNU General Public License for more details. #
18 # You should have received a copy of the GNU General Public License #
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
21 ###############################################################################
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
34 # Read the global settings files to get the current theme and after this load
35 # colors for this theme
38 my %mainsettings = ();
39 my %sensorsettings = ();
40 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
41 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
43 if ( $mainsettings{'RRDLOG'} eq "" ){
44 $mainsettings{'RRDLOG'}="/var/log/rrd";
45 &General
::writehash
("${General::swroot}/main/settings", \
%mainsettings);
48 # If the collection deamon is working and collecting lm_sensors data there will be
49 # some data source named after a common scheme, with the sensorssettingsfile
50 # the user is able to deactivate some of this parameters, in case not to show
51 # false collected values may be disable. The user has the ability to enter
52 # custom graph names in order to change temp0 to cpu or motherboard
55 my @sensorsgraphs = ();
56 my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/ 2>/dev/null`;
57 foreach (@sensorsdir){
61 push(@sensorsgraphs,$_);
62 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
63 my $label = $2.$3;$label=~ s/-//g;
64 $sensorsettings{'LABEL-'.$label}="$label";
65 $sensorsettings{'LINE-'.$label}="checked";
69 &General
::readhash
("${General::swroot}/sensors/settings", \
%sensorsettings);
71 # Generate a nice box for selection of time range in graphs
72 # this will generate a nice iframe for the cgi every klick for
73 # the graph will be handled inside the iframe
74 # 0 is the cgi refering to
76 # 2 is the time range for the graph
77 # 3 if given is the height of the iframe default if nothing is given
83 if ( $_[3] ne "" ){ $height = $_[3]; }
86 print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr
{'hour'}."</b></a>";
88 print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr
{'day'}."</b></a>";
90 print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr
{'week'}."</b></a>";
92 print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr
{'month'}."</b></a>";
94 print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr
{'year'}."</b></a>";
95 print "<br></center>";
96 print "<iframe src='".$_[0]."?".$_[1]."?".$_[2]."' width='".$width."' height='".$height."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>";
99 # Generate the CPU Graph for the current period of time for values given by
100 # collectd we are now able to handle any kind of cpucount
103 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
119 "-t ".$Lang::tr
{'cpu usage per'}." ".$Lang::tr
{$period."-graph"},
120 "-v ".$Lang::tr
{'percentage'},
121 "--color=SHADEA".$color{"color19"},
122 "--color=SHADEB".$color{"color19"},
123 "--color=BACK".$color{"color21"},
124 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
125 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
126 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
127 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
128 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
131 my $nice = "CDEF:nice=";
132 my $interrupt = "CDEF:interrupt=";
133 my $steal = "CDEF:steal=";
134 my $user = "CDEF:user=";
135 my $system = "CDEF:system=";
136 my $idle = "CDEF:idle=";
137 my $iowait = "CDEF:iowait=";
138 my $irq = "CDEF:irq=";
141 for(my $i = 0; $i < $cpucount; $i++) {
142 push(@command,"DEF:iowait".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-wait.rrd:value:AVERAGE"
143 ,"DEF:nice".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-nice.rrd:value:AVERAGE"
144 ,"DEF:interrupt".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-interrupt.rrd:value:AVERAGE"
145 ,"DEF:steal".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-steal.rrd:value:AVERAGE"
146 ,"DEF:user".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-user.rrd:value:AVERAGE"
147 ,"DEF:system".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-system.rrd:value:AVERAGE"
148 ,"DEF:idle".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-idle.rrd:value:AVERAGE"
149 ,"DEF:irq".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-softirq.rrd:value:AVERAGE");
151 $nice .= "nice".$i.",";
152 $interrupt .= "interrupt".$i.",";
153 $steal .= "steal".$i.",";
154 $user .= "user".$i.",";
155 $system .= "system".$i.",";
156 $idle .= "idle".$i.",";
157 $iowait .= "iowait".$i.",";
158 $irq .= "irq".$i.",";
161 for(my $i = 2; $i < $cpucount; $i++) {
167 push(@command,$nice.$addstring
168 ,$interrupt.$addstring
176 chop($nice),chop($interrupt),chop($steal),chop($user),chop($system),chop($idle),chop($iowait),chop($irq);
177 push(@command,$nice,$interrupt,$steal,$user,$system,$idle,$iowait,$irq);
180 push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+"
181 ,"CDEF:userpct=100,user,total,/,*"
182 ,"CDEF:nicepct=100,nice,total,/,*"
183 ,"CDEF:interruptpct=100,interrupt,total,/,*"
184 ,"CDEF:stealpct=100,steal,total,/,*"
185 ,"CDEF:systempct=100,system,total,/,*"
186 ,"CDEF:idlepct=100,idle,total,/,*"
187 ,"CDEF:iowaitpct=100,iowait,total,/,*"
188 ,"CDEF:irqpct=100,irq,total,/,*"
189 ,"AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr
{'cpu iowait usage'})
190 ,"GPRINT:iowaitpct:MAX:%3.2lf%%"
191 ,"GPRINT:iowaitpct:AVERAGE:%3.2lf%%"
192 ,"GPRINT:iowaitpct:MIN:%3.2lf%%"
193 ,"GPRINT:iowaitpct:LAST:%3.2lf%%\\j"
194 ,"STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu irq usage'})
195 ,"GPRINT:irqpct:MAX:%3.2lf%%"
196 ,"GPRINT:irqpct:AVERAGE:%3.2lf%%"
197 ,"GPRINT:irqpct:MIN:%3.2lf%%"
198 ,"GPRINT:irqpct:LAST:%3.2lf%%\\j"
199 ,"STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu nice usage'})
200 ,"GPRINT:nicepct:MAX:%3.2lf%%"
201 ,"GPRINT:nicepct:AVERAGE:%3.2lf%%"
202 ,"GPRINT:nicepct:MIN:%3.2lf%%"
203 ,"GPRINT:nicepct:LAST:%3.2lf%%\\j"
204 ,"STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu interrupt usage'})
205 ,"GPRINT:interruptpct:MAX:%3.2lf%%"
206 ,"GPRINT:interruptpct:AVERAGE:%3.2lf%%"
207 ,"GPRINT:interruptpct:MIN:%3.2lf%%"
208 ,"GPRINT:interruptpct:LAST:%3.2lf%%\\j"
209 ,"STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu steal usage'})
210 ,"GPRINT:stealpct:MAX:%3.2lf%%"
211 ,"GPRINT:stealpct:AVERAGE:%3.2lf%%"
212 ,"GPRINT:stealpct:MIN:%3.2lf%%"
213 ,"GPRINT:stealpct:LAST:%3.2lf%%\\j"
214 ,"STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu user usage'})
215 ,"GPRINT:userpct:MAX:%3.2lf%%"
216 ,"GPRINT:userpct:AVERAGE:%3.2lf%%"
217 ,"GPRINT:userpct:MIN:%3.2lf%%"
218 ,"GPRINT:userpct:LAST:%3.2lf%%\\j"
219 ,"STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu system usage'})
220 ,"GPRINT:systempct:MAX:%3.2lf%%"
221 ,"GPRINT:systempct:AVERAGE:%3.2lf%%"
222 ,"GPRINT:systempct:MIN:%3.2lf%%"
223 ,"GPRINT:systempct:LAST:%3.2lf%%\\j"
224 ,"STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu idle usage'})
225 ,"GPRINT:idlepct:MAX:%3.2lf%%"
226 ,"GPRINT:idlepct:AVERAGE:%3.2lf%%"
227 ,"GPRINT:idlepct:MIN:%3.2lf%%"
228 ,"GPRINT:idlepct:LAST:%3.2lf%%\\j");
230 RRDs
::graph
(@command);
231 $ERROR = RRDs
::error
;
232 print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR;
235 # Generate the Load Graph for the current period of time for values given by collecd
237 sub updateloadgraph
{
252 "-t Load Average ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
253 "-v ".$Lang::tr
{'processes'},
254 "--color=SHADEA".$color{"color19"},
255 "--color=SHADEB".$color{"color19"},
256 "--color=BACK".$color{"color21"},
257 "DEF:load1=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:shortterm:AVERAGE",
258 "DEF:load5=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:midterm:AVERAGE",
259 "DEF:load15=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:longterm:AVERAGE",
260 "AREA:load1".$color{"color13"}."A0:1 ".$Lang::tr
{'minute'},
261 "GPRINT:load1:LAST:%5.2lf",
262 "AREA:load5".$color{"color18"}."A0:5 ".$Lang::tr
{'minutes'},
263 "GPRINT:load5:LAST:%5.2lf",
264 "AREA:load15".$color{"color14"}."A0:15 ".$Lang::tr
{'minutes'},
265 "GPRINT:load15:LAST:%5.2lf\\j",
266 "LINE1:load5".$color{"color13"},
267 "LINE1:load1".$color{"color18"},
269 $ERROR = RRDs
::error
;
270 print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR;
273 # Generate the Memory Graph for the current period of time for values given by collecd
275 sub updatememorygraph
{
291 "-t ".$Lang::tr
{'memory usage per'}." ".$Lang::tr
{$period."-graph"},
292 "-v ".$Lang::tr
{'percentage'},
293 "--color=SHADEA".$color{"color19"},
294 "--color=SHADEB".$color{"color19"},
295 "--color=BACK".$color{"color21"},
296 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",
297 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",
298 "DEF:buffer=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",
299 "DEF:cache=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",
300 "CDEF:total=used,free,cache,buffer,+,+,+",
301 "CDEF:usedpct=used,total,/,100,*",
302 "CDEF:bufferpct=buffer,total,/,100,*",
303 "CDEF:cachepct=cache,total,/,100,*",
304 "CDEF:freepct=free,total,/,100,*",
305 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
306 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
307 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
308 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
309 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
310 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used memory'}),
311 "GPRINT:usedpct:MAX:%3.2lf%%",
312 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
313 "GPRINT:usedpct:MIN:%3.2lf%%",
314 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
315 "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'buffered memory'}),
316 "GPRINT:bufferpct:MAX:%3.2lf%%",
317 "GPRINT:bufferpct:AVERAGE:%3.2lf%%",
318 "GPRINT:bufferpct:MIN:%3.2lf%%",
319 "GPRINT:bufferpct:LAST:%3.2lf%%\\j",
320 "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr
{'cached memory'}),
321 "GPRINT:cachepct:MAX:%3.2lf%%",
322 "GPRINT:cachepct:AVERAGE:%3.2lf%%",
323 "GPRINT:cachepct:MIN:%3.2lf%%",
324 "GPRINT:cachepct:LAST:%3.2lf%%\\j",
325 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free memory'}),
326 "GPRINT:freepct:MAX:%3.2lf%%",
327 "GPRINT:freepct:AVERAGE:%3.2lf%%",
328 "GPRINT:freepct:MIN:%3.2lf%%",
329 "GPRINT:freepct:LAST:%3.2lf%%\\j",
331 $ERROR = RRDs
::error
;
332 print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
335 # Generate the Swap Graph for the current period of time for values given by collecd
337 sub updateswapgraph
{
353 "-t ".$Lang::tr
{'swap usage per'}." ".$Lang::tr
{$period."-graph"},
354 "-v ".$Lang::tr
{'percentage'},
355 "--color=SHADEA".$color{"color19"},
356 "--color=SHADEB".$color{"color19"},
357 "--color=BACK".$color{"color21"},
358 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",
359 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",
360 "DEF:cached=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",
361 "CDEF:total=used,free,cached,+,+",
362 "CDEF:usedpct=100,used,total,/,*",
363 "CDEF:freepct=100,free,total,/,*",
364 "CDEF:cachedpct=100,cached,total,/,*",
365 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
366 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
367 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
368 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
369 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
370 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used swap'}),
371 "GPRINT:usedpct:MAX:%3.2lf%%",
372 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
373 "GPRINT:usedpct:MIN:%3.2lf%%",
374 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
375 "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cached swap'}),
376 "GPRINT:cachedpct:MAX:%3.2lf%%",
377 "GPRINT:cachedpct:AVERAGE:%3.2lf%%",
378 "GPRINT:cachedpct:MIN:%3.2lf%%",
379 "GPRINT:cachedpct:LAST:%3.2lf%%\\j",
380 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free swap'}),
381 "GPRINT:freepct:MAX:%3.2lf%%",
382 "GPRINT:freepct:AVERAGE:%3.2lf%%",
383 "GPRINT:freepct:MIN:%3.2lf%%",
384 "GPRINT:freepct:LAST:%3.2lf%%\\j",
386 $ERROR = RRDs
::error
;
387 print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
390 # Generate the Process Cpu Graph for the current period of time for values given by collecd
392 sub updateprocessescpugraph
{
393 my @processesgraph = getprocesses
();
410 "-t ".$Lang::tr
{'processes'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
411 "--color=SHADEA".$color{"color19"},
412 "--color=SHADEB".$color{"color19"},
413 "--color=BACK".$color{"color21"}
416 foreach(@processesgraph){
417 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
418 push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");
419 push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");
420 push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");
423 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
426 foreach(@processesgraph){
427 my $colorIndex = 10 + $count % 15;
428 my $color="$color{\"color$colorIndex\"}";
429 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
431 push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
433 push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
438 RRDs
::graph
(@command);
439 $ERROR = RRDs
::error
;
440 print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR;
443 # Generate the Process Memory Graph for the current period of time for values given by collecd
445 sub updateprocessesmemorygraph
{
446 my @processesgraph = getprocesses
();
463 "-t ".$Lang::tr
{'processes'}." ".$Lang::tr
{'memory'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
464 "-v ".$Lang::tr
{'bytes'},
465 "--color=SHADEA".$color{"color19"},
466 "--color=SHADEB".$color{"color19"},
467 "--color=BACK".$color{"color21"}
470 foreach(@processesgraph){
471 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
472 push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");
475 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
478 foreach(@processesgraph){
479 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
480 my $colorIndex = 10 + $count % 15;
481 my $color="$color{\"color$colorIndex\"}";
483 push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
485 push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
490 RRDs
::graph
(@command);
491 $ERROR = RRDs
::error
;
492 print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR;
495 # Generate the Disk Graph for the current period of time for values given by collecd
497 sub updatediskgraph
{
512 "-t ".$disk." ".$Lang::tr
{'disk access per'}." ".$Lang::tr
{$period."-graph"},
513 "-v ".$Lang::tr
{'bytes per second'},
514 "--color=SHADEA".$color{"color19"},
515 "--color=SHADEB".$color{"color19"},
516 "--color=BACK".$color{"color21"},
517 "DEF:read=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",
518 "DEF:write=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",
519 "CDEF:writen=write,-1,*",
520 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-".$disk.".rrd:standby:AVERAGE",
521 "CDEF:st=standby,INF,*",
522 "CDEF:st1=standby,NEGINF,*",
523 "COMMENT:".sprintf("%-25s",$Lang::tr
{'caption'}),
524 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
525 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
526 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
527 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
528 "AREA:st".$color{"color20"}."A0:",
529 "AREA:st1".$color{"color20"}."A0:standby\\j",
530 "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'read bytes'}),
531 "GPRINT:read:MAX:%8.1lf %sBps",
532 "GPRINT:read:AVERAGE:%8.1lf %sBps",
533 "GPRINT:read:MIN:%8.1lf %sBps",
534 "GPRINT:read:LAST:%8.1lf %sBps\\j",
535 "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'written bytes'}),
536 "GPRINT:write:MAX:%8.1lf %sBps",
537 "GPRINT:write:AVERAGE:%8.1lf %sBps",
538 "GPRINT:write:MIN:%8.1lf %sBps",
539 "GPRINT:write:LAST:%8.1lf %sBps\\j",
541 $ERROR = RRDs
::error
;
542 print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR;
545 # Generate the Interface Graph for the current period of time for values given by collecd
548 my $interface = $_[0];
562 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
563 "-v ".$Lang::tr
{'bytes per second'},
564 "--color=SHADEA".$color{"color19"},
565 "--color=SHADEB".$color{"color19"},
566 "--color=BACK".$color{"color21"},
567 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:rx:AVERAGE",
568 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:tx:AVERAGE",
569 "CDEF:outgoingn=outgoing,-1,*",
570 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
571 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
572 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
573 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
574 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
575 "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
576 "GPRINT:incoming:MAX:%8.1lf %sBps",
577 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
578 "GPRINT:incoming:MIN:%8.1lf %sBps",
579 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
580 "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
581 "GPRINT:outgoing:MAX:%8.1lf %sBps",
582 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
583 "GPRINT:outgoing:MIN:%8.1lf %sBps",
584 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
586 $ERROR = RRDs
::error
;
587 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
591 my $interface = $_[0];
605 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
606 "-v ".$Lang::tr
{'bytes per second'},
607 "--color=SHADEA".$color{"color19"},
608 "--color=SHADEB".$color{"color19"},
609 "--color=BACK".$color{"color21"},
610 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:rx:AVERAGE",
611 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:tx:AVERAGE",
612 "CDEF:outgoingn=outgoing,-1,*",
613 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
614 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
615 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
616 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
617 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
618 "AREA:incoming#00dd00:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
619 "GPRINT:incoming:MAX:%8.1lf %sBps",
620 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
621 "GPRINT:incoming:MIN:%8.1lf %sBps",
622 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
623 "AREA:outgoingn#dd0000:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
624 "GPRINT:outgoing:MAX:%8.1lf %sBps",
625 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
626 "GPRINT:outgoing:MIN:%8.1lf %sBps",
627 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
629 $ERROR = RRDs
::error
;
630 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
633 sub updatevpnn2ngraph
{
634 my $interface = $_[0];
648 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
649 "-v ".$Lang::tr
{'bytes per second'},
650 "--color=SHADEA".$color{"color19"},
651 "--color=SHADEB".$color{"color19"},
652 "--color=BACK".$color{"color21"},
653 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:rx:AVERAGE",
654 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:tx:AVERAGE",
655 "DEF:overhead_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:rx:AVERAGE",
656 "DEF:overhead_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:tx:AVERAGE",
657 "DEF:compression_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_in.rrd:uncompressed:AVERAGE",
658 "DEF:compression_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_out.rrd:uncompressed:AVERAGE",
659 "CDEF:outgoingn=outgoing,-1,*",
660 "CDEF:overhead_outn=overhead_out,-1,*",
661 "CDEF:compression_outn=compression_out,-1,*",
662 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
663 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
664 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
665 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
666 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
667 "AREA:incoming#00dd00:".sprintf("%-23s",$Lang::tr
{'incoming traffic in bytes per second'}),
668 "GPRINT:incoming:MAX:%8.1lf %sBps",
669 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
670 "GPRINT:incoming:MIN:%8.1lf %sBps",
671 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
672 "STACK:overhead_in#116B11:".sprintf("%-23s",$Lang::tr
{'incoming overhead in bytes per second'}),
673 "GPRINT:overhead_in:MAX:%8.1lf %sBps",
674 "GPRINT:overhead_in:AVERAGE:%8.1lf %sBps",
675 "GPRINT:overhead_in:MIN:%8.1lf %sBps",
676 "GPRINT:overhead_in:LAST:%8.1lf %sBps\\j",
677 "LINE1:compression_in#ff00ff:".sprintf("%-23s",$Lang::tr
{'incoming compression in bytes per second'}),
678 "GPRINT:compression_in:MAX:%8.1lf %sBps",
679 "GPRINT:compression_in:AVERAGE:%8.1lf %sBps",
680 "GPRINT:compression_in:MIN:%8.1lf %sBps",
681 "GPRINT:compression_in:LAST:%8.1lf %sBps\\j",
682 "AREA:outgoingn#dd0000:".sprintf("%-23s",$Lang::tr
{'outgoing traffic in bytes per second'}),
683 "GPRINT:outgoing:MAX:%8.1lf %sBps",
684 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
685 "GPRINT:outgoing:MIN:%8.1lf %sBps",
686 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
687 "STACK:overhead_outn#870C0C:".sprintf("%-23s",$Lang::tr
{'outgoing overhead in bytes per second'}),
688 "GPRINT:overhead_out:MAX:%8.1lf %sBps",
689 "GPRINT:overhead_out:AVERAGE:%8.1lf %sBps",
690 "GPRINT:overhead_out:MIN:%8.1lf %sBps",
691 "GPRINT:overhead_out:LAST:%8.1lf %sBps\\j",
692 "LINE1:compression_outn#000000:".sprintf("%-23s",$Lang::tr
{'outgoing compression in bytes per second'}),
693 "GPRINT:compression_out:MAX:%8.1lf %sBps",
694 "GPRINT:compression_out:AVERAGE:%8.1lf %sBps",
695 "GPRINT:compression_out:MIN:%8.1lf %sBps",
696 "GPRINT:compression_out:LAST:%8.1lf %sBps\\j",
698 $ERROR = RRDs
::error
;
699 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
702 # Generate the Firewall Graph for the current period of time for values given by collecd
704 sub updatefwhitsgraph
{
718 "-t ".$Lang::tr
{'firewall hits per'}." ".$Lang::tr
{$period."-graph"},
719 "-v ".$Lang::tr
{'bytes per second'},
720 "--color=SHADEA".$color{"color19"},
721 "--color=SHADEB".$color{"color19"},
722 "--color=BACK".$color{"color21"},
723 "DEF:output=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYOUT/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
724 "DEF:input=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYIN/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
725 "DEF:forward=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYFWD/ipt_bytes-DROP_FORWARD.rrd:value:AVERAGE",
726 "DEF:newnotsyn=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
727 "DEF:portscan=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
728 "COMMENT:".sprintf("%-26s",$Lang::tr
{'caption'}),
729 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
730 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
731 "COMMENT:".sprintf("%14s",$Lang::tr
{'minimal'}),
732 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
733 "AREA:output".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}."-OUTPUT"),
734 "GPRINT:output:MAX:%8.1lf %sBps",
735 "GPRINT:output:AVERAGE:%8.1lf %sBps",
736 "GPRINT:output:MIN:%8.1lf %sBps",
737 "GPRINT:output:LAST:%8.1lf %sBps\\j",
738 "STACK:forward".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}."-FORWARD"),
739 "GPRINT:forward:MAX:%8.1lf %sBps",
740 "GPRINT:forward:AVERAGE:%8.1lf %sBps",
741 "GPRINT:forward:MIN:%8.1lf %sBps",
742 "GPRINT:forward:LAST:%8.1lf %sBps\\j",
743 "STACK:input".$color{"color24"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}."-INPUT"),
744 "GPRINT:input:MAX:%8.1lf %sBps",
745 "GPRINT:input:AVERAGE:%8.1lf %sBps",
746 "GPRINT:input:MIN:%8.1lf %sBps",
747 "GPRINT:input:LAST:%8.1lf %sBps\\j",
748 "STACK:newnotsyn".$color{"color14"}."A0:".sprintf("%-25s","NewNotSyn"),
749 "GPRINT:newnotsyn:MAX:%8.1lf %sBps",
750 "GPRINT:newnotsyn:MIN:%8.1lf %sBps",
751 "GPRINT:newnotsyn:AVERAGE:%8.1lf %sBps",
752 "GPRINT:newnotsyn:LAST:%8.1lf %sBps\\j",
753 "STACK:portscan".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'portscans'}),
754 "GPRINT:portscan:MAX:%8.1lf %sBps",
755 "GPRINT:portscan:MIN:%8.1lf %sBps",
756 "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
757 "GPRINT:portscan:LAST:%8.1lf %sBps\\j",
759 $ERROR = RRDs
::error
;
760 print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR;
763 # Generate the Line Quality Graph for the current period of time for values given by collecd
765 sub updatepinggraph
{
781 "-t ".$Lang::tr
{'linkq'}." ".$host." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
783 "--color=SHADEA".$color{"color19"},
784 "--color=SHADEB".$color{"color19"},
785 "--color=BACK".$color{"color21"},
786 "DEF:roundtrip=".$mainsettings{'RRDLOG'}."/collectd/localhost/ping/ping-".$host.".rrd:ping:AVERAGE",
787 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'})."\\j",
788 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
789 "CDEF:r0=roundtrip,30,MIN",
790 "CDEF:r1=roundtrip,70,MIN",
791 "CDEF:r2=roundtrip,150,MIN",
792 "CDEF:r3=roundtrip,300,MIN",
793 "AREA:roundtrip".$color{"color25"}."A0:>300 ms",
794 "AREA:r3".$color{"color18"}."A0:150-300 ms",
795 "AREA:r2".$color{"color14"}."A0:70-150 ms",
796 "AREA:r1".$color{"color17"}."A0:30-70 ms",
797 "AREA:r0".$color{"color12"}."A0:<30 ms\\j",
798 "COMMENT:$Lang::tr{'maximal'}",
799 "COMMENT:$Lang::tr{'average'}",
800 "COMMENT:$Lang::tr{'minimal'}","COMMENT:$Lang::tr{'current'}\\j",
801 "LINE1:roundtrip#707070:",
802 "GPRINT:roundtrip:MAX:%3.2lf ms",
803 "GPRINT:roundtrip:AVERAGE:%3.2lf ms",
804 "GPRINT:roundtrip:MIN:%3.2lf ms",
805 "GPRINT:roundtrip:LAST:%3.2lf ms\\j",
807 $ERROR = RRDs
::error
;
808 print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR;
811 sub updatewirelessgraph
{
813 my $interface = $_[0];
825 "-t Wireless ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
827 "--color=SHADEA".$color{"color19"},
828 "--color=SHADEB".$color{"color19"},
829 "--color=BACK".$color{"color21"},
830 "DEF:noise=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_noise.rrd:value:AVERAGE",
831 "DEF:power=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_power.rrd:value:AVERAGE",
832 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
833 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
834 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
835 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
836 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
837 "LINE1:noise".$color{"color11"}."A0:".sprintf("%-20s","Signal Noise Ratio"),
838 "GPRINT:noise:MAX:%5.1lf %sdBm",
839 "GPRINT:noise:AVERAGE:%5.1lf %sdBm",
840 "GPRINT:noise:MIN:%5.1lf %sdBm",
841 "GPRINT:noise:LAST:%5.1lf %sdBm\\j",
842 "LINE1:power".$color{"color12"}."A0:".sprintf("%-20s","Signal Power Ratio"),
843 "GPRINT:power:MAX:%5.1lf %sdBm",
844 "GPRINT:power:AVERAGE:%5.1lf %sdBm",
845 "GPRINT:power:MIN:%5.1lf %sdBm",
846 "GPRINT:power:LAST:%5.1lf %sdBm\\j",
848 $ERROR = RRDs
::error
;
849 print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR;
852 # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors
869 "-t ".$disk." ".$Lang::tr
{'harddisk temperature'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
871 "--color=SHADEA".$color{"color19"},
872 "--color=SHADEB".$color{"color19"},
873 "--color=BACK".$color{"color21"},
874 "DEF:temperature=".$mainsettings{'RRDLOG'}."/hddtemp-$disk.rrd:temperature:AVERAGE",
875 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-$disk.rrd:standby:AVERAGE",
876 "CDEF:st=standby,INF,*",
877 "AREA:st".$color{"color20"}."A0:standby",
878 "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j",
879 "COMMENT:$Lang::tr{'maximal'}",
880 "COMMENT:$Lang::tr{'average'}",
881 "COMMENT:$Lang::tr{'minimal'}",
882 "COMMENT:$Lang::tr{'current'}\\j",
883 "GPRINT:temperature:MAX:%3.0lf Grad C",
884 "GPRINT:temperature:AVERAGE:%3.0lf Grad C",
885 "GPRINT:temperature:MIN:%3.0lf Grad C",
886 "GPRINT:temperature:LAST:%3.0lf Grad C\\j",
888 $ERROR = RRDs
::error
;
889 print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR;
892 # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors
894 sub updatehwtempgraph
{
909 "-t ".$Lang::tr
{'mbmon temp'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
910 "--color=SHADEA".$color{"color19"},
911 "--color=SHADEB".$color{"color19"},
912 "--color=BACK".$color{"color21"},
913 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
914 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
915 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
916 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
917 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
920 foreach(@sensorsgraphs){
922 if ( $_ =~ /temperature/ ) {
923 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
924 my $label = $2.$3;$label=~ s/-//g;
925 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
926 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
930 foreach(@sensorsgraphs){
932 if ( $_ =~ /temperature/ ){
933 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
934 my $label = $2.$3;$label=~ s/-//g;
935 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
936 push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color
(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf C\\j",);
940 RRDs
::graph
(@command);
941 $ERROR = RRDs
::error
;
942 print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR;
945 # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors
947 sub updatehwfangraph
{
962 "-t ".$Lang::tr
{'mbmon fan'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
963 "--color=SHADEA".$color{"color19"},
964 "--color=SHADEB".$color{"color19"},
965 "--color=BACK".$color{"color21"},
966 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
967 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
968 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
969 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
970 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
973 foreach(@sensorsgraphs){
975 if ( $_ =~ /fanspeed/ ) {
976 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
977 my $label = $2.$3;$label=~ s/-//g;
978 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
979 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
983 foreach(@sensorsgraphs){
985 if ( $_ =~ /fanspeed/ ){
986 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
987 my $label = $2.$3;$label=~ s/-//g;
988 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
989 push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color
(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf RPM\\j",);
993 RRDs
::graph
(@command);
994 $ERROR = RRDs
::error
;
995 print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR;
998 # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors
1000 sub updatehwvoltgraph
{
1010 "-W www.ipfire.org",
1015 "-t ".$Lang::tr
{'mbmon volt'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
1016 "--color=SHADEA".$color{"color19"},
1017 "--color=SHADEB".$color{"color19"},
1018 "--color=BACK".$color{"color21"},
1019 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
1020 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1021 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1022 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1023 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1026 foreach(@sensorsgraphs){
1028 if ( $_ =~ /voltage/ ) {
1029 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
1030 my $label = $2.$3;$label=~ s/-//g;
1031 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
1032 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
1036 foreach(@sensorsgraphs){
1038 if ( $_ =~ /voltage/ ){
1039 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
1040 my $label = $2.$3;$label=~ s/-//g;
1041 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
1042 push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color
(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf V\\j",);
1046 RRDs
::graph
(@command);
1047 $ERROR = RRDs
::error
;
1048 print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR;
1052 # Generate the QoS Graph for the current period of time
1054 sub updateqosgraph
{
1057 my %qossettings = ();
1058 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
1060 my $classentry = "";
1063 my $classfile = "/var/ipfire/qos/classes";
1065 $qossettings{'DEV'} = $_[0];
1066 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
1067 $qossettings{'CLASSPRFX'} = '1';
1069 $qossettings{'CLASSPRFX'} = '2';
1074 my $color="#000000";
1083 "-W www.ipfire.org",
1088 "-t ".$Lang::tr
{'Utilization on'}." (".$qossettings{'DEV'}.") ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
1089 "-v ".$Lang::tr
{'bytes per second'},
1090 "--color=SHADEA".$color{"color19"},
1091 "--color=SHADEB".$color{"color19"},
1092 "--color=BACK".$color{"color21"},
1093 "COMMENT:".sprintf("%-28s",$Lang::tr
{'caption'}),
1094 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1095 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1096 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1097 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1100 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1105 foreach $classentry (sort @classes){
1106 @classline = split( /\;/, $classentry );
1107 if ( $classline[0] eq $qossettings{'DEV'} ){
1108 my $colorIndex = 10 + $count % 15;
1109 $color="$color{\"color$colorIndex\"}";
1110 push(@command, "DEF:$classline[1]=$mainsettings{'RRDLOG'}/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
1112 if ($count eq "1") {
1113 push(@command, "AREA:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1115 push(@command, "STACK:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1118 push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"
1119 , "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps"
1120 , "GPRINT:$classline[1]:MIN:%8.1lf %sBps"
1121 , "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");
1125 RRDs
::graph
(@command);
1126 $ERROR = RRDs
::error
;
1127 print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR;
1130 # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors
1132 sub updatecpufreqgraph
{
1133 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
1142 "-W www.ipfire.org",
1147 "-t ".$Lang::tr
{'cpu frequency per'}." ".$Lang::tr
{$period."-graph"},
1149 "--color=SHADEA".$color{"color19"},
1150 "--color=SHADEB".$color{"color19"},
1151 "--color=BACK".$color{"color21"},
1152 "COMMENT:".sprintf("%-10s",$Lang::tr
{'caption'}),
1153 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1154 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1155 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1156 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1159 for(my $i = 0; $i < $cpucount; $i++) {
1161 push(@command,"DEF:cpu".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpufreq/cpufreq-".$i.".rrd:value:AVERAGE"
1162 ,"CDEF:cpu".$i."=cpu".$i."_,1000000,/"
1163 ,"LINE1:cpu".$i.$color{"color1$j"}."A0:cpu ".$i." "
1164 ,"GPRINT:cpu".$i.":MAX:%3.0lf Mhz"
1165 ,"GPRINT:cpu".$i.":AVERAGE:%3.0lf Mhz"
1166 ,"GPRINT:cpu".$i.":MIN:%3.0lf Mhz"
1167 ,"GPRINT:cpu".$i.":LAST:%3.0lf Mhz\\j");
1170 RRDs
::graph
(@command);
1171 $ERROR = RRDs
::error
;
1172 print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
1175 # Generate the Thermal Zone Temp CPU Graph
1177 sub updatethermaltempgraph
{
1178 my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null | wc -l`;
1187 "-W www.ipfire.org",
1192 "-t "."ACPI Thermal-Zone Temperature"." - ".$Lang::tr
{$period."-graph"},
1194 "--color=SHADEA".$color{"color19"},
1195 "--color=SHADEB".$color{"color19"},
1196 "--color=BACK".$color{"color21"},
1197 "COMMENT:".sprintf("%-10s",$Lang::tr
{'caption'}),
1198 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1199 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1200 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1201 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1204 for(my $i = 0; $i < $thermalcount; $i++) {
1206 push(@command,"DEF:temp".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/thermal-thermal_zone".$i."/temperature-temperature.rrd:value:AVERAGE"
1207 ,"CDEF:temp".$i."=temp".$i."_,1,/"
1208 ,"LINE3:temp".$i.$color{"color1$j"}."A0:Temp ".$i." "
1209 ,"GPRINT:temp".$i.":MAX:%3.0lf Grad C"
1210 ,"GPRINT:temp".$i.":AVERAGE:%3.0lf Grad C"
1211 ,"GPRINT:temp".$i.":MIN:%3.0lf Grad C"
1212 ,"GPRINT:temp".$i.":LAST:%3.0lf Grad C\\j");
1215 RRDs
::graph
(@command);
1216 $ERROR = RRDs
::error
;
1217 print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
1221 # Generate a random color, used by Qos Graph to be independent from the amount of values
1223 sub random_hex_color
{
1225 $size = 6 if $size !~ /^3|6$/;
1226 my @hex = ( 0 .. 9, 'a' .. 'f' );
1228 push @color, @hex[rand(@hex)] for 1 .. $size;
1229 return join('', '#', @color);
1233 my @processesgraph = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/processes-*/ 2>/dev/null`;
1234 return @processesgraph;
1237 sub updateentropygraph
{
1246 "-W www.ipfire.org",
1251 "--lower-limit","0",
1252 "-t $Lang::tr{'entropy'}",
1253 "-v $Lang::tr{'bit'}",
1254 "DEF:entropy=$mainsettings{'RRDLOG'}/collectd/localhost/entropy/entropy.rrd:entropy:AVERAGE",
1255 "LINE3:entropy#ff0000:" . sprintf("%-15s", $Lang::tr
{'entropy'}),
1256 "VDEF:entrmin=entropy,MINIMUM",
1257 "VDEF:entrmax=entropy,MAXIMUM",
1258 "VDEF:entravg=entropy,AVERAGE",
1259 "GPRINT:entrmax:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'maximum'}),
1260 "GPRINT:entrmin:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'minimum'}),
1261 "GPRINT:entravg:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'average'}) . "\\n",
1264 RRDs
::graph
(@command);
1265 $ERROR = RRDs
::error
;
1267 print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR;