]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/makegraphs
3 ############################################################################
5 # This file is part of the IPCop Firewall. #
7 # IPCop is free software; you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation; either version 2 of the License, or #
10 # (at your option) any later version. #
12 # IPCop is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with IPCop; if not, write to the Free Software #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21 # Copyright (C) 2004-01-19 Mark Wormgoor <mark@wormgoor.com>. #
23 ############################################################################
29 require "/var/ipfire/general-functions.pl";
30 require "${General::swroot}/lang.pl";
32 my (%settings, @ipacsum, $iface, $ERROR);
33 &General
::readhash
("${General::swroot}/ethernet/settings", \
%settings);
34 my %mbmon_settings = ();
35 &General
::readhash
("${General::swroot}/mbmon/settings", \
%mbmon_settings);
37 # Added for conversion of utf-8 characters
41 # Force language back to English (ugly hack!)
42 # Modified to only force if we are unable to convert charset
44 if ((${Lang
::language
} eq 'el') ||
45 (${Lang
::language
} eq 'fa') ||
46 (${Lang
::language
} eq 'ru') ||
47 (${Lang
::language
} eq 'th') ||
48 (${Lang
::language
} eq 'vi') ||
49 (${Lang
::language
} eq 'zh') ||
50 (${Lang
::language
} eq 'zt')) {
51 eval `/bin/cat "${General::swroot}/langs/en.pl"`;
53 %tr=%Lang::tr
; # use translated version for other languages
57 my $rrdlog = "/var/log/rrd";
58 my $graphs = "/srv/web/ipfire/html/graphs";
59 $ENV{PATH
}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
60 my $hdd_device = "/dev/harddisk";
62 my %mbmon_values = ();
69 my $path_smartctl = "/usr/sbin/smartctl";
70 my $path_hddtemp = "/usr/sbin/hddtemp";
73 $colors{"1"} = "#0000FF";
74 $colors{"2"} = "#00FF00";
75 $colors{"3"} = "#FF0000";
76 $colors{"4"} = "#FFD700";
77 $colors{"5"} = "#CCCCCC";
78 $colors{"6"} = "#40E0D0";
79 $colors{"7"} = "#90EE90";
80 $colors{"8"} = "#F4A460";
82 open(MBMON_OUT
, ">/var/log/mbmon-values");
83 open(FD
, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ;
87 next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ;
91 $mbmon_values{$key} = $value;
92 print(MBMON_OUT
"$key=$value\n");
98 my $interface = $_[0];
106 $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/);
108 # Forwarded Incoming...
109 $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/);
112 $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/);
114 # Forwarded Outgoing...
115 $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/);
117 return "$bytesin:$bytesout";
123 RRDs
::graph
("$graphs/cpu-$period.png",
124 "--start", "-1$period", "-aPNG", "-i", "-z",
125 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
126 "--color", "SHADEA#EAE9EE",
127 "--color", "SHADEB#EAE9EE",
128 "--color", "BACK#FFFFFF",
129 "-t $tr{'cpu usage per'} $tr{$period}",
130 "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE",
131 "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE",
132 "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE",
133 "CDEF:total=user,system,idle,+,+",
134 "CDEF:userpct=100,user,total,/,*",
135 "CDEF:systempct=100,system,total,/,*",
136 "CDEF:idlepct=100,idle,total,/,*",
137 "AREA:userpct#0000FF:$tr{'user cpu usage'}\\j",
138 "STACK:systempct#FF0000:$tr{'system cpu usage'}\\j",
139 "STACK:idlepct#00FF00:$tr{'idle cpu usage'}\\j",
140 "GPRINT:userpct:MAX:$tr{'maximal'} $tr{'user cpu'}\\:%3.2lf%%",
141 "GPRINT:userpct:AVERAGE:$tr{'average'} $tr{'user cpu'}\\:%3.2lf%%",
142 "GPRINT:userpct:LAST:$tr{'current'} $tr{'user cpu'}\\:%3.2lf%%\\j",
143 "GPRINT:systempct:MAX:$tr{'maximal'} $tr{'system cpu'}\\:%3.2lf%%",
144 "GPRINT:systempct:AVERAGE:$tr{'average'} $tr{'system cpu'}\\:%3.2lf%%",
145 "GPRINT:systempct:LAST:$tr{'current'} $tr{'system cpu'}\\:%3.2lf%%\\j",
146 "GPRINT:idlepct:MAX:$tr{'maximal'} $tr{'idle cpu'}\\:%3.2lf%%",
147 "GPRINT:idlepct:AVERAGE:$tr{'average'} $tr{'idle cpu'}\\:%3.2lf%%",
148 "GPRINT:idlepct:LAST:$tr{'current'} $tr{'idle cpu'}\\:%3.2lf%%\\j");
149 $ERROR = RRDs
::error
;
150 print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
154 if ( ! -e
"$rrdlog/cpu.rrd") {
155 RRDs
::create
("$rrdlog/cpu.rrd", "--step=300",
156 "DS:user:COUNTER:600:0:500000000",
157 "DS:system:COUNTER:600:0:500000000",
158 "DS:idle:COUNTER:600:0:500000000",
159 "RRA:AVERAGE:0.5:1:576",
160 "RRA:AVERAGE:0.5:6:672",
161 "RRA:AVERAGE:0.5:24:732",
162 "RRA:AVERAGE:0.5:144:1460");
163 $ERROR = RRDs
::error
;
164 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
167 my ($cpu, $user, $nice, $system, $idle);
169 open STAT
, "/proc/stat";
173 ($cpu, $user, $nice, $system, $idle) = split /\s+/;
179 RRDs
::update
("$rrdlog/cpu.rrd",
180 "-t", "user:system:idle",
181 "N:$user:$system:$idle");
182 $ERROR = RRDs
::error
;
183 print "Error in RRD::update for cpu: $ERROR\n" if $ERROR;
187 sub updateloadgraph
{
190 RRDs
::graph
("$graphs/load-$period.png",
191 "--start", "-1$period", "-aPNG",
192 "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid",
194 "--color", "SHADEA#EAE9EE",
195 "--color", "SHADEB#EAE9EE",
196 "--color", "BACK#FFFFFF",
197 "DEF:load1=$rrdlog/load.rrd:load1:AVERAGE",
198 "DEF:load5=$rrdlog/load.rrd:load5:AVERAGE",
199 "DEF:load15=$rrdlog/load.rrd:load15:AVERAGE",
200 "AREA:load1#ff0000:1 Minute, letzter\\:",
201 "GPRINT:load1:LAST:%5.2lf\\j",
202 "AREA:load5#ff9900:5 Minuten, letzter\\:",
203 "GPRINT:load5:LAST:%5.2lf\\j",
204 "AREA:load15#ffff00:15 Minuten, letzter\\:",
205 "GPRINT:load15:LAST:%5.2lf\\j",
206 "LINE1:load5#ff9900:",
207 "LINE1:load1#ff0000:");
208 $ERROR = RRDs
::error
;
209 print "Error in RRD::graph for load: $ERROR\n" if $ERROR;
213 if ( ! -e
"$rrdlog/load.rrd") {
214 RRDs
::create
("$rrdlog/load.rrd", "--step=60",
215 "DS:load1:GAUGE:120:0:U",
216 "DS:load5:GAUGE:120:0:U",
217 "DS:load15:GAUGE:120:0:U",
218 "RRA:AVERAGE:0.5:1:2160",
219 "RRA:AVERAGE:0.5:5:2016",
220 "RRA:AVERAGE:0.5:15:2880",
221 "RRA:AVERAGE:0.5:60:8760");
223 $ERROR = RRDs
::error
;
224 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
231 RRDs
::graph
("$graphs/memory-$period.png",
232 "--start", "-1$period", "-aPNG", "-i", "-z",
233 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
234 "--color", "SHADEA#EAE9EE",
235 "--color", "SHADEB#EAE9EE",
236 "--color", "BACK#FFFFFF",
237 "-t $tr{'memory usage per'} $tr{$period}",
238 "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE",
239 "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE",
240 "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE",
241 "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE",
242 "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE",
243 "CDEF:total=used,free,+",
244 "CDEF:used2=used,buffer,cache,shared,+,+,-",
245 "CDEF:usedpct=100,used2,total,/,*",
246 "CDEF:sharedpct=100,shared,total,/,*",
247 "CDEF:bufferpct=100,buffer,total,/,*",
248 "CDEF:cachepct=100,cache,total,/,*",
249 "CDEF:freepct=100,free,total,/,*",
250 "AREA:usedpct#0000FF:$tr{'used memory'}\\j",
251 "STACK:sharedpct#FF0000:$tr{'shared memory'}\\j",
252 "STACK:bufferpct#FF00FF:$tr{'buffered memory'}\\j",
253 "STACK:cachepct#FFFF00:$tr{'cached memory'}\\j",
254 "STACK:freepct#00FF00:$tr{'free memory'}\\j",
255 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used memory'}\\:%3.2lf%%",
256 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used memory'}\\:%3.2lf%%",
257 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used memory'}\\:%3.2lf%%\\j",
258 "GPRINT:sharedpct:MAX:$tr{'maximal'} $tr{'shared memory'}\\:%3.2lf%%",
259 "GPRINT:sharedpct:AVERAGE:$tr{'average'} $tr{'shared memory'}\\:%3.2lf%%",
260 "GPRINT:sharedpct:LAST:$tr{'current'} $tr{'shared memory'}\\:%3.2lf%%\\j",
261 "GPRINT:bufferpct:MAX:$tr{'maximal'} $tr{'buffered memory'}\\:%3.2lf%%",
262 "GPRINT:bufferpct:AVERAGE:$tr{'average'} $tr{'buffered memory'}\\:%3.2lf%%",
263 "GPRINT:bufferpct:LAST:$tr{'current'} $tr{'buffered memory'}\\:%3.2lf%%\\j",
264 "GPRINT:cachepct:MAX:$tr{'maximal'} $tr{'cached memory'}\\:%3.2lf%%",
265 "GPRINT:cachepct:AVERAGE:$tr{'average'} $tr{'cached memory'}\\:%3.2lf%%",
266 "GPRINT:cachepct:LAST:$tr{'current'} $tr{'cached memory'}\\:%3.2lf%%\\j",
267 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free memory'}\\:%3.2lf%%",
268 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free memory'}\\:%3.2lf%%",
269 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free memory'}\\:%3.2lf%%\\j");
270 $ERROR = RRDs
::error
;
271 print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
273 RRDs
::graph
("$graphs/swap-$period.png",
274 "--start", "-1$period", "-aPNG", "-i", "-z",
275 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
276 "--color", "SHADEA#EAE9EE",
277 "--color", "SHADEB#EAE9EE",
278 "--color", "BACK#FFFFFF",
279 "-t $tr{'swap usage per'} $tr{$period}",
280 "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE",
281 "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE",
282 "CDEF:total=used,free,+",
283 "CDEF:usedpct=100,used,total,/,*",
284 "CDEF:freepct=100,free,total,/,*",
285 "AREA:usedpct#0000FF:$tr{'used swap'}\\j",
286 "STACK:freepct#00FF00:$tr{'free swap'}\\j",
287 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used swap'}\\:%3.2lf%%",
288 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used swap'}\\:%3.2lf%%",
289 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used swap'}\\:%3.2lf%%\\j",
290 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free swap'}\\:%3.2lf%%",
291 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free swap'}\\:%3.2lf%%",
292 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free swap'}\\:%3.2lf%%\\j");
293 $ERROR = RRDs
::error
;
294 print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
298 my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree);
299 if ( ! -e
"$rrdlog/mem.rrd") {
300 RRDs
::create
("$rrdlog/mem.rrd", "--step=300",
301 "DS:memused:ABSOLUTE:600:0:5000000000",
302 "DS:memfree:ABSOLUTE:600:0:5000000000",
303 "DS:memshared:ABSOLUTE:600:0:5000000000",
304 "DS:membuffers:ABSOLUTE:600:0:5000000000",
305 "DS:memcache:ABSOLUTE:600:0:5000000000",
306 "DS:swapused:ABSOLUTE:600:0:5000000000",
307 "DS:swapfree:ABSOLUTE:600:0:5000000000",
308 "RRA:AVERAGE:0.5:1:576",
309 "RRA:AVERAGE:0.5:6:672",
310 "RRA:AVERAGE:0.5:24:732",
311 "RRA:AVERAGE:0.5:144:1460");
312 $ERROR = RRDs
::error
;
313 print "Error in RRD::create for mem: $ERROR\n" if $ERROR;
316 open MEM
, "/proc/meminfo";
319 if ($_ =~ /^MemTotal:/) {
320 my @temp = split (/\s+/, $_);
322 } elsif ($_ =~ /^MemFree:/) {
323 my @temp = split (/\s+/, $_);
325 } elsif ($_ =~ /^Cached:/) {
326 my @temp = split (/\s+/, $_);
327 $memcache = $temp[1];
328 } elsif ($_ =~ /^Buffers:/) {
329 my @temp = split (/\s+/, $_);
330 $membuffers = $temp[1];
331 } elsif ($_ =~ /^SwapTotal:/) {
332 my @temp = split (/\s+/, $_);
333 $swapused = $temp[1];
334 } elsif ($_ =~ /^SwapFree:/) {
335 my @temp = split (/\s+/, $_);
336 $swapfree = $temp[1];
341 system("/bin/df > /tmp/diskfree");
342 open DF
, "/tmp/diskfree";
346 my @temp = split (/\s+/, $_);
347 $memshared = $temp[2];
351 system("/bin/rm -f /tmp/diskfree");
353 RRDs
::update
("$rrdlog/mem.rrd",
354 "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree",
355 "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree");
356 $ERROR = RRDs
::error
;
357 print "Error in RRD::update for mem: $ERROR\n" if $ERROR;
360 sub updatediskgraph
{
363 RRDs
::graph
("$graphs/disk-$period.png",
364 "--start", "-1$period", "-aPNG", "-i", "-z",
365 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
366 "--color", "SHADEA#EAE9EE",
367 "--color", "SHADEB#EAE9EE",
368 "--color", "BACK#FFFFFF",
369 "-t $tr{'disk access per'} $tr{$period}",
370 "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE",
371 "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE",
372 "AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j",
373 "STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j",
374 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
375 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
376 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
377 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
378 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
379 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
380 $ERROR = RRDs
::error
;
381 print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
385 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
386 if ( ! -e
"$rrdlog/disk.rrd") {
387 RRDs
::create
("$rrdlog/disk.rrd", "--step=300",
388 "DS:readsect:COUNTER:600:0:5000000000",
389 "DS:writesect:COUNTER:600:0:5000000000",
390 "RRA:AVERAGE:0.5:1:576",
391 "RRA:AVERAGE:0.5:6:672",
392 "RRA:AVERAGE:0.5:24:732",
393 "RRA:AVERAGE:0.5:144:1460");
394 $ERROR = RRDs
::error
;
395 print "Error in RRD::create for disk: $ERROR\n" if $ERROR;
398 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
399 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk");
401 my $major = $rdev >> 8;
402 my $minor = $rdev & 0xFF;
404 open STAT
, "/proc/stat";
405 my @diskstat = <STAT
>;
407 foreach my $line (@diskstat)
410 my @temp = split(/\:\ /,$line);
412 my @devicestat = split(/\ /,$temp[1]);
413 foreach my $stats (@devicestat)
416 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
417 if ($major eq $fields[1] and $minor eq $fields[2])
419 $readwritereq = $fields[3];
420 $readreq = $fields[4];
421 $readsect = $fields[5];
422 $writereq = $fields[6];
423 $writesect = $fields[7];
429 if ($readsect && $writesect) {
430 RRDs
::update
("$rrdlog/disk.rrd",
431 "-t", "readsect:writesect",
432 "N:$readsect:$writesect");
433 $ERROR = RRDs
::error
;
434 print "Error in RRD::update for disk: $ERROR\n" if $ERROR;
436 print "Error in RRD::update for disk: no data available\n";
440 sub updatediskgraphnew
{
444 RRDs
::graph
("$graphs/disk-$disk-$period.png",
445 "--start", "-1$period", "-aPNG", "-i", "-z",
446 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
447 "--color", "SHADEA#EAE9EE",
448 "--color", "SHADEB#EAE9EE",
449 "--color", "BACK#FFFFFF",
450 "-t $tr{'disk access per'} $tr{$period}",
451 "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
452 "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
453 "DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE",
454 "CDEF:sl_state=sleep,INF,*",
456 "AREA:sl_state#a0a0a0:disk standby\\j",
457 "AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j",
458 "STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j",
460 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
461 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
462 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
463 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
464 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
465 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
466 $ERROR = RRDs
::error
;
467 print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR;
470 sub updatediskdatanew
{
473 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
474 if ( ! -e
"$rrdlog/disk-$disk.rrd") {
475 RRDs
::create
("$rrdlog/disk-$disk.rrd", "--step=300",
476 "DS:readsect:COUNTER:600:0:5000000000",
477 "DS:writesect:COUNTER:600:0:5000000000",
478 "DS:sleeping:GAUGE:600:0:1",
479 "RRA:AVERAGE:0.5:1:576",
480 "RRA:AVERAGE:0.5:6:672",
481 "RRA:AVERAGE:0.5:24:732",
482 "RRA:AVERAGE:0.5:144:1460");
483 $ERROR = RRDs
::error
;
484 print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR;
487 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
488 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk");
490 print "\n\n$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks\n\n";
492 my $major = $rdev >> 8;
493 my $minor = ($rdev & 0xFF) >>6;
495 open STAT
, "/proc/stat";
496 my @diskstat = <STAT
>;
498 foreach my $line (@diskstat)
501 my @temp = split(/\:\ /,$line);
503 my @devicestat = split(/\ /,$temp[1]);
504 foreach my $stats (@devicestat)
507 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
508 if ($major eq $fields[1] and $minor eq $fields[2])
510 $readwritereq = $fields[3];
511 $readreq = $fields[4];
512 $readsect = $fields[5];
513 $writereq = $fields[6];
514 $writesect = $fields[7];
521 my $lastsleepstate=0;
523 if ( -e
"/tmp/hddshutdown-$disk" ) {
524 open STAT
,"/tmp/hddshutdown-$disk";
525 $lastsleepstate = <STAT
>;
527 if ($lastsleepstate==$readwritereq) {
532 if ($readsect && $writesect) {
533 RRDs
::update
("$rrdlog/disk-$disk.rrd",
534 "-t", "readsect:writesect:sleeping",
535 "N:$readsect:$writesect:$sleeping");
536 $ERROR = RRDs
::error
;
537 print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR;
539 print "Error in RRD::update for disk-$disk: no data available\n";
544 my $interface = $_[0];
547 RRDs
::graph
("$graphs/$interface-$period.png",
548 "--start", "-1$period", "-aPNG", "-i", "-z",
549 "--alt-y-grid", "-w 600", "-h 100",
550 "--color", "SHADEA#EAE9EE",
551 "--color", "SHADEB#EAE9EE",
552 "--color", "BACK#FFFFFF",
553 "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})",
554 "-v$tr{'bytes per second'}",
555 "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE",
556 "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE",
557 "AREA:incoming#00FF00:$tr{'incoming traffic in bytes per second'}\\j",
558 "LINE1:outgoing#0000FF:$tr{'outgoing traffic in bytes per second'}\\j",
559 "GPRINT:incoming:MAX:$tr{'maximal'} $tr{'in'}\\:%8.3lf %sBps",
560 "GPRINT:incoming:AVERAGE:$tr{'average'} $tr{'in'}\\:%8.3lf %sBps",
561 "GPRINT:incoming:LAST:$tr{'current'} $tr{'in'}\\:%8.3lf %sBps\\j",
562 "GPRINT:outgoing:MAX:$tr{'maximal'} $tr{'out'}\\:%8.3lf %sBps",
563 "GPRINT:outgoing:AVERAGE:$tr{'average'} $tr{'out'}\\:%8.3lf %sBps",
564 "GPRINT:outgoing:LAST:$tr{'current'} $tr{'out'}\\:%8.3lf %sBps\\j");
565 $ERROR = RRDs
::error
;
566 print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
570 my $interface = $_[0];
572 if ( ! -e
"$rrdlog/$interface.rrd") {
573 RRDs
::create
("$rrdlog/$interface.rrd", "--step=300",
574 "DS:incoming:ABSOLUTE:600:0:12500000",
575 "DS:outgoing:ABSOLUTE:600:0:12500000",
576 "RRA:AVERAGE:0.5:1:576",
577 "RRA:AVERAGE:0.5:6:672",
578 "RRA:AVERAGE:0.5:24:732",
579 "RRA:AVERAGE:0.5:144:1460");
580 $ERROR = RRDs
::error
;
581 print "Error in RRD::create for $interface: $ERROR\n" if $ERROR;
584 my $traffic = gettraffic
($interface);
585 RRDs
::update
("$rrdlog/$interface.rrd",
586 "-t", "incoming:outgoing",
588 $ERROR = RRDs
::error
;
589 print "Error in RRD::update for $interface: $ERROR\n" if $ERROR;
592 sub updatefwhitsgraph
{
593 my $interval = $_[0];
595 RRDs
::graph
("$graphs/firewallhits-$interval-area.png",
596 "--start", "-1$interval", "-aPNG", "-i", "-z",
597 "--alt-y-grid", "-w 600", "-h 200",
598 "--color", "SHADEA#EAE9EE",
599 "--color", "SHADEB#EAE9EE",
600 "--color", "BACK#FFFFFF",
601 "-t firewall hits over the last $interval",
602 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
603 "AREA:amount#6464FF:firewallhits",
604 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
605 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
606 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
607 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
608 "AREA:portamount#FF6464:portscans",
609 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
610 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
611 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
612 $ERROR = RRDs
::error
;
613 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
615 RRDs
::graph
("$graphs/firewallhits-$interval-line.png",
616 "--start", "-1$interval", "-aPNG", "-i", "-z",
617 "--alt-y-grid", "-w 600", "-h 200",
618 "--color", "SHADEA#EAE9EE",
619 "--color", "SHADEB#EAE9EE",
620 "--color", "BACK#FFFFFF",
621 "-t firewall hits over the last $interval",
622 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
623 "LINE2:amount#6464FF:firewallhits",
624 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
625 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
626 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
627 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
628 "LINE2:portamount#FF6464:portscans",
629 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
630 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
631 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
632 $ERROR = RRDs
::error
;
633 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
636 sub updatefwhitsdata
{
643 if (! -e
"$rrdlog/firewallhits.rrd")
645 RRDs
::create
("$rrdlog/firewallhits.rrd", "--step=300",
646 "DS:amount:GAUGE:600:0:U",
647 "DS:portamount:GAUGE:600:0:U",
648 "RRA:AVERAGE:0.5:1:576",
649 "RRA:AVERAGE:0.5:6:672",
650 "RRA:AVERAGE:0.5:24:732",
651 "RRA:AVERAGE:0.5:144:1460");
652 $ERROR = RRDs
::error
;
653 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
656 system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits");
657 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
663 if (/kernel:.*(IN=.*)$/) {
670 system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits");
671 if (!(open (FILE
,'/tmp/snort.fwhits'))) {
684 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
690 if (/kernel:.*(Scan.*)$/) {
697 system("rm /tmp/messages.fwhits");
698 system("rm /tmp/snort.fwhits");
700 $portamount = $portaktuell + $alertaktuell;
702 RRDs
::update
("$rrdlog/firewallhits.rrd",
703 "N:$aktuell:$portamount");
704 $ERROR = RRDs
::error
;
705 print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR;
708 # Creates and updates a link quality database
709 # -------------------------------------------
711 if ( ! -e
"$rrdlog/lq.rrd") {
712 RRDs
::create
("$rrdlog/lq.rrd", "--step=300",
713 "DS:loss:GAUGE:600:0:100",
714 "DS:roundtrip:GAUGE:600:0:10000",
715 "RRA:AVERAGE:0.5:1:576",
716 "RRA:AVERAGE:0.5:6:672",
717 "RRA:AVERAGE:0.5:24:732",
718 "RRA:AVERAGE:0.5:144:1460");
719 $ERROR = RRDs
::error
;
720 print "Error in RRD::create for link: $ERROR\n" if $ERROR;
725 # LQ_GATEWAY is the ip of your isp's public ip facing you
726 my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`;
728 my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`;
730 my @temp = split (/\/|\
%|\s
/, $pingoutput);
731 $packetloss = $temp[17];
732 $roundtrip = $temp[28];
733 RRDs
::update
("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip");
734 $ERROR = RRDs
::error
;
735 print "Error in RRD::update for line quality: $ERROR\n" if $ERROR;
740 RRDs
::graph
("$graphs/lq-$period.png",
741 "--start", "-1$period", "-aPNG", "-i", "-z",
742 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
743 "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})",
745 "--color", "SHADEA#EAE9EE",
746 "--color", "SHADEB#EAE9EE",
747 "--color", "BACK#FFFFFF",
748 "-v ms / pkts (% x10)",
749 "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE",
750 "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE",
751 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
752 "CDEF:loss10=loss,10,*",
753 "CDEF:r0=roundtrip,30,MIN",
754 "CDEF:r1=roundtrip,70,MIN",
755 "CDEF:r2=roundtrip,150,MIN",
756 "CDEF:r3=roundtrip,300,MIN",
757 "AREA:roundtrip#EE7000:>300 ms",
758 "AREA:r3#D88E1B:150-300 ms",
759 "AREA:r2#B9B63F:70-150 ms",
760 "AREA:r1#99E064:30-70 ms",
761 "AREA:r0#80FF80:<30 ms",
762 "AREA:loss10#800000:Packet loss (x10)",
763 "LINE1:roundtrip#707070:",
764 "GPRINT:roundtrip:MAX:$tr{'maximal'}\\:%3.2lf ms",
765 "GPRINT:roundtrip:AVERAGE:$tr{'average'}\\:%3.2lf ms",
766 "GPRINT:roundtrip:LAST:$tr{'current'}\\:%3.2lf ms\\j",
767 "GPRINT:loss:MAX:$tr{'maximal'} Loss\\:%3.2lf%%",
768 "GPRINT:loss:AVERAGE:$tr{'average'} Loss\\:%3.2lf%%",
769 "GPRINT:loss:LAST:$tr{'current'} Loss\\:%3.2lf%%\\j"
771 $ERROR = RRDs
::error
;
772 print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
778 if ( ! -e
"$rrdlog/hddtemp-$disk.rrd")
780 # database did not exist -> create
781 RRDs
::create
("$rrdlog/hddtemp-$disk.rrd", "--step=300",
782 "DS:temperature:GAUGE:600:0:100",
783 "RRA:AVERAGE:0.5:1:576",
784 "RRA:AVERAGE:0.5:6:672",
785 "RRA:AVERAGE:0.5:24:732",
786 "RRA:AVERAGE:0.5:144:1460");
787 $ERROR = RRDs
::error
;
788 print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR;
793 my $smart_output = '';
795 if ( -e
"$path_smartctl" )
797 system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
800 if ( -e
"$path_hddtemp" )
802 $hdd_output = `$path_hddtemp -qn /dev/$disk`;
804 # I know 4 response possible responses:
806 # /dev/harddisk: harddisk type: S.M.A.R.T. not available
807 # /dev/harddisk: harddisk type: no sensor
808 # /dev/harddisk: harddisk type: 37°C or °F
811 if ( index($hdd_output, "S.M.A.R.T.") != -1 )
815 elsif ( index($hdd_output, "no sensor") != -1 )
819 elsif ( index($hdd_output, "$disk") != -1 )
821 $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
826 $hdd_output =~ /(\d+)\s/;
830 elsif ( -e
"/var/log/smartctl_out_hddtemp-$disk" )
832 $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`;
833 my @t = split(/\s+/,$hdd_output);
841 # print "hdd $hdd_output \n";
842 # print "temp $temp \n";
844 RRDs
::update
("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
846 $ERROR = RRDs
::error
;
847 print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
854 RRDs
::graph
("$graphs/hddtemp-$disk-$period.png",
855 "--start", "-1$period", "-aPNG", "-i", "-z",
856 "--alt-y-grid", "-w 600", "-h 100",
857 "--color", "SHADEA#EAE9EE",
858 "--color", "SHADEB#EAE9EE",
859 "--color", "BACK#FFFFFF",
860 "-t $tr{'harddisk temperature'} ($tr{'graph per'} $tr{$period})",
861 "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
862 "LINE2:temperature#0000FF:$tr{'hdd temperature in'} °C",
863 "GPRINT:temperature:MAX:$tr{'maximal'}\\:%3.0lf °C",
864 "GPRINT:temperature:AVERAGE:$tr{'average'}\\:%3.0lf °C",
865 "GPRINT:temperature:LAST:$tr{'current'}\\:%3.0lf °C",
867 $ERROR = RRDs
::error
;
868 print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;
873 if ( ! -e
"$rrdlog/mbmon.rrd" )
875 # database did not exist -> create
877 @args = ("$rrdlog/mbmon.rrd");
879 push(@args, "--step=300");
880 foreach $key ( sort(keys %mbmon_values) )
882 push(@args, "DS:$key:GAUGE:600:U:U");
884 push(@args, "RRA:AVERAGE:0.5:1:576");
885 push(@args, "RRA:AVERAGE:0.5:6:672");
886 push(@args, "RRA:AVERAGE:0.5:24:732");
887 push(@args, "RRA:AVERAGE:0.5:144:1460");
889 print("create ". join( ", ", @args)) if ( $dbg );
891 RRDs
::create
(@args);
892 $ERROR = RRDs
::error
;
893 print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
900 foreach $key ( sort(keys %mbmon_values) )
903 push(@val, $mbmon_values{$key});
906 $template = join(':', @ds);
907 $value = "N:".join(':', @val);
909 print("update template = '$template'\n") if ( $dbg );
910 print("update value = '$value'\n") if ( $dbg );
912 RRDs
::update
("$rrdlog/mbmon.rrd", "-t", $template, $value);
913 $ERROR = RRDs
::error
;
914 print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
922 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
923 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
924 "--color", "SHADEA#EAE9EE",
925 "--color", "SHADEB#EAE9EE",
926 "--color", "BACK#FFFFFF",
927 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
930 foreach $key ( sort(keys %mbmon_values) )
932 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
934 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
936 $mbmon_settings{'LABEL-'.$key} = $key;
939 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
940 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C");
941 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C");
942 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C");
943 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j");
951 RRDs
::graph
( @args );
952 $ERROR = RRDs
::error
;
953 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
962 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
963 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
964 "--color", "SHADEA#EAE9EE",
965 "--color", "SHADEB#EAE9EE",
966 "--color", "BACK#FFFFFF",
967 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
970 foreach $key ( sort(keys %mbmon_values) )
972 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
974 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
976 $mbmon_settings{'LABEL-'.$key} = $key;
979 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
980 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm");
981 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm");
982 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm");
983 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j");
991 RRDs
::graph
( @args );
992 $ERROR = RRDs
::error
;
993 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
1002 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
1003 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
1004 "--color", "SHADEA#EAE9EE",
1005 "--color", "SHADEB#EAE9EE",
1006 "--color", "BACK#FFFFFF",
1007 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
1010 foreach $key ( sort(keys %mbmon_values) )
1012 my $v = substr($key,0,1);
1013 if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') )
1015 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
1017 $mbmon_settings{'LABEL-'.$key} = $key;
1020 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
1021 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} V");
1022 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V");
1023 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V");
1024 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j");
1032 RRDs
::graph
( @args );
1033 $ERROR = RRDs
::error
;
1034 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
1039 system ('/usr/sbin/fetchipac');
1045 if ( -e
"/var/log/squid/access.log") {
1046 system ("/usr/bin/squid-graph -o=/srv/web/ipfire/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1");
1052 if ((${Lang
::language
} eq 'cs') ||
1053 (${Lang
::language
} eq 'hu') ||
1054 (${Lang
::language
} eq 'pl') ||
1055 (${Lang
::language
} eq 'sk')) {
1056 # Czech, Hungarian, Polish and Slovak character set
1057 foreach my $key(keys %Lang::tr
) {
1058 from_to
($tr{$key}, "utf-8", "iso-8859-2");
1060 } elsif (${Lang
::language
} eq 'tr') {
1062 foreach my $key(keys %Lang::tr
) {
1063 from_to
($tr{$key}, "utf-8", "iso-8859-9");
1066 foreach my $key(keys %Lang::tr
) {
1067 from_to
($tr{$key}, "utf-8", "iso-8859-1");
1075 updatecpugraph
("day");
1076 updatecpugraph
("week");
1077 updatecpugraph
("month");
1078 updatecpugraph
("year");
1081 updateloadgraph
("day");
1082 updateloadgraph
("week");
1083 updateloadgraph
("month");
1084 updateloadgraph
("year");
1087 updatememgraph
("day");
1088 updatememgraph
("week");
1089 updatememgraph
("month");
1090 updatememgraph
("year");
1093 updatediskgraph
("day");
1094 updatediskgraph
("week");
1095 updatediskgraph
("month");
1096 updatediskgraph
("year");
1098 if (open STAT
,"/dev/hda") {
1100 updatediskdatanew
("hda");
1101 updatediskgraphnew
("hda","day");
1102 updatediskgraphnew
("hda","week");
1103 updatediskgraphnew
("hda","month");
1104 updatediskgraphnew
("hda","year");
1106 if (-e
"$graphs/disk-hda-day.png") {
1107 system("rm $graphs/disk-hda-day.png");
1111 if (open STAT
,"/dev/hdb") {
1113 updatediskdatanew
("hdb");
1114 updatediskgraphnew
("hdb","day");
1115 updatediskgraphnew
("hdb","week");
1116 updatediskgraphnew
("hdb","month");
1117 updatediskgraphnew
("hdb","year");
1119 if (-e
"$graphs/disk-hdb-day.png") {
1120 system("rm $graphs/disk-hdb-day.png");
1124 if (open STAT
,"/dev/hdc") {
1126 updatediskdatanew
("hdc");
1127 updatediskgraphnew
("hdc","day");
1128 updatediskgraphnew
("hdc","week");
1129 updatediskgraphnew
("hdc","month");
1130 updatediskgraphnew
("hdc","year");
1132 if (-e
"$graphs/disk-hdc-day.png") {
1133 system("rm $graphs/disk-hdc-day.png");
1137 if (open STAT
,"/dev/hdd") {
1139 updatediskdatanew
("hdd");
1140 updatediskgraphnew
("hdd","day");
1141 updatediskgraphnew
("hdd","week");
1142 updatediskgraphnew
("hdd","month");
1143 updatediskgraphnew
("hdd","year");
1145 if (-e
"$graphs/disk-hdd-day.png") {
1146 system("rm $graphs/disk-hdd-day.png");
1150 if (open STAT
,"/dev/hde") {
1152 updatediskdatanew
("hde");
1153 updatediskgraphnew
("hde","day");
1154 updatediskgraphnew
("hde","week");
1155 updatediskgraphnew
("hde","month");
1156 updatediskgraphnew
("hde","year");
1158 if (-e
"$graphs/disk-hde-day.png") {
1159 system("rm $graphs/disk-hde-day.png");
1163 if (open STAT
,"/dev/hdf") {
1165 updatediskdatanew
("hdf");
1166 updatediskgraphnew
("hdf","day");
1167 updatediskgraphnew
("hdf","week");
1168 updatediskgraphnew
("hdf","month");
1169 updatediskgraphnew
("hdf","year");
1171 if (-e
"$graphs/disk-hdf-day.png") {
1172 system("rm $graphs/disk-hdf-day.png");
1176 if (open STAT
,"/dev/hdg") {
1178 updatediskdatanew
("hdg");
1179 updatediskgraphnew
("hdg","day");
1180 updatediskgraphnew
("hdg","week");
1181 updatediskgraphnew
("hdg","month");
1182 updatediskgraphnew
("hdg","year");
1184 if (-e
"$graphs/disk-hdg-day.png") {
1185 system("rm $graphs/disk-hdg-day.png");
1189 if (open STAT
,"/dev/hdh") {
1191 updatediskdatanew
("hdh");
1192 updatediskgraphnew
("hdh","day");
1193 updatediskgraphnew
("hdh","week");
1194 updatediskgraphnew
("hdh","month");
1195 updatediskgraphnew
("hdh","year");
1197 if (-e
"$graphs/disk-hdh-day.png") {
1198 system("rm $graphs/disk-hdh-day.png");
1206 updatefwhitsgraph
("day");
1207 updatefwhitsgraph
("week");
1208 updatefwhitsgraph
("month");
1209 updatefwhitsgraph
("year");
1216 updatelqgraph
("day");
1217 updatelqgraph
("week");
1218 updatelqgraph
("month");
1219 updatelqgraph
("year");
1222 ### HDDTEMP-Graphs for /dev/harddisk
1224 if (open STAT
,"/dev/hda") {
1226 updatehdddata
("hda");
1227 updatehddgraph
("hda","day");
1228 updatehddgraph
("hda","week");
1229 updatehddgraph
("hda","month");
1230 updatehddgraph
("hda","year");
1232 if (-e
"$graphs/hddtemp-hda-day.png") {
1233 system("rm $graphs/hddtemp-hda-day.png");
1237 if (open STAT
,"/dev/hdb") {
1239 updatehdddata
("hdb");
1240 updatehddgraph
("hdb","day");
1241 updatehddgraph
("hdb","week");
1242 updatehddgraph
("hdb","month");
1243 updatehddgraph
("hdb","year");
1245 if (-e
"$graphs/hddtemp-hdb-day.png") {
1246 system("rm $graphs/hddtemp-hdb-day.png");
1250 if (open STAT
,"/dev/hdc") {
1252 updatehdddata
("hdc");
1253 updatehddgraph
("hdc","day");
1254 updatehddgraph
("hdc","week");
1255 updatehddgraph
("hdc","month");
1256 updatehddgraph
("hdc","year");
1258 if (-e
"$graphs/hddtemp-hdc-day.png") {
1259 system("rm $graphs/hddtemp-hdc-day.png");
1263 if (open STAT
,"/dev/hdd") {
1265 updatehdddata
("hdd");
1266 updatehddgraph
("hdd","day");
1267 updatehddgraph
("hdd","week");
1268 updatehddgraph
("hdd","month");
1269 updatehddgraph
("hdd","year");
1271 if (-e
"$graphs/hddtemp-hdd-day.png") {
1272 system("rm $graphs/hddtemp-hdd-day.png");
1276 if (open STAT
,"/dev/hde") {
1278 updatehdddata
("hde");
1279 updatehddgraph
("hde","day");
1280 updatehddgraph
("hde","week");
1281 updatehddgraph
("hde","month");
1282 updatehddgraph
("hde","year");
1284 if (-e
"$graphs/hddtemp-hde-day.png") {
1285 system("rm $graphs/hddtemp-hde-day.png");
1289 if (open STAT
,"/dev/hdf") {
1291 updatehdddata
("hdf");
1292 updatehddgraph
("hdf","day");
1293 updatehddgraph
("hdf","week");
1294 updatehddgraph
("hdf","month");
1295 updatehddgraph
("hdf","year");
1297 if (-e
"$graphs/hddtemp-hdf-day.png") {
1298 system("rm $graphs/hddtemp-hdf-day.png");
1302 if (open STAT
,"/dev/hdg") {
1304 updatehdddata
("hdg");
1305 updatehddgraph
("hdg","day");
1306 updatehddgraph
("hdg","week");
1307 updatehddgraph
("hdg","month");
1308 updatehddgraph
("hdg","year");
1310 if (-e
"$graphs/hddtemp-hdg-day.png") {
1311 system("rm $graphs/hddtemp-hdg-day.png");
1315 if (open STAT
,"/dev/hdh") {
1317 updatehdddata
("hdh");
1318 updatehddgraph
("hdh","day");
1319 updatehddgraph
("hdh","week");
1320 updatehddgraph
("hdh","month");
1321 updatehddgraph
("hdh","year");
1323 if (-e
"$graphs/hddtemp-hdh-day.png") {
1324 system("rm $graphs/hddtemp-hdh-day.png");
1330 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1332 updatetempgraph
("day");
1333 updatetempgraph
("week");
1334 updatetempgraph
("month");
1335 updatetempgraph
("year");
1337 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1339 updatefangraph
("day");
1340 updatefangraph
("week");
1341 updatefangraph
("month");
1342 updatefangraph
("year");
1344 if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
1346 updatevoltgraph
("day");
1347 updatevoltgraph
("week");
1348 updatevoltgraph
("month");
1349 updatevoltgraph
("year");
1355 @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`;
1357 updateifdata
("GREEN");
1358 updateifdata
("RED");
1359 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ ) {
1360 updateifdata
("ORANGE");
1362 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ ) {
1363 updateifdata
("BLUE");
1366 if ( -e
"$rrdlog/GREEN.rrd") {
1367 updateifgraph
("GREEN", "day");
1368 updateifgraph
("GREEN", "week");
1369 updateifgraph
("GREEN", "month");
1370 updateifgraph
("GREEN", "year");
1373 if ( -e
"$rrdlog/RED.rrd") {
1374 updateifgraph
("RED", "day");
1375 updateifgraph
("RED", "week");
1376 updateifgraph
("RED", "month");
1377 updateifgraph
("RED", "year");
1380 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ && -e
"$rrdlog/ORANGE.rrd") {
1381 updateifgraph
("ORANGE", "day");
1382 updateifgraph
("ORANGE", "week");
1383 updateifgraph
("ORANGE", "month");
1384 updateifgraph
("ORANGE", "year");
1387 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ && -e
"$rrdlog/BLUE.rrd") {
1388 updateifgraph
("BLUE", "day");
1389 updateifgraph
("BLUE", "week");
1390 updateifgraph
("BLUE", "month");
1391 updateifgraph
("BLUE", "year");
1394 system("chmod -R 0777 /srv/web/ipfire/html/graphs");
1395 system("chmod -R 0777 /srv/web/ipfire/html/sgraph");