]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/makegraphs
3626c184cf832b4ba265d7a838d4e8b8e0ba5cb8
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 my %mainsettings = ();
74 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
75 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
77 open(MBMON_OUT
, ">/var/log/mbmon-values");
78 open(FD
, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ;
82 next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ;
86 $mbmon_values{$key} = $value;
87 print(MBMON_OUT
"$key=$value\n");
93 my $interface = $_[0];
101 $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/);
103 # Forwarded Incoming...
104 $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/);
107 $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/);
109 # Forwarded Outgoing...
110 $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/);
112 return "$bytesin:$bytesout";
118 RRDs
::graph
("$graphs/cpu-$period.png",
119 "--start", "-1$period", "-aPNG", "-i", "-z",
120 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
121 "--color", "SHADEA".$color{"color19"},
122 "--color", "SHADEB".$color{"color19"},
123 "--color", "BACK".$color{"color21"},
124 "-t $tr{'cpu usage per'} $tr{$period}",
125 "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE",
126 "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE",
127 "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE",
128 "CDEF:total=user,system,idle,+,+",
129 "CDEF:userpct=100,user,total,/,*",
130 "CDEF:systempct=100,system,total,/,*",
131 "CDEF:idlepct=100,idle,total,/,*",
132 "AREA:userpct".$color{"color11"}.":$tr{'user cpu usage'}",
133 "STACK:systempct".$color{"color13"}.":$tr{'system cpu usage'}",
134 "STACK:idlepct".$color{"color12"}.":$tr{'idle cpu usage'}\\j",
136 "COMMENT:$tr{'maximal'}",
137 "COMMENT:$tr{'average'}",
138 "COMMENT:$tr{'current'}\\j",
139 "GPRINT:userpct:MAX:$tr{'user cpu'}\\:%3.2lf%%",
140 "GPRINT:userpct:AVERAGE:$tr{'user cpu'}\\:%3.2lf%%",
141 "GPRINT:userpct:LAST:$tr{'user cpu'}\\:%3.2lf%%\\j",
142 "GPRINT:systempct:MAX:$tr{'system cpu'}\\:%3.2lf%%",
143 "GPRINT:systempct:AVERAGE:$tr{'system cpu'}\\:%3.2lf%%",
144 "GPRINT:systempct:LAST:$tr{'system cpu'}\\:%3.2lf%%\\j",
145 "GPRINT:idlepct:MAX:$tr{'idle cpu'}\\:%3.2lf%%",
146 "GPRINT:idlepct:AVERAGE:$tr{'idle cpu'}\\:%3.2lf%%",
147 "GPRINT:idlepct:LAST:$tr{'idle cpu'}\\:%3.2lf%%\\j");
148 $ERROR = RRDs
::error
;
149 print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
153 if ( ! -e
"$rrdlog/cpu.rrd") {
154 RRDs
::create
("$rrdlog/cpu.rrd", "--step=300",
155 "DS:user:COUNTER:600:0:500000000",
156 "DS:system:COUNTER:600:0:500000000",
157 "DS:idle:COUNTER:600:0:500000000",
158 "RRA:AVERAGE:0.5:1:576",
159 "RRA:AVERAGE:0.5:6:672",
160 "RRA:AVERAGE:0.5:24:732",
161 "RRA:AVERAGE:0.5:144:1460");
162 $ERROR = RRDs
::error
;
163 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
166 my ($cpu, $user, $nice, $system, $idle);
168 open STAT
, "/proc/stat";
172 ($cpu, $user, $nice, $system, $idle) = split /\s+/;
178 RRDs
::update
("$rrdlog/cpu.rrd",
179 "-t", "user:system:idle",
180 "N:$user:$system:$idle");
181 $ERROR = RRDs
::error
;
182 print "Error in RRD::update for cpu: $ERROR\n" if $ERROR;
186 sub updateloadgraph
{
189 RRDs
::graph
("$graphs/load-$period.png",
190 "--start", "-1$period", "-aPNG",
191 "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid",
193 "--color", "SHADEA".$color{"color19"},
194 "--color", "SHADEB".$color{"color19"},
195 "--color", "BACK".$color{"color21"},
196 "DEF:load1=$rrdlog/load.rrd:load1:AVERAGE",
197 "DEF:load5=$rrdlog/load.rrd:load5:AVERAGE",
198 "DEF:load15=$rrdlog/load.rrd:load15:AVERAGE",
199 "AREA:load1".$color{"color13"}.":1 Minute, letzter:",
200 "GPRINT:load1:LAST:%5.2lf",
201 "AREA:load5".$color{"color18"}.":5 Minuten, letzter:",
202 "GPRINT:load5:LAST:%5.2lf",
203 "AREA:load15".$color{"color14"}.":15 Minuten, letzter:",
204 "GPRINT:load15:LAST:%5.2lf\\j",
205 "LINE1:load5".$color{"color13"},
206 "LINE1:load1".$color{"color18"});
207 $ERROR = RRDs
::error
;
208 print "Error in RRD::graph for load: $ERROR\n" if $ERROR;
212 if ( ! -e
"$rrdlog/load.rrd") {
213 RRDs
::create
("$rrdlog/load.rrd", "--step=60",
214 "DS:load1:GAUGE:120:0:U",
215 "DS:load5:GAUGE:120:0:U",
216 "DS:load15:GAUGE:120:0:U",
217 "RRA:AVERAGE:0.5:1:2160",
218 "RRA:AVERAGE:0.5:5:2016",
219 "RRA:AVERAGE:0.5:15:2880",
220 "RRA:AVERAGE:0.5:60:8760");
222 $ERROR = RRDs
::error
;
223 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
230 RRDs
::graph
("$graphs/memory-$period.png",
231 "--start", "-1$period", "-aPNG", "-i", "-z",
232 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
233 "--color", "SHADEA".$color{"color19"},
234 "--color", "SHADEB".$color{"color19"},
235 "--color", "BACK".$color{"color21"},
236 "-t $tr{'memory usage per'} $tr{$period}",
237 "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE",
238 "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE",
239 "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE",
240 "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE",
241 "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE",
242 "CDEF:total=used,free,+",
243 "CDEF:used2=used,buffer,cache,shared,+,+,-",
244 "CDEF:usedpct=100,used2,total,/,*",
245 "CDEF:sharedpct=100,shared,total,/,*",
246 "CDEF:bufferpct=100,buffer,total,/,*",
247 "CDEF:cachepct=100,cache,total,/,*",
248 "CDEF:freepct=100,free,total,/,*",
249 "AREA:usedpct".$color{"color11"}.":$tr{'used memory'}",
250 "STACK:sharedpct".$color{"color13"}.":$tr{'shared memory'}",
251 "STACK:bufferpct".$color{"color23"}.":$tr{'buffered memory'}",
252 "STACK:cachepct".$color{"color14"}.":$tr{'cached memory'}",
253 "STACK:freepct".$color{"color12"}.":$tr{'free memory'}\\j",
255 "COMMENT:$tr{'maximal'}",
256 "COMMENT:$tr{'average'}",
257 "COMMENT:$tr{'current'}\\j",
258 "GPRINT:usedpct:MAX:$tr{'used memory'}\\:%3.2lf%%",
259 "GPRINT:usedpct:AVERAGE:$tr{'used memory'}\\:%3.2lf%%",
260 "GPRINT:usedpct:LAST:$tr{'used memory'}\\:%3.2lf%%\\j",
261 "GPRINT:sharedpct:MAX:$tr{'shared memory'}\\:%3.2lf%%",
262 "GPRINT:sharedpct:AVERAGE:$tr{'shared memory'}\\:%3.2lf%%",
263 "GPRINT:sharedpct:LAST:$tr{'shared memory'}\\:%3.2lf%%\\j",
264 "GPRINT:bufferpct:MAX:$tr{'buffered memory'}\\:%3.2lf%%",
265 "GPRINT:bufferpct:AVERAGE:$tr{'buffered memory'}\\:%3.2lf%%",
266 "GPRINT:bufferpct:LAST:$tr{'buffered memory'}\\:%3.2lf%%\\j",
267 "GPRINT:cachepct:MAX:$tr{'cached memory'}\\:%3.2lf%%",
268 "GPRINT:cachepct:AVERAGE:$tr{'cached memory'}\\:%3.2lf%%",
269 "GPRINT:cachepct:LAST:$tr{'cached memory'}\\:%3.2lf%%\\j",
270 "GPRINT:freepct:MAX:$tr{'free memory'}\\:%3.2lf%%",
271 "GPRINT:freepct:AVERAGE:$tr{'free memory'}\\:%3.2lf%%",
272 "GPRINT:freepct:LAST:$tr{'free memory'}\\:%3.2lf%%\\j");
273 $ERROR = RRDs
::error
;
274 print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
276 RRDs
::graph
("$graphs/swap-$period.png",
277 "--start", "-1$period", "-aPNG", "-i", "-z",
278 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
279 "--color", "SHADEA".$color{"color19"},
280 "--color", "SHADEB".$color{"color19"},
281 "--color", "BACK".$color{"color21"},
282 "-t $tr{'swap usage per'} $tr{$period}",
283 "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE",
284 "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE",
285 "CDEF:total=used,free,+",
286 "CDEF:usedpct=100,used,total,/,*",
287 "CDEF:freepct=100,free,total,/,*",
288 "AREA:usedpct".$color{"color11"}.":$tr{'used swap'}",
289 "STACK:freepct".$color{"color12"}.":$tr{'free swap'}\\j",
291 "COMMENT:$tr{'maximal'}",
292 "COMMENT:$tr{'average'}",
293 "COMMENT:$tr{'current'}\\j",
294 "GPRINT:usedpct:MAX:$tr{'used swap'}\\:%3.2lf%%",
295 "GPRINT:usedpct:AVERAGE:$tr{'used swap'}\\:%3.2lf%%",
296 "GPRINT:usedpct:LAST:$tr{'used swap'}\\:%3.2lf%%\\j",
297 "GPRINT:freepct:MAX:$tr{'free swap'}\\:%3.2lf%%",
298 "GPRINT:freepct:AVERAGE:$tr{'free swap'}\\:%3.2lf%%",
299 "GPRINT:freepct:LAST:$tr{'free swap'}\\:%3.2lf%%\\j");
300 $ERROR = RRDs
::error
;
301 print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
305 my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree, $swaptotal);
306 if ( ! -e
"$rrdlog/mem.rrd") {
307 RRDs
::create
("$rrdlog/mem.rrd", "--step=300",
308 "DS:memused:ABSOLUTE:600:0:5000000000",
309 "DS:memfree:ABSOLUTE:600:0:5000000000",
310 "DS:memshared:ABSOLUTE:600:0:5000000000",
311 "DS:membuffers:ABSOLUTE:600:0:5000000000",
312 "DS:memcache:ABSOLUTE:600:0:5000000000",
313 "DS:swapused:ABSOLUTE:600:0:5000000000",
314 "DS:swapfree:ABSOLUTE:600:0:5000000000",
315 "RRA:AVERAGE:0.5:1:576",
316 "RRA:AVERAGE:0.5:6:672",
317 "RRA:AVERAGE:0.5:24:732",
318 "RRA:AVERAGE:0.5:144:1460");
319 $ERROR = RRDs
::error
;
320 print "Error in RRD::create for mem: $ERROR\n" if $ERROR;
323 open MEM
, "/proc/meminfo";
326 if ($_ =~ /^MemTotal:/) {
327 my @temp = split (/\s+/, $_);
329 } elsif ($_ =~ /^MemFree:/) {
330 my @temp = split (/\s+/, $_);
332 } elsif ($_ =~ /^Cached:/) {
333 my @temp = split (/\s+/, $_);
334 $memcache = $temp[1];
335 } elsif ($_ =~ /^Buffers:/) {
336 my @temp = split (/\s+/, $_);
337 $membuffers = $temp[1];
338 } elsif ($_ =~ /^SwapTotal:/) {
339 my @temp = split (/\s+/, $_);
340 $swaptotal = $temp[1];
341 } elsif ($_ =~ /^SwapFree:/) {
342 my @temp = split (/\s+/, $_);
343 $swapfree = $temp[1];
348 system("/bin/df > /tmp/diskfree");
349 open DF
, "/tmp/diskfree";
353 my @temp = split (/\s+/, $_);
354 $memshared = $temp[2];
358 system("/bin/rm -f /tmp/diskfree");
360 $swapused = $swaptotal-$swapfree;
361 RRDs
::update
("$rrdlog/mem.rrd",
362 "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree",
363 "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree");
364 $ERROR = RRDs
::error
;
365 print "Error in RRD::update for mem: $ERROR\n" if $ERROR;
368 sub updatediskgraph
{
371 RRDs
::graph
("$graphs/disk-$period.png",
372 "--start", "-1$period", "-aPNG", "-i", "-z",
373 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
374 "--color", "SHADEA".$color{"color19"},
375 "--color", "SHADEB".$color{"color19"},
376 "--color", "BACK".$color{"color21"},
377 "-t $tr{'disk access per'} $tr{$period}",
378 "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE",
379 "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE",
380 "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}",
381 "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j",
383 "COMMENT:$tr{'maximal'}",
384 "COMMENT:$tr{'average'}",
385 "COMMENT:$tr{'current'}\\j",
386 "GPRINT:read:MAX:$tr{'read sectors'}\\:%8.0lf",
387 "GPRINT:read:AVERAGE:$tr{'read sectors'}\\:%8.0lf",
388 "GPRINT:read:LAST:$tr{'read sectors'}\\:%8.0lf\\j",
389 "GPRINT:write:MAX:$tr{'written sectors'}\\:%8.0lf",
390 "GPRINT:write:AVERAGE:$tr{'written sectors'}\\:%8.0lf",
391 "GPRINT:write:LAST:$tr{'written sectors'}\\:%8.0lf\\j");
392 $ERROR = RRDs
::error
;
393 print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
397 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
398 if ( ! -e
"$rrdlog/disk.rrd") {
399 RRDs
::create
("$rrdlog/disk.rrd", "--step=300",
400 "DS:readsect:COUNTER:600:0:5000000000",
401 "DS:writesect:COUNTER:600:0:5000000000",
402 "RRA:AVERAGE:0.5:1:576",
403 "RRA:AVERAGE:0.5:6:672",
404 "RRA:AVERAGE:0.5:24:732",
405 "RRA:AVERAGE:0.5:144:1460");
406 $ERROR = RRDs
::error
;
407 print "Error in RRD::create for disk: $ERROR\n" if $ERROR;
410 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
411 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk");
413 my $major = $rdev >> 8;
414 my $minor = $rdev & 0xFF;
416 open STAT
, "/proc/stat";
417 my @diskstat = <STAT
>;
419 foreach my $line (@diskstat)
422 my @temp = split(/\:\ /,$line);
424 my @devicestat = split(/\ /,$temp[1]);
425 foreach my $stats (@devicestat)
428 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
429 if ($major eq $fields[1] and $minor eq $fields[2])
431 $readwritereq = $fields[3];
432 $readreq = $fields[4];
433 $readsect = $fields[5];
434 $writereq = $fields[6];
435 $writesect = $fields[7];
441 if ($readsect && $writesect) {
442 RRDs
::update
("$rrdlog/disk.rrd",
443 "-t", "readsect:writesect",
444 "N:$readsect:$writesect");
445 $ERROR = RRDs
::error
;
446 print "Error in RRD::update for disk: $ERROR\n" if $ERROR;
448 print "Error in RRD::update for disk: no data available\n";
452 sub updatediskgraphnew
{
456 RRDs
::graph
("$graphs/disk-$disk-$period.png",
457 "--start", "-1$period", "-aPNG", "-i", "-z",
458 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
459 "--color", "SHADEA".$color{"color19"},
460 "--color", "SHADEB".$color{"color19"},
461 "--color", "BACK".$color{"color21"},
462 "-t $tr{'disk access per'} $tr{$period}",
463 "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
464 "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
465 "DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE",
466 "CDEF:sl_state=sleep,INF,*",
468 "AREA:sl_state#a0a0a0:disk standby\\j",
469 "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}",
470 "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j",
472 "COMMENT:$tr{'maximal'}",
473 "COMMENT:$tr{'average'}",
474 "COMMENT:$tr{'current'}\\j",
475 "GPRINT:read:MAX:$tr{'read sectors'}\\:%8.0lf",
476 "GPRINT:read:AVERAGE:$tr{'read sectors'}\\:%8.0lf",
477 "GPRINT:read:LAST:$tr{'read sectors'}\\:%8.0lf\\j",
478 "GPRINT:write:MAX:$tr{'written sectors'}\\:%8.0lf",
479 "GPRINT:write:AVERAGE:$tr{'written sectors'}\\:%8.0lf",
480 "GPRINT:write:LAST:$tr{'written sectors'}\\:%8.0lf\\j");
481 $ERROR = RRDs
::error
;
482 print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR;
485 sub updatediskdatanew
{
488 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
489 if ( ! -e
"$rrdlog/disk-$disk.rrd") {
490 RRDs
::create
("$rrdlog/disk-$disk.rrd", "--step=300",
491 "DS:readsect:COUNTER:600:0:5000000000",
492 "DS:writesect:COUNTER:600:0:5000000000",
493 "DS:sleeping:GAUGE:600:0:1",
494 "RRA:AVERAGE:0.5:1:576",
495 "RRA:AVERAGE:0.5:6:672",
496 "RRA:AVERAGE:0.5:24:732",
497 "RRA:AVERAGE:0.5:144:1460");
498 $ERROR = RRDs
::error
;
499 print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR;
502 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
503 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk");
505 print "\n\n$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks\n\n";
507 my $major = $rdev >> 8;
508 my $minor = ($rdev & 0xFF) >>6;
510 open STAT
, "/proc/stat";
511 my @diskstat = <STAT
>;
513 foreach my $line (@diskstat)
516 my @temp = split(/\:\ /,$line);
518 my @devicestat = split(/\ /,$temp[1]);
519 foreach my $stats (@devicestat)
522 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
523 if ($major eq $fields[1] and $minor eq $fields[2])
525 $readwritereq = $fields[3];
526 $readreq = $fields[4];
527 $readsect = $fields[5];
528 $writereq = $fields[6];
529 $writesect = $fields[7];
536 my $lastsleepstate=0;
538 if ( -e
"/tmp/hddshutdown-$disk" ) {
539 open STAT
,"/tmp/hddshutdown-$disk";
540 $lastsleepstate = <STAT
>;
542 if ($lastsleepstate==$readwritereq) {
547 if ($readsect && $writesect) {
548 RRDs
::update
("$rrdlog/disk-$disk.rrd",
549 "-t", "readsect:writesect:sleeping",
550 "N:$readsect:$writesect:$sleeping");
551 $ERROR = RRDs
::error
;
552 print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR;
554 print "Error in RRD::update for disk-$disk: no data available\n";
559 my $interface = $_[0];
562 RRDs
::graph
("$graphs/$interface-$period.png",
563 "--start", "-1$period", "-aPNG", "-i", "-z",
564 "--alt-y-grid", "-w 600", "-h 100",
565 "--color", "SHADEA".$color{"color19"},
566 "--color", "SHADEB".$color{"color19"},
567 "--color", "BACK".$color{"color21"},
568 "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})",
569 "-v$tr{'bytes per second'}",
570 "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE",
571 "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE",
572 "AREA:incoming".$color{"color11"}.":$tr{'incoming traffic in bytes per second'}",
573 "LINE1:outgoing".$color{"color12"}.":$tr{'outgoing traffic in bytes per second'}\\j",
575 "COMMENT:$tr{'maximal'}",
576 "COMMENT:$tr{'average'}",
577 "COMMENT:$tr{'current'}\\j",
578 "GPRINT:incoming:MAX:$tr{'in'}\\:%8.3lf %sBps",
579 "GPRINT:incoming:AVERAGE:$tr{'in'}\\:%8.3lf %sBps",
580 "GPRINT:incoming:LAST:$tr{'in'}\\:%8.3lf %sBps\\j",
581 "GPRINT:outgoing:MAX:$tr{'out'}\\:%8.3lf %sBps",
582 "GPRINT:outgoing:AVERAGE:$tr{'out'}\\:%8.3lf %sBps",
583 "GPRINT:outgoing:LAST:$tr{'out'}\\:%8.3lf %sBps\\j");
584 $ERROR = RRDs
::error
;
585 print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
589 my $interface = $_[0];
591 if ( ! -e
"$rrdlog/$interface.rrd") {
592 RRDs
::create
("$rrdlog/$interface.rrd", "--step=300",
593 "DS:incoming:ABSOLUTE:600:0:12500000",
594 "DS:outgoing:ABSOLUTE:600:0:12500000",
595 "RRA:AVERAGE:0.5:1:576",
596 "RRA:AVERAGE:0.5:6:672",
597 "RRA:AVERAGE:0.5:24:732",
598 "RRA:AVERAGE:0.5:144:1460");
599 $ERROR = RRDs
::error
;
600 print "Error in RRD::create for $interface: $ERROR\n" if $ERROR;
603 my $traffic = gettraffic
($interface);
604 RRDs
::update
("$rrdlog/$interface.rrd",
605 "-t", "incoming:outgoing",
607 $ERROR = RRDs
::error
;
608 print "Error in RRD::update for $interface: $ERROR\n" if $ERROR;
611 sub updatefwhitsgraph
{
612 my $interval = $_[0];
614 RRDs
::graph
("$graphs/firewallhits-$interval-area.png",
615 "--start", "-1$interval", "-aPNG", "-i", "-z",
616 "--alt-y-grid", "-w 600", "-h 200",
617 "--color", "SHADEA".$color{"color19"},
618 "--color", "SHADEB".$color{"color19"},
619 "--color", "BACK".$color{"color21"},
620 "-t firewall hits over the last $interval",
621 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
622 "AREA:amount".$color{"color24"}.":firewallhits",
623 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
624 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
625 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
626 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
627 "AREA:portamount".$color{"color25"}.":portscans",
628 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
629 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
630 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
631 $ERROR = RRDs
::error
;
632 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
634 RRDs
::graph
("$graphs/firewallhits-$interval-line.png",
635 "--start", "-1$interval", "-aPNG", "-i", "-z",
636 "--alt-y-grid", "-w 600", "-h 200",
637 "--color", "SHADEA".$color{"color19"},
638 "--color", "SHADEB".$color{"color19"},
639 "--color", "BACK".$color{"color21"},
640 "-t firewall hits over the last $interval",
641 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
642 "LINE2:amount".$color{"color24"}.":firewallhits",
643 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
644 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
645 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
646 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
647 "LINE2:portamount".$color{"color25"}.":portscans",
648 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
649 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
650 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
651 $ERROR = RRDs
::error
;
652 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
655 sub updatefwhitsdata
{
662 if (! -e
"$rrdlog/firewallhits.rrd")
664 RRDs
::create
("$rrdlog/firewallhits.rrd", "--step=300",
665 "DS:amount:GAUGE:600:0:U",
666 "DS:portamount:GAUGE:600:0:U",
667 "RRA:AVERAGE:0.5:1:576",
668 "RRA:AVERAGE:0.5:6:672",
669 "RRA:AVERAGE:0.5:24:732",
670 "RRA:AVERAGE:0.5:144:1460");
671 $ERROR = RRDs
::error
;
672 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
675 system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits");
676 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
682 if (/kernel:.*(IN=.*)$/) {
689 system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits");
690 if (!(open (FILE
,'/tmp/snort.fwhits'))) {
703 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
709 if (/kernel:.*(Scan.*)$/) {
716 system("rm /tmp/messages.fwhits");
717 system("rm /tmp/snort.fwhits");
719 $portamount = $portaktuell + $alertaktuell;
721 RRDs
::update
("$rrdlog/firewallhits.rrd",
722 "N:$aktuell:$portamount");
723 $ERROR = RRDs
::error
;
724 print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR;
727 # Creates and updates a link quality database
728 # -------------------------------------------
730 if ( ! -e
"$rrdlog/lq.rrd") {
731 RRDs
::create
("$rrdlog/lq.rrd", "--step=300",
732 "DS:loss:GAUGE:600:0:100",
733 "DS:roundtrip:GAUGE:600:0:10000",
734 "RRA:AVERAGE:0.5:1:576",
735 "RRA:AVERAGE:0.5:6:672",
736 "RRA:AVERAGE:0.5:24:732",
737 "RRA:AVERAGE:0.5:144:1460");
738 $ERROR = RRDs
::error
;
739 print "Error in RRD::create for link: $ERROR\n" if $ERROR;
744 # LQ_GATEWAY is the ip of your isp's public ip facing you
745 my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`;
747 my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`;
749 my @temp = split (/\/|\
%|\s
/, $pingoutput);
750 $packetloss = $temp[17];
751 $roundtrip = $temp[28];
752 RRDs
::update
("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip");
753 $ERROR = RRDs
::error
;
754 print "Error in RRD::update for line quality: $ERROR\n" if $ERROR;
759 RRDs
::graph
("$graphs/lq-$period.png",
760 "--start", "-1$period", "-aPNG", "-i", "-z",
761 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
762 "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})",
764 "--color", "SHADEA".$color{"color19"},
765 "--color", "SHADEB".$color{"color19"},
766 "--color", "BACK".$color{"color21"},
767 "-v ms / pkts (% x10)",
768 "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE",
769 "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE",
770 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
771 "CDEF:loss10=loss,10,*",
772 "CDEF:r0=roundtrip,30,MIN",
773 "CDEF:r1=roundtrip,70,MIN",
774 "CDEF:r2=roundtrip,150,MIN",
775 "CDEF:r3=roundtrip,300,MIN",
776 "AREA:roundtrip".$color{"color25"}.":>300 ms",
777 "AREA:r3".$color{"color18"}.":150-300 ms",
778 "AREA:r2".$color{"color14"}.":70-150 ms",
779 "AREA:r1".$color{"color17"}.":30-70 ms",
780 "AREA:r0".$color{"color12"}.":<30 ms",
781 "AREA:loss10".$color{"color13"}.":Packet loss (x10)",
782 "LINE1:roundtrip#707070:",
783 "GPRINT:roundtrip:MAX:$tr{'maximal'}\\:%3.2lf ms",
784 "GPRINT:roundtrip:AVERAGE:$tr{'average'}\\:%3.2lf ms",
785 "GPRINT:roundtrip:LAST:$tr{'current'}\\:%3.2lf ms\\j",
786 "GPRINT:loss:MAX:$tr{'maximal'} Loss\\:%3.2lf%%",
787 "GPRINT:loss:AVERAGE:$tr{'average'} Loss\\:%3.2lf%%",
788 "GPRINT:loss:LAST:$tr{'current'} Loss\\:%3.2lf%%\\j"
790 $ERROR = RRDs
::error
;
791 print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
797 if ( ! -e
"$rrdlog/hddtemp-$disk.rrd")
799 # database did not exist -> create
800 RRDs
::create
("$rrdlog/hddtemp-$disk.rrd", "--step=300",
801 "DS:temperature:GAUGE:600:0:100",
802 "RRA:AVERAGE:0.5:1:576",
803 "RRA:AVERAGE:0.5:6:672",
804 "RRA:AVERAGE:0.5:24:732",
805 "RRA:AVERAGE:0.5:144:1460");
806 $ERROR = RRDs
::error
;
807 print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR;
812 my $smart_output = '';
814 if ( -e
"$path_smartctl" )
816 system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
819 if ( -e
"$path_hddtemp" )
821 $hdd_output = `$path_hddtemp -qn /dev/$disk`;
823 # I know 4 response possible responses:
825 # /dev/harddisk: harddisk type: S.M.A.R.T. not available
826 # /dev/harddisk: harddisk type: no sensor
827 # /dev/harddisk: harddisk type: 37°C or °F
830 if ( index($hdd_output, "S.M.A.R.T.") != -1 )
834 elsif ( index($hdd_output, "no sensor") != -1 )
838 elsif ( index($hdd_output, "$disk") != -1 )
840 $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
845 $hdd_output =~ /(\d+)\s/;
849 elsif ( -e
"/var/log/smartctl_out_hddtemp-$disk" )
851 $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`;
852 my @t = split(/\s+/,$hdd_output);
860 # print "hdd $hdd_output \n";
861 # print "temp $temp \n";
863 RRDs
::update
("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
865 $ERROR = RRDs
::error
;
866 print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
873 RRDs
::graph
("$graphs/hddtemp-$disk-$period.png",
874 "--start", "-1$period", "-aPNG", "-i", "-z",
875 "--alt-y-grid", "-w 600", "-h 100",
876 "--color", "SHADEA".$color{"color19"},
877 "--color", "SHADEB".$color{"color19"},
878 "--color", "BACK".$color{"color21"},
879 "-t $tr{'harddisk temperature'} ($tr{'graph per'} $tr{$period})",
880 "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
881 "LINE2:temperature".$color{"color11"}.":$tr{'hdd temperature in'} °C",
882 "GPRINT:temperature:MAX:$tr{'maximal'}\\:%3.0lf °C",
883 "GPRINT:temperature:AVERAGE:$tr{'average'}\\:%3.0lf °C",
884 "GPRINT:temperature:LAST:$tr{'current'}\\:%3.0lf °C",
886 $ERROR = RRDs
::error
;
887 print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;
892 if ( ! -e
"$rrdlog/mbmon.rrd" )
894 # database did not exist -> create
896 @args = ("$rrdlog/mbmon.rrd");
898 push(@args, "--step=300");
899 foreach $key ( sort(keys %mbmon_values) )
901 push(@args, "DS:$key:GAUGE:600:U:U");
903 push(@args, "RRA:AVERAGE:0.5:1:576");
904 push(@args, "RRA:AVERAGE:0.5:6:672");
905 push(@args, "RRA:AVERAGE:0.5:24:732");
906 push(@args, "RRA:AVERAGE:0.5:144:1460");
908 print("create ". join( ", ", @args)) if ( $dbg );
910 RRDs
::create
(@args);
911 $ERROR = RRDs
::error
;
912 print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
919 foreach $key ( sort(keys %mbmon_values) )
922 push(@val, $mbmon_values{$key});
925 $template = join(':', @ds);
926 $value = "N:".join(':', @val);
928 print("update template = '$template'\n") if ( $dbg );
929 print("update value = '$value'\n") if ( $dbg );
931 RRDs
::update
("$rrdlog/mbmon.rrd", "-t", $template, $value);
932 $ERROR = RRDs
::error
;
933 print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
941 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
942 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
943 "--color", "SHADEA".$color{"color19"},
944 "--color", "SHADEB".$color{"color19"},
945 "--color", "BACK".$color{"color21"},
946 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
949 foreach $key ( sort(keys %mbmon_values) )
951 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
953 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
955 $mbmon_settings{'LABEL-'.$key} = $key;
958 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
959 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C");
960 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C");
961 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C");
962 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j");
970 RRDs
::graph
( @args );
971 $ERROR = RRDs
::error
;
972 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
981 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
982 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
983 "--color", "SHADEA".$color{"color19"},
984 "--color", "SHADEB".$color{"color19"},
985 "--color", "BACK".$color{"color21"},
986 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
989 foreach $key ( sort(keys %mbmon_values) )
991 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
993 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
995 $mbmon_settings{'LABEL-'.$key} = $key;
998 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
999 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm");
1000 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm");
1001 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm");
1002 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j");
1010 RRDs
::graph
( @args );
1011 $ERROR = RRDs
::error
;
1012 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
1021 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
1022 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
1023 "--color", "SHADEA".$color{"color19"},
1024 "--color", "SHADEB".$color{"color19"},
1025 "--color", "BACK".$color{"color21"},
1026 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
1029 foreach $key ( sort(keys %mbmon_values) )
1031 my $v = substr($key,0,1);
1032 if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') )
1034 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
1036 $mbmon_settings{'LABEL-'.$key} = $key;
1039 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
1040 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} V");
1041 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V");
1042 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V");
1043 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j");
1051 RRDs
::graph
( @args );
1052 $ERROR = RRDs
::error
;
1053 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
1058 system ('/usr/sbin/fetchipac');
1064 if ( -e
"/var/log/squid/access.log") {
1065 system ("/usr/bin/squid-graph -o=/srv/web/ipfire/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1");
1071 if ((${Lang
::language
} eq 'cs') ||
1072 (${Lang
::language
} eq 'hu') ||
1073 (${Lang
::language
} eq 'pl') ||
1074 (${Lang
::language
} eq 'sk')) {
1075 # Czech, Hungarian, Polish and Slovak character set
1076 foreach my $key(keys %Lang::tr
) {
1077 from_to
($tr{$key}, "utf-8", "iso-8859-2");
1079 } elsif (${Lang
::language
} eq 'tr') {
1081 foreach my $key(keys %Lang::tr
) {
1082 from_to
($tr{$key}, "utf-8", "iso-8859-9");
1085 foreach my $key(keys %Lang::tr
) {
1086 from_to
($tr{$key}, "utf-8", "iso-8859-1");
1094 updatecpugraph
("day");
1095 updatecpugraph
("week");
1096 updatecpugraph
("month");
1097 updatecpugraph
("year");
1100 updateloadgraph
("day");
1101 updateloadgraph
("week");
1102 updateloadgraph
("month");
1103 updateloadgraph
("year");
1106 updatememgraph
("day");
1107 updatememgraph
("week");
1108 updatememgraph
("month");
1109 updatememgraph
("year");
1112 updatediskgraph
("day");
1113 updatediskgraph
("week");
1114 updatediskgraph
("month");
1115 updatediskgraph
("year");
1117 if (open STAT
,"/dev/hda") {
1119 updatediskdatanew
("hda");
1120 updatediskgraphnew
("hda","day");
1121 updatediskgraphnew
("hda","week");
1122 updatediskgraphnew
("hda","month");
1123 updatediskgraphnew
("hda","year");
1125 if (-e
"$graphs/disk-hda-day.png") {
1126 system("rm $graphs/disk-hda-day.png");
1130 if (open STAT
,"/dev/hdb") {
1132 updatediskdatanew
("hdb");
1133 updatediskgraphnew
("hdb","day");
1134 updatediskgraphnew
("hdb","week");
1135 updatediskgraphnew
("hdb","month");
1136 updatediskgraphnew
("hdb","year");
1138 if (-e
"$graphs/disk-hdb-day.png") {
1139 system("rm $graphs/disk-hdb-day.png");
1143 if (open STAT
,"/dev/hdc") {
1145 updatediskdatanew
("hdc");
1146 updatediskgraphnew
("hdc","day");
1147 updatediskgraphnew
("hdc","week");
1148 updatediskgraphnew
("hdc","month");
1149 updatediskgraphnew
("hdc","year");
1151 if (-e
"$graphs/disk-hdc-day.png") {
1152 system("rm $graphs/disk-hdc-day.png");
1156 if (open STAT
,"/dev/hdd") {
1158 updatediskdatanew
("hdd");
1159 updatediskgraphnew
("hdd","day");
1160 updatediskgraphnew
("hdd","week");
1161 updatediskgraphnew
("hdd","month");
1162 updatediskgraphnew
("hdd","year");
1164 if (-e
"$graphs/disk-hdd-day.png") {
1165 system("rm $graphs/disk-hdd-day.png");
1169 if (open STAT
,"/dev/hde") {
1171 updatediskdatanew
("hde");
1172 updatediskgraphnew
("hde","day");
1173 updatediskgraphnew
("hde","week");
1174 updatediskgraphnew
("hde","month");
1175 updatediskgraphnew
("hde","year");
1177 if (-e
"$graphs/disk-hde-day.png") {
1178 system("rm $graphs/disk-hde-day.png");
1182 if (open STAT
,"/dev/hdf") {
1184 updatediskdatanew
("hdf");
1185 updatediskgraphnew
("hdf","day");
1186 updatediskgraphnew
("hdf","week");
1187 updatediskgraphnew
("hdf","month");
1188 updatediskgraphnew
("hdf","year");
1190 if (-e
"$graphs/disk-hdf-day.png") {
1191 system("rm $graphs/disk-hdf-day.png");
1195 if (open STAT
,"/dev/hdg") {
1197 updatediskdatanew
("hdg");
1198 updatediskgraphnew
("hdg","day");
1199 updatediskgraphnew
("hdg","week");
1200 updatediskgraphnew
("hdg","month");
1201 updatediskgraphnew
("hdg","year");
1203 if (-e
"$graphs/disk-hdg-day.png") {
1204 system("rm $graphs/disk-hdg-day.png");
1208 if (open STAT
,"/dev/hdh") {
1210 updatediskdatanew
("hdh");
1211 updatediskgraphnew
("hdh","day");
1212 updatediskgraphnew
("hdh","week");
1213 updatediskgraphnew
("hdh","month");
1214 updatediskgraphnew
("hdh","year");
1216 if (-e
"$graphs/disk-hdh-day.png") {
1217 system("rm $graphs/disk-hdh-day.png");
1225 updatefwhitsgraph
("day");
1226 updatefwhitsgraph
("week");
1227 updatefwhitsgraph
("month");
1228 updatefwhitsgraph
("year");
1235 updatelqgraph
("day");
1236 updatelqgraph
("week");
1237 updatelqgraph
("month");
1238 updatelqgraph
("year");
1241 ### HDDTEMP-Graphs for /dev/harddisk
1243 if (open STAT
,"/dev/hda") {
1245 updatehdddata
("hda");
1246 updatehddgraph
("hda","day");
1247 updatehddgraph
("hda","week");
1248 updatehddgraph
("hda","month");
1249 updatehddgraph
("hda","year");
1251 if (-e
"$graphs/hddtemp-hda-day.png") {
1252 system("rm $graphs/hddtemp-hda-day.png");
1256 if (open STAT
,"/dev/hdb") {
1258 updatehdddata
("hdb");
1259 updatehddgraph
("hdb","day");
1260 updatehddgraph
("hdb","week");
1261 updatehddgraph
("hdb","month");
1262 updatehddgraph
("hdb","year");
1264 if (-e
"$graphs/hddtemp-hdb-day.png") {
1265 system("rm $graphs/hddtemp-hdb-day.png");
1269 if (open STAT
,"/dev/hdc") {
1271 updatehdddata
("hdc");
1272 updatehddgraph
("hdc","day");
1273 updatehddgraph
("hdc","week");
1274 updatehddgraph
("hdc","month");
1275 updatehddgraph
("hdc","year");
1277 if (-e
"$graphs/hddtemp-hdc-day.png") {
1278 system("rm $graphs/hddtemp-hdc-day.png");
1282 if (open STAT
,"/dev/hdd") {
1284 updatehdddata
("hdd");
1285 updatehddgraph
("hdd","day");
1286 updatehddgraph
("hdd","week");
1287 updatehddgraph
("hdd","month");
1288 updatehddgraph
("hdd","year");
1290 if (-e
"$graphs/hddtemp-hdd-day.png") {
1291 system("rm $graphs/hddtemp-hdd-day.png");
1295 if (open STAT
,"/dev/hde") {
1297 updatehdddata
("hde");
1298 updatehddgraph
("hde","day");
1299 updatehddgraph
("hde","week");
1300 updatehddgraph
("hde","month");
1301 updatehddgraph
("hde","year");
1303 if (-e
"$graphs/hddtemp-hde-day.png") {
1304 system("rm $graphs/hddtemp-hde-day.png");
1308 if (open STAT
,"/dev/hdf") {
1310 updatehdddata
("hdf");
1311 updatehddgraph
("hdf","day");
1312 updatehddgraph
("hdf","week");
1313 updatehddgraph
("hdf","month");
1314 updatehddgraph
("hdf","year");
1316 if (-e
"$graphs/hddtemp-hdf-day.png") {
1317 system("rm $graphs/hddtemp-hdf-day.png");
1321 if (open STAT
,"/dev/hdg") {
1323 updatehdddata
("hdg");
1324 updatehddgraph
("hdg","day");
1325 updatehddgraph
("hdg","week");
1326 updatehddgraph
("hdg","month");
1327 updatehddgraph
("hdg","year");
1329 if (-e
"$graphs/hddtemp-hdg-day.png") {
1330 system("rm $graphs/hddtemp-hdg-day.png");
1334 if (open STAT
,"/dev/hdh") {
1336 updatehdddata
("hdh");
1337 updatehddgraph
("hdh","day");
1338 updatehddgraph
("hdh","week");
1339 updatehddgraph
("hdh","month");
1340 updatehddgraph
("hdh","year");
1342 if (-e
"$graphs/hddtemp-hdh-day.png") {
1343 system("rm $graphs/hddtemp-hdh-day.png");
1349 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1351 updatetempgraph
("day");
1352 updatetempgraph
("week");
1353 updatetempgraph
("month");
1354 updatetempgraph
("year");
1356 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1358 updatefangraph
("day");
1359 updatefangraph
("week");
1360 updatefangraph
("month");
1361 updatefangraph
("year");
1363 if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
1365 updatevoltgraph
("day");
1366 updatevoltgraph
("week");
1367 updatevoltgraph
("month");
1368 updatevoltgraph
("year");
1374 @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`;
1376 updateifdata
("GREEN");
1377 updateifdata
("RED");
1378 if ($settings{'CONFIG_TYPE'} =~ /^(2|4)$/ ) {
1379 updateifdata
("ORANGE");
1381 if ($settings{'CONFIG_TYPE'} =~ /^(3|4)$/ ) {
1382 updateifdata
("BLUE");
1385 if ( -e
"$rrdlog/GREEN.rrd") {
1386 updateifgraph
("GREEN", "day");
1387 updateifgraph
("GREEN", "week");
1388 updateifgraph
("GREEN", "month");
1389 updateifgraph
("GREEN", "year");
1392 if ( -e
"$rrdlog/RED.rrd") {
1393 updateifgraph
("RED", "day");
1394 updateifgraph
("RED", "week");
1395 updateifgraph
("RED", "month");
1396 updateifgraph
("RED", "year");
1399 if ($settings{'CONFIG_TYPE'} =~ /^(2|4)$/ && -e
"$rrdlog/ORANGE.rrd") {
1400 updateifgraph
("ORANGE", "day");
1401 updateifgraph
("ORANGE", "week");
1402 updateifgraph
("ORANGE", "month");
1403 updateifgraph
("ORANGE", "year");
1406 if ($settings{'CONFIG_TYPE'} =~ /^(3|4)$/ && -e
"$rrdlog/BLUE.rrd") {
1407 updateifgraph
("BLUE", "day");
1408 updateifgraph
("BLUE", "week");
1409 updateifgraph
("BLUE", "month");
1410 updateifgraph
("BLUE", "year");
1413 system("chmod -R 0777 /srv/web/ipfire/html/graphs");
1414 system("chmod -R 0777 /srv/web/ipfire/html/sgraph");