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";
41 # For a more 'organic' look
44 # HxW define the size of the output image
54 # Use alternative grid
58 # Read the global settings files to get the current theme and after this load
59 # colors for this theme
62 my %mainsettings = ();
63 my %sensorsettings = ();
64 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
65 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
67 if ( $mainsettings{'RRDLOG'} eq "" ){
68 $mainsettings{'RRDLOG'}="/var/log/rrd";
69 &General
::writehash
("${General::swroot}/main/settings", \
%mainsettings);
72 # If the collection deamon is working and collecting lm_sensors data there will be
73 # some data source named after a common scheme, with the sensorssettingsfile
74 # the user is able to deactivate some of this parameters, in case not to show
75 # false collected values may be disable. The user has the ability to enter
76 # custom graph names in order to change temp0 to cpu or motherboard
79 my @sensorsgraphs = ();
80 my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/ 2>/dev/null`;
81 foreach (@sensorsdir){
85 push(@sensorsgraphs,$_);
86 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
87 my $label = $2.$3;$label=~ s/-//g;
88 $sensorsettings{'LABEL-'.$label}="$label";
89 $sensorsettings{'LINE-'.$label}="checked";
93 &General
::readhash
("${General::swroot}/sensors/settings", \
%sensorsettings);
95 # Generate a nice box for selection of time range in graphs
96 # this will generate a nice iframe for the cgi every klick for
97 # the graph will be handled inside the iframe
98 # 0 is the cgi refering to
100 # 2 is the time range for the graph
101 # 3 if given is the height of the iframe default if nothing is given
105 print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr
{'hour'}."</b></a>";
107 print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr
{'day'}."</b></a>";
109 print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr
{'week'}."</b></a>";
111 print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr
{'month'}."</b></a>";
113 print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr
{'year'}."</b></a>";
114 print "<br></center>";
115 print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>";
118 # Generate the CPU Graph for the current period of time for values given by
119 # collectd we are now able to handle any kind of cpucount
122 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
132 "-t ".$Lang::tr
{'cpu usage per'}." ".$Lang::tr
{$period."-graph"},
133 "-v ".$Lang::tr
{'percentage'},
134 "--color=SHADEA".$color{"color19"},
135 "--color=SHADEB".$color{"color19"},
136 "--color=BACK".$color{"color21"},
137 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
138 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
139 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
140 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
141 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
144 my $nice = "CDEF:nice=";
145 my $interrupt = "CDEF:interrupt=";
146 my $steal = "CDEF:steal=";
147 my $user = "CDEF:user=";
148 my $system = "CDEF:system=";
149 my $idle = "CDEF:idle=";
150 my $iowait = "CDEF:iowait=";
151 my $irq = "CDEF:irq=";
154 for(my $i = 0; $i < $cpucount; $i++) {
155 push(@command,"DEF:iowait".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-wait.rrd:value:AVERAGE"
156 ,"DEF:nice".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-nice.rrd:value:AVERAGE"
157 ,"DEF:interrupt".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-interrupt.rrd:value:AVERAGE"
158 ,"DEF:steal".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-steal.rrd:value:AVERAGE"
159 ,"DEF:user".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-user.rrd:value:AVERAGE"
160 ,"DEF:system".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-system.rrd:value:AVERAGE"
161 ,"DEF:idle".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-idle.rrd:value:AVERAGE"
162 ,"DEF:irq".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-softirq.rrd:value:AVERAGE");
164 $nice .= "nice".$i.",";
165 $interrupt .= "interrupt".$i.",";
166 $steal .= "steal".$i.",";
167 $user .= "user".$i.",";
168 $system .= "system".$i.",";
169 $idle .= "idle".$i.",";
170 $iowait .= "iowait".$i.",";
171 $irq .= "irq".$i.",";
174 for(my $i = 2; $i < $cpucount; $i++) {
175 $addstring .= "ADDNAN,";
180 push(@command,$nice.$addstring
181 ,$interrupt.$addstring
189 chop($nice),chop($interrupt),chop($steal),chop($user),chop($system),chop($idle),chop($iowait),chop($irq);
190 push(@command,$nice,$interrupt,$steal,$user,$system,$idle,$iowait,$irq);
193 push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN"
194 ,"CDEF:userpct=100,user,total,/,*"
195 ,"CDEF:nicepct=100,nice,total,/,*"
196 ,"CDEF:interruptpct=100,interrupt,total,/,*"
197 ,"CDEF:stealpct=100,steal,total,/,*"
198 ,"CDEF:systempct=100,system,total,/,*"
199 ,"CDEF:idlepct=100,idle,total,/,*"
200 ,"CDEF:iowaitpct=100,iowait,total,/,*"
201 ,"CDEF:irqpct=100,irq,total,/,*"
202 ,"AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr
{'cpu iowait usage'})
203 ,"GPRINT:iowaitpct:MAX:%3.2lf%%"
204 ,"GPRINT:iowaitpct:AVERAGE:%3.2lf%%"
205 ,"GPRINT:iowaitpct:MIN:%3.2lf%%"
206 ,"GPRINT:iowaitpct:LAST:%3.2lf%%\\j"
207 ,"STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu irq usage'})
208 ,"GPRINT:irqpct:MAX:%3.2lf%%"
209 ,"GPRINT:irqpct:AVERAGE:%3.2lf%%"
210 ,"GPRINT:irqpct:MIN:%3.2lf%%"
211 ,"GPRINT:irqpct:LAST:%3.2lf%%\\j"
212 ,"STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu nice usage'})
213 ,"GPRINT:nicepct:MAX:%3.2lf%%"
214 ,"GPRINT:nicepct:AVERAGE:%3.2lf%%"
215 ,"GPRINT:nicepct:MIN:%3.2lf%%"
216 ,"GPRINT:nicepct:LAST:%3.2lf%%\\j"
217 ,"STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu interrupt usage'})
218 ,"GPRINT:interruptpct:MAX:%3.2lf%%"
219 ,"GPRINT:interruptpct:AVERAGE:%3.2lf%%"
220 ,"GPRINT:interruptpct:MIN:%3.2lf%%"
221 ,"GPRINT:interruptpct:LAST:%3.2lf%%\\j"
222 ,"STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu steal usage'})
223 ,"GPRINT:stealpct:MAX:%3.2lf%%"
224 ,"GPRINT:stealpct:AVERAGE:%3.2lf%%"
225 ,"GPRINT:stealpct:MIN:%3.2lf%%"
226 ,"GPRINT:stealpct:LAST:%3.2lf%%\\j"
227 ,"STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu user usage'})
228 ,"GPRINT:userpct:MAX:%3.1lf%%"
229 ,"GPRINT:userpct:AVERAGE:%3.2lf%%"
230 ,"GPRINT:userpct:MIN:%3.2lf%%"
231 ,"GPRINT:userpct:LAST:%3.2lf%%\\j"
232 ,"STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu system usage'})
233 ,"GPRINT:systempct:MAX:%3.2lf%%"
234 ,"GPRINT:systempct:AVERAGE:%3.2lf%%"
235 ,"GPRINT:systempct:MIN:%3.2lf%%"
236 ,"GPRINT:systempct:LAST:%3.2lf%%\\j"
237 ,"STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu idle usage'})
238 ,"GPRINT:idlepct:MAX:%3.2lf%%"
239 ,"GPRINT:idlepct:AVERAGE:%3.2lf%%"
240 ,"GPRINT:idlepct:MIN:%3.2lf%%"
241 ,"GPRINT:idlepct:LAST:%3.2lf%%\\j");
243 RRDs
::graph
(@command);
244 $ERROR = RRDs
::error
;
245 print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR;
248 # Generate the Load Graph for the current period of time for values given by collecd
250 sub updateloadgraph
{
259 "-t ".$Lang::tr
{'uptime load average'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
260 "-v ".$Lang::tr
{'processes'},
261 "--color=SHADEA".$color{"color19"},
262 "--color=SHADEB".$color{"color19"},
263 "--color=BACK".$color{"color21"},
264 "DEF:load1=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:shortterm:AVERAGE",
265 "DEF:load5=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:midterm:AVERAGE",
266 "DEF:load15=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:longterm:AVERAGE",
267 "AREA:load1".$color{"color13"}."A0:1 ".$Lang::tr
{'minute'},
268 "GPRINT:load1:LAST:%5.2lf",
269 "AREA:load5".$color{"color18"}."A0:5 ".$Lang::tr
{'minutes'},
270 "GPRINT:load5:LAST:%5.2lf",
271 "AREA:load15".$color{"color14"}."A0:15 ".$Lang::tr
{'minutes'},
272 "GPRINT:load15:LAST:%5.2lf\\j",
273 "LINE1:load5".$color{"color13"},
274 "LINE1:load1".$color{"color18"},
276 $ERROR = RRDs
::error
;
277 print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR;
280 # Generate the Memory Graph for the current period of time for values given by collecd
282 sub updatememorygraph
{
292 "-t ".$Lang::tr
{'memory usage per'}." ".$Lang::tr
{$period."-graph"},
293 "-v ".$Lang::tr
{'percentage'},
294 "--color=SHADEA".$color{"color19"},
295 "--color=SHADEB".$color{"color19"},
296 "--color=BACK".$color{"color21"},
297 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",
298 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",
299 "DEF:buffer=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",
300 "DEF:cache=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",
301 "CDEF:total=used,free,cache,buffer,+,+,+",
302 "CDEF:usedpct=used,total,/,100,*",
303 "CDEF:bufferpct=buffer,total,/,100,*",
304 "CDEF:cachepct=cache,total,/,100,*",
305 "CDEF:freepct=free,total,/,100,*",
306 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
307 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
308 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
309 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
310 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
311 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used memory'}),
312 "GPRINT:usedpct:MAX:%3.2lf%%",
313 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
314 "GPRINT:usedpct:MIN:%3.2lf%%",
315 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
316 "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'buffered memory'}),
317 "GPRINT:bufferpct:MAX:%3.2lf%%",
318 "GPRINT:bufferpct:AVERAGE:%3.2lf%%",
319 "GPRINT:bufferpct:MIN:%3.2lf%%",
320 "GPRINT:bufferpct:LAST:%3.2lf%%\\j",
321 "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr
{'cached memory'}),
322 "GPRINT:cachepct:MAX:%3.2lf%%",
323 "GPRINT:cachepct:AVERAGE:%3.2lf%%",
324 "GPRINT:cachepct:MIN:%3.2lf%%",
325 "GPRINT:cachepct:LAST:%3.2lf%%\\j",
326 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free memory'}),
327 "GPRINT:freepct:MAX:%3.2lf%%",
328 "GPRINT:freepct:AVERAGE:%3.2lf%%",
329 "GPRINT:freepct:MIN:%3.2lf%%",
330 "GPRINT:freepct:LAST:%3.2lf%%\\j",
332 $ERROR = RRDs
::error
;
333 print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
336 # Generate the Swap Graph for the current period of time for values given by collecd
338 sub updateswapgraph
{
348 "-t ".$Lang::tr
{'swap usage per'}." ".$Lang::tr
{$period."-graph"},
349 "-v ".$Lang::tr
{'percentage'},
350 "--color=SHADEA".$color{"color19"},
351 "--color=SHADEB".$color{"color19"},
352 "--color=BACK".$color{"color21"},
353 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",
354 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",
355 "DEF:cached=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",
356 "CDEF:total=used,free,cached,+,+",
357 "CDEF:usedpct=100,used,total,/,*",
358 "CDEF:freepct=100,free,total,/,*",
359 "CDEF:cachedpct=100,cached,total,/,*",
360 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
361 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
362 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
363 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
364 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
365 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used swap'}),
366 "GPRINT:usedpct:MAX:%3.2lf%%",
367 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
368 "GPRINT:usedpct:MIN:%3.2lf%%",
369 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
370 "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cached swap'}),
371 "GPRINT:cachedpct:MAX:%3.2lf%%",
372 "GPRINT:cachedpct:AVERAGE:%3.2lf%%",
373 "GPRINT:cachedpct:MIN:%3.2lf%%",
374 "GPRINT:cachedpct:LAST:%3.2lf%%\\j",
375 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free swap'}),
376 "GPRINT:freepct:MAX:%3.2lf%%",
377 "GPRINT:freepct:AVERAGE:%3.2lf%%",
378 "GPRINT:freepct:MIN:%3.2lf%%",
379 "GPRINT:freepct:LAST:%3.2lf%%\\j",
381 $ERROR = RRDs
::error
;
382 print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
385 # Generate the Process Cpu Graph for the current period of time for values given by collecd
387 sub updateprocessescpugraph
{
388 my @processesgraph = getprocesses
();
399 "-t ".$Lang::tr
{'processes'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
400 "--color=SHADEA".$color{"color19"},
401 "--color=SHADEB".$color{"color19"},
402 "--color=BACK".$color{"color21"}
405 foreach(@processesgraph){
406 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
407 push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");
408 push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");
409 push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");
412 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
415 foreach(@processesgraph){
416 my $colorIndex = 10 + $count % 15;
417 my $color="$color{\"color$colorIndex\"}";
418 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
420 push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
422 push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
427 RRDs
::graph
(@command);
428 $ERROR = RRDs
::error
;
429 print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR;
432 # Generate the Process Memory Graph for the current period of time for values given by collecd
434 sub updateprocessesmemorygraph
{
435 my @processesgraph = getprocesses
();
446 "-t ".$Lang::tr
{'processes'}." ".$Lang::tr
{'memory'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
447 "-v ".$Lang::tr
{'bytes'},
448 "--color=SHADEA".$color{"color19"},
449 "--color=SHADEB".$color{"color19"},
450 "--color=BACK".$color{"color21"}
453 foreach(@processesgraph){
454 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
455 push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");
458 push(@command,"COMMENT:".$Lang::tr
{'caption'}."\\j");
461 foreach(@processesgraph){
462 chomp($_);my @name=split(/\-/,$_);chop($name[1]);
463 my $colorIndex = 10 + $count % 15;
464 my $color="$color{\"color$colorIndex\"}";
466 push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
468 push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
473 RRDs
::graph
(@command);
474 $ERROR = RRDs
::error
;
475 print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR;
478 # Generate the Disk Graph for the current period of time for values given by collecd
480 sub updatediskgraph
{
489 "-t ".$disk." ".$Lang::tr
{'disk access per'}." ".$Lang::tr
{$period."-graph"},
490 "-v ".$Lang::tr
{'bytes per second'},
491 "--color=SHADEA".$color{"color19"},
492 "--color=SHADEB".$color{"color19"},
493 "--color=BACK".$color{"color21"},
494 "DEF:read=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",
495 "DEF:write=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",
496 "CDEF:writen=write,-1,*",
497 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-".$disk.".rrd:standby:AVERAGE",
498 "CDEF:st=standby,INF,*",
499 "CDEF:st1=standby,NEGINF,*",
500 "COMMENT:".sprintf("%-25s",$Lang::tr
{'caption'}),
501 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
502 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
503 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
504 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
505 "AREA:st".$color{"color20"}."A0:",
506 "AREA:st1".$color{"color20"}."A0:standby\\j",
507 "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'read bytes'}),
508 "GPRINT:read:MAX:%8.1lf %sBps",
509 "GPRINT:read:AVERAGE:%8.1lf %sBps",
510 "GPRINT:read:MIN:%8.1lf %sBps",
511 "GPRINT:read:LAST:%8.1lf %sBps\\j",
512 "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'written bytes'}),
513 "GPRINT:write:MAX:%8.1lf %sBps",
514 "GPRINT:write:AVERAGE:%8.1lf %sBps",
515 "GPRINT:write:MIN:%8.1lf %sBps",
516 "GPRINT:write:LAST:%8.1lf %sBps\\j",
518 $ERROR = RRDs
::error
;
519 print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR;
522 # Generate the Interface Graph for the current period of time for values given by collecd
525 my $interface = $_[0];
533 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
534 "-v ".$Lang::tr
{'bytes per second'},
535 "--color=SHADEA".$color{"color19"},
536 "--color=SHADEB".$color{"color19"},
537 "--color=BACK".$color{"color21"},
538 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:rx:AVERAGE",
539 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:tx:AVERAGE",
540 "CDEF:outgoingn=outgoing,-1,*",
541 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
542 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
543 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
544 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
545 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
546 "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
547 "GPRINT:incoming:MAX:%8.1lf %sBps",
548 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
549 "GPRINT:incoming:MIN:%8.1lf %sBps",
550 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
551 "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
552 "GPRINT:outgoing:MAX:%8.1lf %sBps",
553 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
554 "GPRINT:outgoing:MIN:%8.1lf %sBps",
555 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
557 $ERROR = RRDs
::error
;
558 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
562 my $interface = $_[0];
570 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
571 "-v ".$Lang::tr
{'bytes per second'},
572 "--color=SHADEA".$color{"color19"},
573 "--color=SHADEB".$color{"color19"},
574 "--color=BACK".$color{"color21"},
575 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:rx:AVERAGE",
576 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:tx:AVERAGE",
577 "CDEF:outgoingn=outgoing,-1,*",
578 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
579 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
580 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
581 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
582 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
583 "AREA:incoming#00dd00:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
584 "GPRINT:incoming:MAX:%8.1lf %sBps",
585 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
586 "GPRINT:incoming:MIN:%8.1lf %sBps",
587 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
588 "AREA:outgoingn#dd0000:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
589 "GPRINT:outgoing:MAX:%8.1lf %sBps",
590 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
591 "GPRINT:outgoing:MIN:%8.1lf %sBps",
592 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
594 $ERROR = RRDs
::error
;
595 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
598 sub updatevpnn2ngraph
{
599 my $interface = $_[0];
607 "-t ".$Lang::tr
{'traffic on'}." ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
608 "-v ".$Lang::tr
{'bytes per second'},
609 "--color=SHADEA".$color{"color19"},
610 "--color=SHADEB".$color{"color19"},
611 "--color=BACK".$color{"color21"},
612 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:rx:AVERAGE",
613 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:tx:AVERAGE",
614 "DEF:overhead_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:rx:AVERAGE",
615 "DEF:overhead_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:tx:AVERAGE",
616 "DEF:compression_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_in.rrd:uncompressed:AVERAGE",
617 "DEF:compression_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_out.rrd:uncompressed:AVERAGE",
618 "CDEF:outgoingn=outgoing,-1,*",
619 "CDEF:overhead_outn=overhead_out,-1,*",
620 "CDEF:compression_outn=compression_out,-1,*",
621 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
622 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
623 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
624 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
625 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
626 "AREA:incoming#00dd00:".sprintf("%-23s",$Lang::tr
{'incoming traffic in bytes per second'}),
627 "GPRINT:incoming:MAX:%8.1lf %sBps",
628 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
629 "GPRINT:incoming:MIN:%8.1lf %sBps",
630 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
631 "STACK:overhead_in#116B11:".sprintf("%-23s",$Lang::tr
{'incoming overhead in bytes per second'}),
632 "GPRINT:overhead_in:MAX:%8.1lf %sBps",
633 "GPRINT:overhead_in:AVERAGE:%8.1lf %sBps",
634 "GPRINT:overhead_in:MIN:%8.1lf %sBps",
635 "GPRINT:overhead_in:LAST:%8.1lf %sBps\\j",
636 "LINE1:compression_in#ff00ff:".sprintf("%-23s",$Lang::tr
{'incoming compression in bytes per second'}),
637 "GPRINT:compression_in:MAX:%8.1lf %sBps",
638 "GPRINT:compression_in:AVERAGE:%8.1lf %sBps",
639 "GPRINT:compression_in:MIN:%8.1lf %sBps",
640 "GPRINT:compression_in:LAST:%8.1lf %sBps\\j",
641 "AREA:outgoingn#dd0000:".sprintf("%-23s",$Lang::tr
{'outgoing traffic in bytes per second'}),
642 "GPRINT:outgoing:MAX:%8.1lf %sBps",
643 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
644 "GPRINT:outgoing:MIN:%8.1lf %sBps",
645 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
646 "STACK:overhead_outn#870C0C:".sprintf("%-23s",$Lang::tr
{'outgoing overhead in bytes per second'}),
647 "GPRINT:overhead_out:MAX:%8.1lf %sBps",
648 "GPRINT:overhead_out:AVERAGE:%8.1lf %sBps",
649 "GPRINT:overhead_out:MIN:%8.1lf %sBps",
650 "GPRINT:overhead_out:LAST:%8.1lf %sBps\\j",
651 "LINE1:compression_outn#000000:".sprintf("%-23s",$Lang::tr
{'outgoing compression in bytes per second'}),
652 "GPRINT:compression_out:MAX:%8.1lf %sBps",
653 "GPRINT:compression_out:AVERAGE:%8.1lf %sBps",
654 "GPRINT:compression_out:MIN:%8.1lf %sBps",
655 "GPRINT:compression_out:LAST:%8.1lf %sBps\\j",
657 $ERROR = RRDs
::error
;
658 print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
661 # Generate the Firewall Graph for the current period of time for values given by collecd
663 sub updatefwhitsgraph
{
671 "-t ".$Lang::tr
{'firewall hits per'}." ".$Lang::tr
{$period."-graph"},
672 "-v ".$Lang::tr
{'bytes per second'},
673 "--color=SHADEA".$color{"color19"},
674 "--color=SHADEB".$color{"color19"},
675 "--color=BACK".$color{"color21"},
676 "DEF:output=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYOUT/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
677 "DEF:input=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYIN/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
678 "DEF:forward=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYFWD/ipt_bytes-DROP_FORWARD.rrd:value:AVERAGE",
679 "DEF:newnotsyn=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
680 "DEF:portscan=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
681 "COMMENT:".sprintf("%-26s",$Lang::tr
{'caption'}),
682 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
683 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
684 "COMMENT:".sprintf("%14s",$Lang::tr
{'minimal'}),
685 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
686 "AREA:output".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (OUTPUT)"),
687 "GPRINT:output:MAX:%8.1lf %sBps",
688 "GPRINT:output:AVERAGE:%8.1lf %sBps",
689 "GPRINT:output:MIN:%8.1lf %sBps",
690 "GPRINT:output:LAST:%8.1lf %sBps\\j",
691 "STACK:forward".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (FORWARD)"),
692 "GPRINT:forward:MAX:%8.1lf %sBps",
693 "GPRINT:forward:AVERAGE:%8.1lf %sBps",
694 "GPRINT:forward:MIN:%8.1lf %sBps",
695 "GPRINT:forward:LAST:%8.1lf %sBps\\j",
696 "STACK:input".$color{"color24"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (INPUT)"),
697 "GPRINT:input:MAX:%8.1lf %sBps",
698 "GPRINT:input:AVERAGE:%8.1lf %sBps",
699 "GPRINT:input:MIN:%8.1lf %sBps",
700 "GPRINT:input:LAST:%8.1lf %sBps\\j",
701 "STACK:newnotsyn".$color{"color14"}."A0:".sprintf("%-25s","NewNotSYN"),
702 "GPRINT:newnotsyn:MAX:%8.1lf %sBps",
703 "GPRINT:newnotsyn:MIN:%8.1lf %sBps",
704 "GPRINT:newnotsyn:AVERAGE:%8.1lf %sBps",
705 "GPRINT:newnotsyn:LAST:%8.1lf %sBps\\j",
706 "STACK:portscan".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'portscans'}),
707 "GPRINT:portscan:MAX:%8.1lf %sBps",
708 "GPRINT:portscan:MIN:%8.1lf %sBps",
709 "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
710 "GPRINT:portscan:LAST:%8.1lf %sBps\\j",
712 $ERROR = RRDs
::error
;
713 print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR;
716 # Generate the Line Quality Graph for the current period of time for values given by collecd
718 sub updatepinggraph
{
728 "-t ".$Lang::tr
{'linkq'}." ".$host." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
730 "--color=SHADEA".$color{"color19"},
731 "--color=SHADEB".$color{"color19"},
732 "--color=BACK".$color{"color21"},
733 "DEF:roundtrip=".$mainsettings{'RRDLOG'}."/collectd/localhost/ping/ping-".$host.".rrd:ping:AVERAGE",
734 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'})."\\j",
735 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
736 "CDEF:r0=roundtrip,30,MIN",
737 "CDEF:r1=roundtrip,70,MIN",
738 "CDEF:r2=roundtrip,150,MIN",
739 "CDEF:r3=roundtrip,300,MIN",
740 "AREA:roundtrip".$color{"color25"}."A0:>300 ms",
741 "AREA:r3".$color{"color18"}."A0:150-300 ms",
742 "AREA:r2".$color{"color14"}."A0:70-150 ms",
743 "AREA:r1".$color{"color17"}."A0:30-70 ms",
744 "AREA:r0".$color{"color12"}."A0:<30 ms\\j",
745 "COMMENT:$Lang::tr{'maximal'}",
746 "COMMENT:$Lang::tr{'average'}",
747 "COMMENT:$Lang::tr{'minimal'}","COMMENT:$Lang::tr{'current'}\\j",
748 "LINE1:roundtrip#707070:",
749 "GPRINT:roundtrip:MAX:%3.2lf ms",
750 "GPRINT:roundtrip:AVERAGE:%3.2lf ms",
751 "GPRINT:roundtrip:MIN:%3.2lf ms",
752 "GPRINT:roundtrip:LAST:%3.2lf ms\\j",
754 $ERROR = RRDs
::error
;
755 print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR;
758 sub updatewirelessgraph
{
760 my $interface = $_[0];
766 "-t Wireless ".$interface." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
768 "--color=SHADEA".$color{"color19"},
769 "--color=SHADEB".$color{"color19"},
770 "--color=BACK".$color{"color21"},
771 "DEF:noise=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_noise.rrd:value:AVERAGE",
772 "DEF:power=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_power.rrd:value:AVERAGE",
773 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
774 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
775 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
776 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
777 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
778 "LINE1:noise".$color{"color11"}."A0:".sprintf("%-20s","Signal Noise Ratio"),
779 "GPRINT:noise:MAX:%5.1lf %sdBm",
780 "GPRINT:noise:AVERAGE:%5.1lf %sdBm",
781 "GPRINT:noise:MIN:%5.1lf %sdBm",
782 "GPRINT:noise:LAST:%5.1lf %sdBm\\j",
783 "LINE1:power".$color{"color12"}."A0:".sprintf("%-20s","Signal Power Ratio"),
784 "GPRINT:power:MAX:%5.1lf %sdBm",
785 "GPRINT:power:AVERAGE:%5.1lf %sdBm",
786 "GPRINT:power:MIN:%5.1lf %sdBm",
787 "GPRINT:power:LAST:%5.1lf %sdBm\\j",
789 $ERROR = RRDs
::error
;
790 print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR;
793 # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors
804 "-t ".$disk." ".$Lang::tr
{'harddisk temperature'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
806 "--color=SHADEA".$color{"color19"},
807 "--color=SHADEB".$color{"color19"},
808 "--color=BACK".$color{"color21"},
809 "DEF:temperature=".$mainsettings{'RRDLOG'}."/hddtemp-$disk.rrd:temperature:AVERAGE",
810 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-$disk.rrd:standby:AVERAGE",
811 "CDEF:st=standby,INF,*",
812 "AREA:st".$color{"color20"}."A0:standby",
813 "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j",
814 "COMMENT:$Lang::tr{'maximal'}",
815 "COMMENT:$Lang::tr{'average'}",
816 "COMMENT:$Lang::tr{'minimal'}",
817 "COMMENT:$Lang::tr{'current'}\\j",
818 "GPRINT:temperature:MAX:%3.0lf Grad C",
819 "GPRINT:temperature:AVERAGE:%3.0lf Grad C",
820 "GPRINT:temperature:MIN:%3.0lf Grad C",
821 "GPRINT:temperature:LAST:%3.0lf Grad C\\j",
823 $ERROR = RRDs
::error
;
824 print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR;
827 # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors
829 sub updatehwtempgraph
{
838 "-t ".$Lang::tr
{'mbmon temp'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
839 "--color=SHADEA".$color{"color19"},
840 "--color=SHADEB".$color{"color19"},
841 "--color=BACK".$color{"color21"},
842 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
843 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
844 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
845 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
846 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
849 foreach(@sensorsgraphs){
851 if ( $_ =~ /temperature/ ) {
852 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
853 my $label = $2.$3;$label=~ s/-//g;
854 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
855 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
859 foreach(@sensorsgraphs){
861 if ( $_ =~ /temperature/ ){
862 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
863 my $label = $2.$3;$label=~ s/-//g;
864 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
865 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",);
869 RRDs
::graph
(@command);
870 $ERROR = RRDs
::error
;
871 print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR;
874 # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors
876 sub updatehwfangraph
{
885 "-t ".$Lang::tr
{'mbmon fan'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
886 "--color=SHADEA".$color{"color19"},
887 "--color=SHADEB".$color{"color19"},
888 "--color=BACK".$color{"color21"},
889 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
890 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
891 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
892 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
893 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
896 foreach(@sensorsgraphs){
898 if ( $_ =~ /fanspeed/ ) {
899 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
900 my $label = $2.$3;$label=~ s/-//g;
901 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
902 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
906 foreach(@sensorsgraphs){
908 if ( $_ =~ /fanspeed/ ){
909 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
910 my $label = $2.$3;$label=~ s/-//g;
911 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
912 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",);
916 RRDs
::graph
(@command);
917 $ERROR = RRDs
::error
;
918 print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR;
921 # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors
923 sub updatehwvoltgraph
{
932 "-t ".$Lang::tr
{'mbmon volt'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
933 "--color=SHADEA".$color{"color19"},
934 "--color=SHADEB".$color{"color19"},
935 "--color=BACK".$color{"color21"},
936 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
937 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
938 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
939 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
940 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
943 foreach(@sensorsgraphs){
945 if ( $_ =~ /voltage/ ) {
946 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
947 my $label = $2.$3;$label=~ s/-//g;
948 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
949 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
953 foreach(@sensorsgraphs){
955 if ( $_ =~ /voltage/ ){
956 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
957 my $label = $2.$3;$label=~ s/-//g;
958 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
959 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",);
963 RRDs
::graph
(@command);
964 $ERROR = RRDs
::error
;
965 print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR;
969 # Generate the QoS Graph for the current period of time
974 my %qossettings = ();
975 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
980 my $classfile = "/var/ipfire/qos/classes";
982 $qossettings{'DEV'} = $_[0];
983 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
984 $qossettings{'CLASSPRFX'} = '1';
986 $qossettings{'CLASSPRFX'} = '2';
999 "-t ".$Lang::tr
{'Utilization on'}." (".$qossettings{'DEV'}.") ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
1000 "-v ".$Lang::tr
{'bytes per second'},
1001 "--color=SHADEA".$color{"color19"},
1002 "--color=SHADEB".$color{"color19"},
1003 "--color=BACK".$color{"color21"},
1004 "COMMENT:".sprintf("%-28s",$Lang::tr
{'caption'}),
1005 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1006 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1007 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1008 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1011 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1016 foreach $classentry (sort @classes){
1017 @classline = split( /\;/, $classentry );
1018 if ( $classline[0] eq $qossettings{'DEV'} ){
1019 my $colorIndex = 10 + $count % 15;
1020 $color="$color{\"color$colorIndex\"}";
1021 push(@command, "DEF:$classline[1]=$mainsettings{'RRDLOG'}/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
1023 if ($count eq "1") {
1024 push(@command, "AREA:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1026 push(@command, "STACK:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1029 push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"
1030 , "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps"
1031 , "GPRINT:$classline[1]:MIN:%8.1lf %sBps"
1032 , "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");
1036 RRDs
::graph
(@command);
1037 $ERROR = RRDs
::error
;
1038 print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR;
1041 # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors
1043 sub updatecpufreqgraph
{
1044 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
1052 "-t ".$Lang::tr
{'cpu frequency per'}." ".$Lang::tr
{$period."-graph"},
1054 "--color=SHADEA".$color{"color19"},
1055 "--color=SHADEB".$color{"color19"},
1056 "--color=BACK".$color{"color21"},
1057 "COMMENT:".sprintf("%-10s",$Lang::tr
{'caption'}),
1058 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1059 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1060 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1061 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1064 for(my $i = 0; $i < $cpucount; $i++) {
1066 push(@command,"DEF:cpu".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpufreq/cpufreq-".$i.".rrd:value:AVERAGE"
1067 ,"CDEF:cpu".$i."=cpu".$i."_,1000000,/"
1068 ,"LINE1:cpu".$i.$color{"color1$j"}."A0:cpu ".$i." "
1069 ,"GPRINT:cpu".$i.":MAX:%3.0lf Mhz"
1070 ,"GPRINT:cpu".$i.":AVERAGE:%3.0lf Mhz"
1071 ,"GPRINT:cpu".$i.":MIN:%3.0lf Mhz"
1072 ,"GPRINT:cpu".$i.":LAST:%3.0lf Mhz\\j");
1075 RRDs
::graph
(@command);
1076 $ERROR = RRDs
::error
;
1077 print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
1080 # Generate the Thermal Zone Temp CPU Graph
1082 sub updatethermaltempgraph
{
1083 my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null | wc -l`;
1091 "-t ".$Lang::tr
{'acpitemp'}." ".$Lang::tr
{'graph per'}." ".$Lang::tr
{$period."-graph"},
1093 "--color=SHADEA".$color{"color19"},
1094 "--color=SHADEB".$color{"color19"},
1095 "--color=BACK".$color{"color21"},
1096 "COMMENT:".sprintf("%-10s",$Lang::tr
{'caption'}),
1097 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1098 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1099 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1100 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1103 for(my $i = 0; $i < $thermalcount; $i++) {
1105 push(@command,"DEF:temp".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/thermal-thermal_zone".$i."/temperature-temperature.rrd:value:AVERAGE"
1106 ,"CDEF:temp".$i."=temp".$i."_,1,/"
1107 ,"LINE3:temp".$i.$color{"color1$j"}."A0:Temp ".$i." "
1108 ,"GPRINT:temp".$i.":MAX:%3.0lf Grad C"
1109 ,"GPRINT:temp".$i.":AVERAGE:%3.0lf Grad C"
1110 ,"GPRINT:temp".$i.":MIN:%3.0lf Grad C"
1111 ,"GPRINT:temp".$i.":LAST:%3.0lf Grad C\\j");
1114 RRDs
::graph
(@command);
1115 $ERROR = RRDs
::error
;
1116 print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
1120 # Generate a random color, used by Qos Graph to be independent from the amount of values
1122 sub random_hex_color
{
1124 $size = 6 if $size !~ /^3|6$/;
1125 my @hex = ( 0 .. 9, 'a' .. 'f' );
1127 push @color, @hex[rand(@hex)] for 1 .. $size;
1128 return join('', '#', @color);
1132 my @processesgraph = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/processes-*/ 2>/dev/null`;
1133 return @processesgraph;
1136 sub updateentropygraph
{
1144 "--lower-limit","0",
1145 "-t $Lang::tr{'entropy'}",
1146 "-v $Lang::tr{'bit'}",
1147 "DEF:entropy=$mainsettings{'RRDLOG'}/collectd/localhost/entropy/entropy.rrd:entropy:AVERAGE",
1148 "LINE3:entropy#ff0000:" . sprintf("%-15s", $Lang::tr
{'entropy'}),
1149 "VDEF:entrmin=entropy,MINIMUM",
1150 "VDEF:entrmax=entropy,MAXIMUM",
1151 "VDEF:entravg=entropy,AVERAGE",
1152 "GPRINT:entrmax:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'maximum'}),
1153 "GPRINT:entrmin:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'minimum'}),
1154 "GPRINT:entravg:" . sprintf("%12s\\: %%5.0lf", $Lang::tr
{'average'}) . "\\n",
1155 "--color=BACK".$color{"color21"},
1158 RRDs
::graph
(@command);
1159 $ERROR = RRDs
::error
;
1161 print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR;
1164 sub updateconntrackgraph
{
1172 "--lower-limit","0",
1173 "-t $Lang::tr{'connection tracking'}",
1174 "-v $Lang::tr{'open connections'}",
1175 "DEF:conntrack=$mainsettings{'RRDLOG'}/collectd/localhost/conntrack/conntrack.rrd:entropy:AVERAGE",
1176 "LINE3:conntrack#ff0000:" . sprintf("%-15s", $Lang::tr
{'open connections'}),
1177 "VDEF:ctmin=conntrack,MINIMUM",
1178 "VDEF:ctmax=conntrack,MAXIMUM",
1179 "VDEF:ctavg=conntrack,AVERAGE",
1180 "GPRINT:ctmax:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'maximum'}),
1181 "GPRINT:ctmin:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'minimum'}),
1182 "GPRINT:ctavg:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'average'}) . "\\n",
1183 "--color=BACK" . $color{"color21"},
1186 RRDs
::graph
(@command);
1187 $ERROR = RRDs
::error
;
1189 print STDERR
"Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR;