]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/cfgroot/graphs.pl
a64958c75a0cdb161211b27f989b5986a46be7bd
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-2021 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. #update.sh
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 ###############################################################################
27 use experimental
'smartmatch';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
33 # Approximate size of the final graph image including canvas and labeling (in pixels, mainly used for placeholders)
34 our %image_size = ('width' => 900, 'height' => 400);
36 # Size of the actual data area within the image, without labeling (in pixels)
37 our %canvas_size = ('width' => 800, 'height' => 290);
39 # List of all available time ranges
40 our @time_ranges = ("hour", "day", "week", "month", "year");
51 # For a more 'organic' look
58 "-w $canvas_size{'width'}",
59 "-h $canvas_size{'height'}",
61 # Use alternative grid
67 my %mainsettings = ();
68 my %sensorsettings = ();
69 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
70 &General
::readhash
("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \
%color);
72 if ( $mainsettings{'RRDLOG'} eq "" ){
73 $mainsettings{'RRDLOG'}="/var/log/rrd";
74 &General
::writehash
("${General::swroot}/main/settings", \
%mainsettings);
77 # If the collection deamon is working and collecting lm_sensors data there will be
78 # some data source named after a common scheme, with the sensorssettingsfile
79 # the user is able to deactivate some of this parameters, in case not to show
80 # false collected values may be disable. The user has the ability to enter
81 # custom graph names in order to change temp0 to cpu or motherboard
84 my @sensorsgraphs = ();
85 my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/ 2>/dev/null`;
86 foreach (@sensorsdir){
90 push(@sensorsgraphs,$_);
91 $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
92 my $label = $2.$3;$label=~ s/-//g;
93 $sensorsettings{'LABEL-'.$label}="$label";
94 $sensorsettings{'LINE-'.$label}="checked";
98 &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings);
100 # Generate a nice box for selection of time range in graphs
101 # this will generate a nice div box for the cgi every klick for
102 # the graph will be handled by javascript
103 # 0 is the cgi refering to
104 # 1 is the graph name
105 # 2 is the time range for the graph (optional)
108 my ($origin, $name, $default_range) = @_;
110 # Optional time range: Default to "day" unless otherwise specified
111 $default_range = "day" unless ($default_range ~~ @time_ranges);
114 <div class="graph" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range">
115 <img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)">
120 # Print range select buttons
121 foreach my $range (@time_ranges) {
122 my $selected = ($range eq $default_range) ? "class=\"selected\"" : "";
126 <button data-range="$range" onclick="rrdimage_selectRange(this)" $selected>
139 # Generate the CPU Graph for the current period of time for values given by
140 # collectd we are now able to handle any kind of cpucount
143 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
153 "-v ".$Lang::tr
{'percentage'},
154 "--color=SHADEA".$color{"color19"},
155 "--color=SHADEB".$color{"color19"},
156 "--color=BACK".$color{"color21"},
157 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
158 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
159 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
160 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
161 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
164 my $nice = "CDEF:nice=";
165 my $interrupt = "CDEF:interrupt=";
166 my $steal = "CDEF:steal=";
167 my $user = "CDEF:user=";
168 my $system = "CDEF:system=";
169 my $idle = "CDEF:idle=";
170 my $iowait = "CDEF:iowait=";
171 my $irq = "CDEF:irq=";
174 for(my $i = 0; $i < $cpucount; $i++) {
175 push(@command,"DEF:iowait".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-wait.rrd:value:AVERAGE"
176 ,"DEF:nice".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-nice.rrd:value:AVERAGE"
177 ,"DEF:interrupt".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-interrupt.rrd:value:AVERAGE"
178 ,"DEF:steal".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-steal.rrd:value:AVERAGE"
179 ,"DEF:user".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-user.rrd:value:AVERAGE"
180 ,"DEF:system".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-system.rrd:value:AVERAGE"
181 ,"DEF:idle".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-idle.rrd:value:AVERAGE"
182 ,"DEF:irq".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-softirq.rrd:value:AVERAGE");
184 $nice .= "nice".$i.",";
185 $interrupt .= "interrupt".$i.",";
186 $steal .= "steal".$i.",";
187 $user .= "user".$i.",";
188 $system .= "system".$i.",";
189 $idle .= "idle".$i.",";
190 $iowait .= "iowait".$i.",";
191 $irq .= "irq".$i.",";
194 for(my $i = 2; $i < $cpucount; $i++) {
195 $addstring .= "ADDNAN,";
200 push(@command,$nice.$addstring
201 ,$interrupt.$addstring
209 chop($nice),chop($interrupt),chop($steal),chop($user),chop($system),chop($idle),chop($iowait),chop($irq);
210 push(@command,$nice,$interrupt,$steal,$user,$system,$idle,$iowait,$irq);
213 push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN"
214 ,"CDEF:userpct=100,user,total,/,*"
215 ,"CDEF:nicepct=100,nice,total,/,*"
216 ,"CDEF:interruptpct=100,interrupt,total,/,*"
217 ,"CDEF:stealpct=100,steal,total,/,*"
218 ,"CDEF:systempct=100,system,total,/,*"
219 ,"CDEF:idlepct=100,idle,total,/,*"
220 ,"CDEF:iowaitpct=100,iowait,total,/,*"
221 ,"CDEF:irqpct=100,irq,total,/,*"
222 ,"AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr
{'cpu iowait usage'})
223 ,"GPRINT:iowaitpct:MAX:%3.2lf%%"
224 ,"GPRINT:iowaitpct:AVERAGE:%3.2lf%%"
225 ,"GPRINT:iowaitpct:MIN:%3.2lf%%"
226 ,"GPRINT:iowaitpct:LAST:%3.2lf%%\\j"
227 ,"STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu irq usage'})
228 ,"GPRINT:irqpct:MAX:%3.2lf%%"
229 ,"GPRINT:irqpct:AVERAGE:%3.2lf%%"
230 ,"GPRINT:irqpct:MIN:%3.2lf%%"
231 ,"GPRINT:irqpct:LAST:%3.2lf%%\\j"
232 ,"STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu nice usage'})
233 ,"GPRINT:nicepct:MAX:%3.2lf%%"
234 ,"GPRINT:nicepct:AVERAGE:%3.2lf%%"
235 ,"GPRINT:nicepct:MIN:%3.2lf%%"
236 ,"GPRINT:nicepct:LAST:%3.2lf%%\\j"
237 ,"STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu interrupt usage'})
238 ,"GPRINT:interruptpct:MAX:%3.2lf%%"
239 ,"GPRINT:interruptpct:AVERAGE:%3.2lf%%"
240 ,"GPRINT:interruptpct:MIN:%3.2lf%%"
241 ,"GPRINT:interruptpct:LAST:%3.2lf%%\\j"
242 ,"STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu steal usage'})
243 ,"GPRINT:stealpct:MAX:%3.2lf%%"
244 ,"GPRINT:stealpct:AVERAGE:%3.2lf%%"
245 ,"GPRINT:stealpct:MIN:%3.2lf%%"
246 ,"GPRINT:stealpct:LAST:%3.2lf%%\\j"
247 ,"STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu user usage'})
248 ,"GPRINT:userpct:MAX:%3.1lf%%"
249 ,"GPRINT:userpct:AVERAGE:%3.2lf%%"
250 ,"GPRINT:userpct:MIN:%3.2lf%%"
251 ,"GPRINT:userpct:LAST:%3.2lf%%\\j"
252 ,"STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu system usage'})
253 ,"GPRINT:systempct:MAX:%3.2lf%%"
254 ,"GPRINT:systempct:AVERAGE:%3.2lf%%"
255 ,"GPRINT:systempct:MIN:%3.2lf%%"
256 ,"GPRINT:systempct:LAST:%3.2lf%%\\j"
257 ,"STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'cpu idle usage'})
258 ,"GPRINT:idlepct:MAX:%3.2lf%%"
259 ,"GPRINT:idlepct:AVERAGE:%3.2lf%%"
260 ,"GPRINT:idlepct:MIN:%3.2lf%%"
261 ,"GPRINT:idlepct:LAST:%3.2lf%%\\j");
263 RRDs
::graph
(@command);
264 $ERROR = RRDs
::error
;
265 return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR;
268 # Generate the Load Graph for the current period of time for values given by collecd
270 sub updateloadgraph
{
279 "-v ".$Lang::tr
{'processes'},
280 "--color=SHADEA".$color{"color19"},
281 "--color=SHADEB".$color{"color19"},
282 "--color=BACK".$color{"color21"},
283 "DEF:load1=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:shortterm:AVERAGE",
284 "DEF:load5=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:midterm:AVERAGE",
285 "DEF:load15=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:longterm:AVERAGE",
286 "AREA:load1".$color{"color13"}."A0:1 ".$Lang::tr
{'minute'},
287 "GPRINT:load1:LAST:%5.2lf",
288 "AREA:load5".$color{"color18"}."A0:5 ".$Lang::tr
{'minutes'},
289 "GPRINT:load5:LAST:%5.2lf",
290 "AREA:load15".$color{"color14"}."A0:15 ".$Lang::tr
{'minutes'},
291 "GPRINT:load15:LAST:%5.2lf\\j",
292 "LINE1:load5".$color{"color13"},
293 "LINE1:load1".$color{"color18"},
295 $ERROR = RRDs
::error
;
296 return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR;
299 # Generate the Memory Graph for the current period of time for values given by collecd
301 sub updatememorygraph
{
311 "-v ".$Lang::tr
{'percentage'},
312 "--color=SHADEA".$color{"color19"},
313 "--color=SHADEB".$color{"color19"},
314 "--color=BACK".$color{"color21"},
315 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",
316 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",
317 "DEF:buffer=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",
318 "DEF:cache=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",
319 "CDEF:total=used,free,cache,buffer,+,+,+",
320 "CDEF:usedpct=used,total,/,100,*",
321 "CDEF:bufferpct=buffer,total,/,100,*",
322 "CDEF:cachepct=cache,total,/,100,*",
323 "CDEF:freepct=free,total,/,100,*",
324 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
325 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
326 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
327 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
328 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
329 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used memory'}),
330 "GPRINT:usedpct:MAX:%3.2lf%%",
331 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
332 "GPRINT:usedpct:MIN:%3.2lf%%",
333 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
334 "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'buffered memory'}),
335 "GPRINT:bufferpct:MAX:%3.2lf%%",
336 "GPRINT:bufferpct:AVERAGE:%3.2lf%%",
337 "GPRINT:bufferpct:MIN:%3.2lf%%",
338 "GPRINT:bufferpct:LAST:%3.2lf%%\\j",
339 "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr
{'cached memory'}),
340 "GPRINT:cachepct:MAX:%3.2lf%%",
341 "GPRINT:cachepct:AVERAGE:%3.2lf%%",
342 "GPRINT:cachepct:MIN:%3.2lf%%",
343 "GPRINT:cachepct:LAST:%3.2lf%%\\j",
344 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free memory'}),
345 "GPRINT:freepct:MAX:%3.2lf%%",
346 "GPRINT:freepct:AVERAGE:%3.2lf%%",
347 "GPRINT:freepct:MIN:%3.2lf%%",
348 "GPRINT:freepct:LAST:%3.2lf%%\\j",
350 $ERROR = RRDs
::error
;
351 return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
354 # Generate the Swap Graph for the current period of time for values given by collecd
356 sub updateswapgraph
{
366 "-v ".$Lang::tr
{'percentage'},
367 "--color=SHADEA".$color{"color19"},
368 "--color=SHADEB".$color{"color19"},
369 "--color=BACK".$color{"color21"},
370 "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",
371 "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",
372 "DEF:cached=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",
373 "CDEF:total=used,free,cached,+,+",
374 "CDEF:usedpct=100,used,total,/,*",
375 "CDEF:freepct=100,free,total,/,*",
376 "CDEF:cachedpct=100,cached,total,/,*",
377 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
378 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
379 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
380 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
381 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
382 "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr
{'used swap'}),
383 "GPRINT:usedpct:MAX:%3.2lf%%",
384 "GPRINT:usedpct:AVERAGE:%3.2lf%%",
385 "GPRINT:usedpct:MIN:%3.2lf%%",
386 "GPRINT:usedpct:LAST:%3.2lf%%\\j",
387 "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'cached swap'}),
388 "GPRINT:cachedpct:MAX:%3.2lf%%",
389 "GPRINT:cachedpct:AVERAGE:%3.2lf%%",
390 "GPRINT:cachedpct:MIN:%3.2lf%%",
391 "GPRINT:cachedpct:LAST:%3.2lf%%\\j",
392 "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'free swap'}),
393 "GPRINT:freepct:MAX:%3.2lf%%",
394 "GPRINT:freepct:AVERAGE:%3.2lf%%",
395 "GPRINT:freepct:MIN:%3.2lf%%",
396 "GPRINT:freepct:LAST:%3.2lf%%\\j",
398 $ERROR = RRDs
::error
;
399 return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
402 # Generate the Disk Graph for the current period of time for values given by collecd
404 sub updatediskgraph
{
413 "-v ".$Lang::tr
{'bytes per second'},
414 "--color=SHADEA".$color{"color19"},
415 "--color=SHADEB".$color{"color19"},
416 "--color=BACK".$color{"color21"},
417 "DEF:read=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",
418 "DEF:write=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",
419 "CDEF:writen=write,-1,*",
420 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-".$disk.".rrd:standby:AVERAGE",
421 "CDEF:st=standby,INF,*",
422 "CDEF:st1=standby,NEGINF,*",
423 "COMMENT:".sprintf("%-25s",$Lang::tr
{'caption'}),
424 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
425 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
426 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
427 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
428 "AREA:st".$color{"color20"}."A0:",
429 "AREA:st1".$color{"color20"}."A0:standby\\j",
430 "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'read bytes'}),
431 "GPRINT:read:MAX:%8.1lf %sBps",
432 "GPRINT:read:AVERAGE:%8.1lf %sBps",
433 "GPRINT:read:MIN:%8.1lf %sBps",
434 "GPRINT:read:LAST:%8.1lf %sBps\\j",
435 "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'written bytes'}),
436 "GPRINT:write:MAX:%8.1lf %sBps",
437 "GPRINT:write:AVERAGE:%8.1lf %sBps",
438 "GPRINT:write:MIN:%8.1lf %sBps",
439 "GPRINT:write:LAST:%8.1lf %sBps\\j",
441 $ERROR = RRDs
::error
;
442 return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR;
445 # Generate the Interface Graph for the current period of time for values given by collecd
448 my $interface = $_[0];
456 "-v ".$Lang::tr
{'bytes per second'},
457 "--color=SHADEA".$color{"color19"},
458 "--color=SHADEB".$color{"color19"},
459 "--color=BACK".$color{"color21"},
460 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface-".$interface."/if_octets.rrd:rx:AVERAGE",
461 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface-".$interface."/if_octets.rrd:tx:AVERAGE",
462 "CDEF:outgoingn=outgoing,-1,*",
463 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
464 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
465 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
466 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
467 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
468 "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
469 "GPRINT:incoming:MAX:%8.1lf %sBps",
470 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
471 "GPRINT:incoming:MIN:%8.1lf %sBps",
472 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
473 "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
474 "GPRINT:outgoing:MAX:%8.1lf %sBps",
475 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
476 "GPRINT:outgoing:MIN:%8.1lf %sBps",
477 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
479 $ERROR = RRDs
::error
;
480 return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
484 my $interface = $_[0];
492 "-v ".$Lang::tr
{'bytes per second'},
493 "--color=SHADEA".$color{"color19"},
494 "--color=SHADEB".$color{"color19"},
495 "--color=BACK".$color{"color21"},
496 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets.rrd:rx:AVERAGE",
497 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets.rrd:tx:AVERAGE",
498 "CDEF:outgoingn=outgoing,-1,*",
499 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
500 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
501 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
502 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
503 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
504 "AREA:incoming#00dd00:".sprintf("%-20s",$Lang::tr
{'incoming traffic in bytes per second'}),
505 "GPRINT:incoming:MAX:%8.1lf %sBps",
506 "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
507 "GPRINT:incoming:MIN:%8.1lf %sBps",
508 "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
509 "AREA:outgoingn#dd0000:".sprintf("%-20s",$Lang::tr
{'outgoing traffic in bytes per second'}),
510 "GPRINT:outgoing:MAX:%8.1lf %sBps",
511 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
512 "GPRINT:outgoing:MIN:%8.1lf %sBps",
513 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
515 $ERROR = RRDs
::error
;
516 return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
519 sub updatevpnn2ngraph
{
520 my $interface = $_[0];
528 "-v ".$Lang::tr
{'bytes per second'},
529 "--color=SHADEA".$color{"color19"},
530 "--color=SHADEB".$color{"color19"},
531 "--color=BACK".$color{"color21"},
532 "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets-traffic.rrd:rx:AVERAGE",
533 "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets-traffic.rrd:tx:AVERAGE",
534 "DEF:overhead_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets-overhead.rrd:rx:AVERAGE",
535 "DEF:overhead_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets-overhead.rrd:tx:AVERAGE",
536 "DEF:compression_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression-data_in.rrd:uncompressed:AVERAGE",
537 "DEF:compression_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression-data_out.rrd:uncompressed:AVERAGE",
538 "CDEF:outgoingn=outgoing,-1,*",
539 "CDEF:overhead_outn=overhead_out,-1,*",
540 "CDEF:compression_outn=compression_out,-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#00dd00:".sprintf("%-23s",$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 "STACK:overhead_in#116B11:".sprintf("%-23s",$Lang::tr
{'incoming overhead in bytes per second'}),
552 "GPRINT:overhead_in:MAX:%8.1lf %sBps",
553 "GPRINT:overhead_in:AVERAGE:%8.1lf %sBps",
554 "GPRINT:overhead_in:MIN:%8.1lf %sBps",
555 "GPRINT:overhead_in:LAST:%8.1lf %sBps\\j",
556 "LINE1:compression_in#ff00ff:".sprintf("%-23s",$Lang::tr
{'incoming compression in bytes per second'}),
557 "GPRINT:compression_in:MAX:%8.1lf %sBps",
558 "GPRINT:compression_in:AVERAGE:%8.1lf %sBps",
559 "GPRINT:compression_in:MIN:%8.1lf %sBps",
560 "GPRINT:compression_in:LAST:%8.1lf %sBps\\j",
561 "AREA:outgoingn#dd0000:".sprintf("%-23s",$Lang::tr
{'outgoing traffic in bytes per second'}),
562 "GPRINT:outgoing:MAX:%8.1lf %sBps",
563 "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
564 "GPRINT:outgoing:MIN:%8.1lf %sBps",
565 "GPRINT:outgoing:LAST:%8.1lf %sBps\\j",
566 "STACK:overhead_outn#870C0C:".sprintf("%-23s",$Lang::tr
{'outgoing overhead in bytes per second'}),
567 "GPRINT:overhead_out:MAX:%8.1lf %sBps",
568 "GPRINT:overhead_out:AVERAGE:%8.1lf %sBps",
569 "GPRINT:overhead_out:MIN:%8.1lf %sBps",
570 "GPRINT:overhead_out:LAST:%8.1lf %sBps\\j",
571 "LINE1:compression_outn#000000:".sprintf("%-23s",$Lang::tr
{'outgoing compression in bytes per second'}),
572 "GPRINT:compression_out:MAX:%8.1lf %sBps",
573 "GPRINT:compression_out:AVERAGE:%8.1lf %sBps",
574 "GPRINT:compression_out:MIN:%8.1lf %sBps",
575 "GPRINT:compression_out:LAST:%8.1lf %sBps\\j",
577 $ERROR = RRDs
::error
;
578 return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
581 # Generate the Firewall Graph for the current period of time for values given by collecd
583 sub updatefwhitsgraph
{
585 if ( -e
"$mainsettings{'RRDLOG'}/collectd/localhost/iptables-filter-HOSTILE_DROP/ipt_bytes-DROP_HOSTILE.rrd" ) {
592 "-v ".$Lang::tr
{'bytes per second'},
593 "--color=SHADEA".$color{"color19"},
594 "--color=SHADEB".$color{"color19"},
595 "--color=BACK".$color{"color21"},
596 "DEF:output=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYOUT/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
597 "DEF:input=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYIN/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
598 "DEF:forward=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYFWD/ipt_bytes-DROP_FORWARD.rrd:value:AVERAGE",
599 "DEF:newnotsyn=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
600 "DEF:portscan=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
601 "DEF:spoofedmartian=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-SPOOFED_MARTIAN/ipt_bytes-DROP_SPOOFED_MARTIAN.rrd:value:AVERAGE",
602 "DEF:hostilein=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-HOSTILE_DROP_IN/ipt_bytes-DROP_HOSTILE.rrd:value:AVERAGE",
603 "DEF:hostileout=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-HOSTILE_DROP_OUT/ipt_bytes-DROP_HOSTILE.rrd:value:AVERAGE",
604 "DEF:hostilelegacy=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-HOSTILE_DROP/ipt_bytes-DROP_HOSTILE.rrd:value:AVERAGE",
606 # This creates a new combined hostile segment.
607 # Previously we did not split into incoming/outgoing, but we cannot go back in time. This CDEF will take the values
608 # from the old RRD database if it exists and if those values are UNKNOWN (time period after Hostile was split into In and Out),
609 # we replace them with the sum of IN + OUT.
610 "CDEF:hostile=hostilelegacy,UN,hostilein,hostileout,+,hostilelegacy,IF",
612 "COMMENT:".sprintf("%-26s",$Lang::tr
{'caption'}),
613 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
614 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
615 "COMMENT:".sprintf("%14s",$Lang::tr
{'minimal'}),
616 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
617 "AREA:output".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (OUTPUT)"),
618 "GPRINT:output:MAX:%8.1lf %sBps",
619 "GPRINT:output:AVERAGE:%8.1lf %sBps",
620 "GPRINT:output:MIN:%8.1lf %sBps",
621 "GPRINT:output:LAST:%8.1lf %sBps\\j",
622 "STACK:forward".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (FORWARD)"),
623 "GPRINT:forward:MAX:%8.1lf %sBps",
624 "GPRINT:forward:AVERAGE:%8.1lf %sBps",
625 "GPRINT:forward:MIN:%8.1lf %sBps",
626 "GPRINT:forward:LAST:%8.1lf %sBps\\j",
627 "STACK:input".$color{"color24"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (INPUT)"),
628 "GPRINT:input:MAX:%8.1lf %sBps",
629 "GPRINT:input:AVERAGE:%8.1lf %sBps",
630 "GPRINT:input:MIN:%8.1lf %sBps",
631 "GPRINT:input:LAST:%8.1lf %sBps\\j",
632 "STACK:newnotsyn".$color{"color14"}."A0:".sprintf("%-25s","NewNotSYN"),
633 "GPRINT:newnotsyn:MAX:%8.1lf %sBps",
634 "GPRINT:newnotsyn:AVERAGE:%8.1lf %sBps",
635 "GPRINT:newnotsyn:MIN:%8.1lf %sBps",
636 "GPRINT:newnotsyn:LAST:%8.1lf %sBps\\j",
637 "STACK:portscan".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'portscans'}),
638 "GPRINT:portscan:MAX:%8.1lf %sBps",
639 "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
640 "GPRINT:portscan:MIN:%8.1lf %sBps",
641 "GPRINT:portscan:LAST:%8.1lf %sBps\\j",
642 "STACK:spoofedmartian".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'spoofed or martians'}),
643 "GPRINT:spoofedmartian:MAX:%8.1lf %sBps",
644 "GPRINT:spoofedmartian:AVERAGE:%8.1lf %sBps",
645 "GPRINT:spoofedmartian:MIN:%8.1lf %sBps",
646 "GPRINT:spoofedmartian:LAST:%8.1lf %sBps\\j",
647 "STACK:hostilein".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'hostile networks in'}),
648 "GPRINT:hostilein:MAX:%8.1lf %sBps",
649 "GPRINT:hostilein:AVERAGE:%8.1lf %sBps",
650 "GPRINT:hostilein:MIN:%8.1lf %sBps",
651 "GPRINT:hostilein:LAST:%8.1lf %sBps\\j",
652 "STACK:hostileout".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'hostile networks out'}),
653 "GPRINT:hostileout:MAX:%8.1lf %sBps",
654 "GPRINT:hostileout:AVERAGE:%8.1lf %sBps",
655 "GPRINT:hostileout:MIN:%8.1lf %sBps",
656 "GPRINT:hostileout:LAST:%8.1lf %sBps\\j",
657 "LINE:hostile#000000A0:".sprintf("%-25s",$Lang::tr
{'hostile networks total'}),
658 "GPRINT:hostile:MAX:%8.1lf %sBps",
659 "GPRINT:hostile:AVERAGE:%8.1lf %sBps",
660 "GPRINT:hostile:MIN:%8.1lf %sBps",
661 "GPRINT:hostile:LAST:%8.1lf %sBps\\j",
670 "-v ".$Lang::tr
{'bytes per second'},
671 "--color=SHADEA".$color{"color19"},
672 "--color=SHADEB".$color{"color19"},
673 "--color=BACK".$color{"color21"},
674 "DEF:output=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYOUT/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
675 "DEF:input=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYIN/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
676 "DEF:forward=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYFWD/ipt_bytes-DROP_FORWARD.rrd:value:AVERAGE",
677 "DEF:newnotsyn=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
678 "DEF:portscan=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
679 "DEF:spoofedmartian=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-SPOOFED_MARTIAN/ipt_bytes-DROP_SPOOFED_MARTIAN.rrd:value:AVERAGE",
680 "DEF:hostilein=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-HOSTILE_DROP_IN/ipt_bytes-DROP_HOSTILE.rrd:value:AVERAGE",
681 "DEF:hostileout=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-HOSTILE_DROP_OUT/ipt_bytes-DROP_HOSTILE.rrd:value:AVERAGE",
683 # This creates a new combined hostile segment.
684 # If we started collecting IN/OUT, ie the old single Hostile RRD database is not available then this CDEF will take the values
685 # from the sum of IN + OUT.
686 "CDEF:hostile=hostilein,hostileout,+",
688 "COMMENT:".sprintf("%-26s",$Lang::tr
{'caption'}),
689 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
690 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
691 "COMMENT:".sprintf("%14s",$Lang::tr
{'minimal'}),
692 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
693 "AREA:output".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (OUTPUT)"),
694 "GPRINT:output:MAX:%8.1lf %sBps",
695 "GPRINT:output:AVERAGE:%8.1lf %sBps",
696 "GPRINT:output:MIN:%8.1lf %sBps",
697 "GPRINT:output:LAST:%8.1lf %sBps\\j",
698 "STACK:forward".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (FORWARD)"),
699 "GPRINT:forward:MAX:%8.1lf %sBps",
700 "GPRINT:forward:AVERAGE:%8.1lf %sBps",
701 "GPRINT:forward:MIN:%8.1lf %sBps",
702 "GPRINT:forward:LAST:%8.1lf %sBps\\j",
703 "STACK:input".$color{"color24"}."A0:".sprintf("%-25s",$Lang::tr
{'firewallhits'}." (INPUT)"),
704 "GPRINT:input:MAX:%8.1lf %sBps",
705 "GPRINT:input:AVERAGE:%8.1lf %sBps",
706 "GPRINT:input:MIN:%8.1lf %sBps",
707 "GPRINT:input:LAST:%8.1lf %sBps\\j",
708 "STACK:newnotsyn".$color{"color14"}."A0:".sprintf("%-25s","NewNotSYN"),
709 "GPRINT:newnotsyn:MAX:%8.1lf %sBps",
710 "GPRINT:newnotsyn:AVERAGE:%8.1lf %sBps",
711 "GPRINT:newnotsyn:MIN:%8.1lf %sBps",
712 "GPRINT:newnotsyn:LAST:%8.1lf %sBps\\j",
713 "STACK:portscan".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr
{'portscans'}),
714 "GPRINT:portscan:MAX:%8.1lf %sBps",
715 "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
716 "GPRINT:portscan:MIN:%8.1lf %sBps",
717 "GPRINT:portscan:LAST:%8.1lf %sBps\\j",
718 "STACK:spoofedmartian".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr
{'spoofed or martians'}),
719 "GPRINT:spoofedmartian:MAX:%8.1lf %sBps",
720 "GPRINT:spoofedmartian:AVERAGE:%8.1lf %sBps",
721 "GPRINT:spoofedmartian:MIN:%8.1lf %sBps",
722 "GPRINT:spoofedmartian:LAST:%8.1lf %sBps\\j",
723 "STACK:hostilein".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr
{'hostile networks in'}),
724 "GPRINT:hostilein:MAX:%8.1lf %sBps",
725 "GPRINT:hostilein:AVERAGE:%8.1lf %sBps",
726 "GPRINT:hostilein:MIN:%8.1lf %sBps",
727 "GPRINT:hostilein:LAST:%8.1lf %sBps\\j",
728 "STACK:hostileout".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr
{'hostile networks out'}),
729 "GPRINT:hostileout:MAX:%8.1lf %sBps",
730 "GPRINT:hostileout:AVERAGE:%8.1lf %sBps",
731 "GPRINT:hostileout:MIN:%8.1lf %sBps",
732 "GPRINT:hostileout:LAST:%8.1lf %sBps\\j",
733 "LINE:hostile#000000A0:".sprintf("%-25s",$Lang::tr
{'hostile networks total'}),
734 "GPRINT:hostile:MAX:%8.1lf %sBps",
735 "GPRINT:hostile:AVERAGE:%8.1lf %sBps",
736 "GPRINT:hostile:MIN:%8.1lf %sBps",
737 "GPRINT:hostile:LAST:%8.1lf %sBps\\j",
740 $ERROR = RRDs
::error
;
741 return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR;
744 # Generate the Line Quality Graph for the current period of time for values given by collecd
746 sub updatepinggraph
{
757 "--color=SHADEA".$color{"color19"},
758 "--color=SHADEB".$color{"color19"},
759 "--color=BACK".$color{"color21"},
760 "DEF:roundtrip=".$mainsettings{'RRDLOG'}."/collectd/localhost/ping/ping-".$host.".rrd:value:AVERAGE",
761 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'})."\\j",
762 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
763 "CDEF:r0=roundtrip,30,MIN",
764 "CDEF:r1=roundtrip,70,MIN",
765 "CDEF:r2=roundtrip,150,MIN",
766 "CDEF:r3=roundtrip,300,MIN",
767 "AREA:roundtrip".$color{"color25"}."A0:>300 ms",
768 "AREA:r3".$color{"color18"}."A0:150-300 ms",
769 "AREA:r2".$color{"color14"}."A0:70-150 ms",
770 "AREA:r1".$color{"color17"}."A0:30-70 ms",
771 "AREA:r0".$color{"color12"}."A0:<30 ms\\j",
772 "COMMENT:$Lang::tr{'maximal'}",
773 "COMMENT:$Lang::tr{'average'}",
774 "COMMENT:$Lang::tr{'minimal'}","COMMENT:$Lang::tr{'current'}\\j",
775 "LINE1:roundtrip#707070:",
776 "GPRINT:roundtrip:MAX:%3.2lf ms",
777 "GPRINT:roundtrip:AVERAGE:%3.2lf ms",
778 "GPRINT:roundtrip:MIN:%3.2lf ms",
779 "GPRINT:roundtrip:LAST:%3.2lf ms\\j",
781 $ERROR = RRDs
::error
;
782 return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR;
785 sub updatewirelessgraph
{
787 my $interface = $_[0];
794 "--color=SHADEA".$color{"color19"},
795 "--color=SHADEB".$color{"color19"},
796 "--color=BACK".$color{"color21"},
797 "DEF:noise=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_noise.rrd:value:AVERAGE",
798 "DEF:power=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_power.rrd:value:AVERAGE",
799 "COMMENT:".sprintf("%-20s",$Lang::tr
{'caption'}),
800 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
801 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
802 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
803 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j",
804 "LINE1:noise".$color{"color11"}."A0:".sprintf("%-20s","Signal Noise Ratio"),
805 "GPRINT:noise:MAX:%5.1lf %sdBm",
806 "GPRINT:noise:AVERAGE:%5.1lf %sdBm",
807 "GPRINT:noise:MIN:%5.1lf %sdBm",
808 "GPRINT:noise:LAST:%5.1lf %sdBm\\j",
809 "LINE1:power".$color{"color12"}."A0:".sprintf("%-20s","Signal Power Ratio"),
810 "GPRINT:power:MAX:%5.1lf %sdBm",
811 "GPRINT:power:AVERAGE:%5.1lf %sdBm",
812 "GPRINT:power:MIN:%5.1lf %sdBm",
813 "GPRINT:power:LAST:%5.1lf %sdBm\\j",
815 $ERROR = RRDs
::error
;
816 return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR;
819 # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors
831 "--color=SHADEA".$color{"color19"},
832 "--color=SHADEB".$color{"color19"},
833 "--color=BACK".$color{"color21"},
834 "DEF:temperature=".$mainsettings{'RRDLOG'}."/hddtemp-$disk.rrd:temperature:AVERAGE",
835 "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-$disk.rrd:standby:AVERAGE",
836 "CDEF:st=standby,INF,*",
837 "AREA:st".$color{"color20"}."A0:standby",
838 "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} °C\\j",
839 "COMMENT:$Lang::tr{'maximal'}",
840 "COMMENT:$Lang::tr{'average'}",
841 "COMMENT:$Lang::tr{'minimal'}",
842 "COMMENT:$Lang::tr{'current'}\\j",
843 "GPRINT:temperature:MAX:%3.0lf °C",
844 "GPRINT:temperature:AVERAGE:%3.0lf °C",
845 "GPRINT:temperature:MIN:%3.0lf °C",
846 "GPRINT:temperature:LAST:%3.0lf °C\\j",
848 $ERROR = RRDs
::error
;
849 return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR;
852 # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors
854 sub updatehwtempgraph
{
864 "--color=SHADEA".$color{"color19"},
865 "--color=SHADEB".$color{"color19"},
866 "--color=BACK".$color{"color21"},
867 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
868 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
869 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
870 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
871 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
874 foreach(@sensorsgraphs){
876 if ( $_ =~ /temperature/ ) {
877 $_ =~ /\/(.*)sensors-
(.*)\
/(.*)\.rrd/;
878 my $label = $2.$3;$label=~ s/-//g;
879 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
880 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
884 foreach(@sensorsgraphs){
886 if ( $_ =~ /temperature/ ){
887 $_ =~ /\/(.*)sensors-
(.*)\
/(.*)\.rrd/;
888 my $label = $2.$3;$label=~ s/-//g;
889 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
890 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",);
894 RRDs
::graph
(@command);
895 $ERROR = RRDs
::error
;
896 return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR;
899 # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors
901 sub updatehwfangraph
{
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 ( $_ =~ /fanspeed/ ) {
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 ( $_ =~ /fanspeed/ ){
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 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",);
940 RRDs
::graph
(@command);
941 $ERROR = RRDs
::error
;
942 return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR;
945 # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors
947 sub updatehwvoltgraph
{
956 "--color=SHADEA".$color{"color19"},
957 "--color=SHADEB".$color{"color19"},
958 "--color=BACK".$color{"color21"},
959 "COMMENT:".sprintf("%-29s",$Lang::tr
{'caption'}),
960 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
961 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
962 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
963 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
966 foreach(@sensorsgraphs){
968 if ( $_ =~ /voltage/ ) {
969 $_ =~ /\/(.*)sensors-
(.*)\
/(.*)\.rrd/;
970 my $label = $2.$3;$label=~ s/-//g;
971 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
972 push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
976 foreach(@sensorsgraphs){
978 if ( $_ =~ /voltage/ ){
979 $_ =~ /\/(.*)sensors-
(.*)\
/(.*)\.rrd/;
980 my $label = $2.$3;$label=~ s/-//g;
981 if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
982 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",);
986 RRDs
::graph
(@command);
987 $ERROR = RRDs
::error
;
988 return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR;
992 # Generate the QoS Graph for the current period of time
997 my %qossettings = ();
998 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
1000 my $classentry = "";
1003 my $classfile = "/var/ipfire/qos/classes";
1005 $qossettings{'DEV'} = $_[0];
1006 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
1007 $qossettings{'CLASSPRFX'} = '1';
1009 $qossettings{'CLASSPRFX'} = '2';
1014 my %colorMap = (); # maps traffic classes to graph colors
1022 "-v ".$Lang::tr
{'bytes per second'},
1023 "--color=SHADEA".$color{"color19"},
1024 "--color=SHADEB".$color{"color19"},
1025 "--color=BACK".$color{"color21"},
1026 "COMMENT:".sprintf("%-28s",$Lang::tr
{'caption'}),
1027 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1028 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1029 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1030 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1033 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1037 foreach $classentry (sort @classes){
1038 @classline = split( /\;/, $classentry );
1040 # create class <-> color mapping
1041 my $colorKey = uc $classline[8]; # upper case class name as key
1042 if(! exists $colorMap{$colorKey}) {
1043 # add missing color to table, use colors 11-25
1044 my $colorIndex = 11 + ((scalar keys %colorMap) % 15);
1045 $colorMap{$colorKey} = "$color{\"color$colorIndex\"}";
1048 if ( $classline[0] eq $qossettings{'DEV'} ){
1049 push(@command, "DEF:$classline[1]=$mainsettings{'RRDLOG'}/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
1051 # get color to be used for this graph
1052 my $graphColor = $colorMap{$colorKey};
1054 if ($count eq "1") {
1055 push(@command, "AREA:$classline[1]$graphColor:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1057 push(@command, "STACK:$classline[1]$graphColor:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
1060 push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"
1061 , "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps"
1062 , "GPRINT:$classline[1]:MIN:%8.1lf %sBps"
1063 , "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");
1067 RRDs
::graph
(@command);
1068 $ERROR = RRDs
::error
;
1069 return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR;
1072 # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors
1074 sub updatecpufreqgraph
{
1075 my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`;
1084 "--color=SHADEA".$color{"color19"},
1085 "--color=SHADEB".$color{"color19"},
1086 "--color=BACK".$color{"color21"},
1087 "COMMENT:".sprintf("%-15s",$Lang::tr
{'caption'}),
1088 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1089 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1090 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1091 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1095 for(my $i = 0; $i < $cpucount; $i++) {
1096 $j++; $j = 1 if $j > 20;
1097 push(@command,"DEF:cpu".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpufreq-".$i."/cpufreq.rrd:value:AVERAGE"
1098 ,"CDEF:cpu".$i."=cpu".$i."_,1000000,/"
1099 ,"LINE1:cpu".$i.$color{"color$j"}."A0:cpu ".$i." "
1100 ,"GPRINT:cpu".$i.":MAX:%3.0lf Mhz"
1101 ,"GPRINT:cpu".$i.":AVERAGE:%3.0lf Mhz"
1102 ,"GPRINT:cpu".$i.":MIN:%3.0lf Mhz"
1103 ,"GPRINT:cpu".$i.":LAST:%3.0lf Mhz\\j");
1106 RRDs
::graph
(@command);
1107 $ERROR = RRDs
::error
;
1108 return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
1111 # Generate the Thermal Zone Temp CPU Graph
1113 sub updatethermaltempgraph
{
1114 my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null | wc -l`;
1123 "--color=SHADEA".$color{"color19"},
1124 "--color=SHADEB".$color{"color19"},
1125 "--color=BACK".$color{"color21"},
1126 "COMMENT:".sprintf("%-10s",$Lang::tr
{'caption'}),
1127 "COMMENT:".sprintf("%15s",$Lang::tr
{'maximal'}),
1128 "COMMENT:".sprintf("%15s",$Lang::tr
{'average'}),
1129 "COMMENT:".sprintf("%15s",$Lang::tr
{'minimal'}),
1130 "COMMENT:".sprintf("%15s",$Lang::tr
{'current'})."\\j"
1133 for(my $i = 0; $i < $thermalcount; $i++) {
1135 push(@command,"DEF:temp".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/thermal-thermal_zone".$i."/temperature.rrd:value:AVERAGE"
1136 ,"CDEF:temp".$i."=temp".$i."_,1,/"
1137 ,"LINE3:temp".$i.$color{"color1$j"}."A0:Temp ".$i." "
1138 ,"GPRINT:temp".$i.":MAX:%3.0lf °C"
1139 ,"GPRINT:temp".$i.":AVERAGE:%3.0lf °C"
1140 ,"GPRINT:temp".$i.":MIN:%3.0lf °C"
1141 ,"GPRINT:temp".$i.":LAST:%3.0lf °C\\j");
1144 RRDs
::graph
(@command);
1145 $ERROR = RRDs
::error
;
1146 return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
1150 # Generate a random color, used by Qos Graph to be independent from the amount of values
1152 sub random_hex_color
{
1154 $size = 6 if $size !~ /^3|6$/;
1155 my @hex = ( 0 .. 9, 'a' .. 'f' );
1157 push @color, @hex[rand(@hex)] for 1 .. $size;
1158 return join('', '#', @color);
1162 my @processesgraph = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/processes-*/ 2>/dev/null`;
1163 return @processesgraph;
1166 sub updateconntrackgraph
{
1174 "--lower-limit","0",
1175 "-v $Lang::tr{'open connections'}",
1176 "DEF:conntrack=$mainsettings{'RRDLOG'}/collectd/localhost/conntrack/conntrack.rrd:value:AVERAGE",
1177 "LINE3:conntrack#ff0000:" . sprintf("%-15s", $Lang::tr
{'open connections'}),
1178 "VDEF:ctmin=conntrack,MINIMUM",
1179 "VDEF:ctmax=conntrack,MAXIMUM",
1180 "VDEF:ctavg=conntrack,AVERAGE",
1181 "GPRINT:ctmax:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'maximum'}),
1182 "GPRINT:ctmin:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'minimum'}),
1183 "GPRINT:ctavg:" . sprintf("%15s\\: %%5.0lf", $Lang::tr
{'average'}) . "\\n",
1184 "--color=BACK" . $color{"color21"},
1187 RRDs
::graph
(@command);
1188 $ERROR = RRDs
::error
;
1190 return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR;
1193 sub updateipsthroughputgraph
{
1202 "--lower-limit","0",
1203 "-v $Lang::tr{'bytes per second'}",
1204 "--color=BACK" . $color{"color21"},
1206 # Read bypassed packets
1207 "DEF:bypassed_bytes=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_bytes-BYPASSED.rrd:value:AVERAGE",
1208 #"DEF:bypassed_packets=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_packets-BYPASSED.rrd:value:AVERAGE",
1210 "VDEF:bypassed_bytes_avg=bypassed_bytes,AVERAGE",
1211 "VDEF:bypassed_bytes_min=bypassed_bytes,MINIMUM",
1212 "VDEF:bypassed_bytes_max=bypassed_bytes,MAXIMUM",
1214 # Read scanned packets
1215 "DEF:scanned_bytes=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_bytes-SCANNED.rrd:value:AVERAGE",
1216 #"DEF:scanned_packets=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_packets-SCANNED.rrd:value:AVERAGE",
1218 "VDEF:scanned_bytes_avg=scanned_bytes,AVERAGE",
1219 "VDEF:scanned_bytes_min=scanned_bytes,MINIMUM",
1220 "VDEF:scanned_bytes_max=scanned_bytes,MAXIMUM",
1222 # Read whitelisted packets
1223 "DEF:whitelisted_bytes=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_bytes-WHITELISTED.rrd:value:AVERAGE",
1224 #"DEF:whitelisted_packets=$mainsettings{'RRDLOG'}/collectd/localhost/iptables-mangle-IPS/ipt_packets-WHITELISTED.rrd:value:AVERAGE",
1226 "VDEF:whitelisted_bytes_avg=whitelisted_bytes,AVERAGE",
1227 "VDEF:whitelisted_bytes_min=whitelisted_bytes,MINIMUM",
1228 "VDEF:whitelisted_bytes_max=whitelisted_bytes,MAXIMUM",
1231 "CDEF:total_bytes=bypassed_bytes,scanned_bytes,ADDNAN,whitelisted_bytes,ADDNAN",
1232 #"CDEF:total_packets=bypassed_packets,scanned_packets,ADDNAN,whitelisted_packets,ADDNAN",
1234 "VDEF:total_bytes_avg=total_bytes,AVERAGE",
1235 "VDEF:total_bytes_min=total_bytes,MINIMUM",
1236 "VDEF:total_bytes_max=total_bytes,MAXIMUM",
1238 # Add some space below the graph
1242 "COMMENT:" . sprintf("%32s", ""),
1243 "COMMENT:" . sprintf("%16s", $Lang::tr
{'average'}),
1244 "COMMENT:" . sprintf("%16s", $Lang::tr
{'minimum'}),
1245 "COMMENT:" . sprintf("%16s", $Lang::tr
{'maximum'}) . "\\j",
1247 # Whitelisted Packets
1248 "AREA:whitelisted_bytes$color{'color12'}A0:" . sprintf("%-30s", $Lang::tr
{'whitelisted'}),
1249 "GPRINT:whitelisted_bytes_avg:%9.2lf %sbps",
1250 "GPRINT:whitelisted_bytes_min:%9.2lf %sbps",
1251 "GPRINT:whitelisted_bytes_max:%9.2lf %sbps\\j",
1254 "STACK:bypassed_bytes$color{'color11'}A0:" . sprintf("%-30s", $Lang::tr
{'bypassed'}),
1255 "GPRINT:bypassed_bytes_avg:%9.2lf %sbps",
1256 "GPRINT:bypassed_bytes_min:%9.2lf %sbps",
1257 "GPRINT:bypassed_bytes_max:%9.2lf %sbps\\j",
1260 "STACK:scanned_bytes$color{'color13'}A0:" . sprintf("%-30s", $Lang::tr
{'scanned'}),
1261 "GPRINT:scanned_bytes_avg:%9.2lf %sbps",
1262 "GPRINT:scanned_bytes_min:%9.2lf %sbps",
1263 "GPRINT:scanned_bytes_max:%9.2lf %sbps\\j",
1268 "COMMENT:" . sprintf("%-32s", $Lang::tr
{'total'}),
1269 "GPRINT:total_bytes_avg:%9.2lf %sbps",
1270 "GPRINT:total_bytes_min:%9.2lf %sbps",
1271 "GPRINT:total_bytes_max:%9.2lf %sbps\\j",
1274 RRDs
::graph
(@command);
1275 $ERROR = RRDs
::error
;
1277 return "Error in RRD::Graph for suricata: " . $ERROR . "\n" if $ERROR;