]>
git.ipfire.org Git - people/pmueller/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 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{"color20"},
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'}\\j",
133 "STACK:systempct".$color{"color13"}.":$tr{'system cpu usage'}\\j",
134 "STACK:idlepct".$color{"color12"}.":$tr{'idle cpu usage'}\\j",
135 "GPRINT:userpct:MAX:$tr{'maximal'} $tr{'user cpu'}\\:%3.2lf%%",
136 "GPRINT:userpct:AVERAGE:$tr{'average'} $tr{'user cpu'}\\:%3.2lf%%",
137 "GPRINT:userpct:LAST:$tr{'current'} $tr{'user cpu'}\\:%3.2lf%%\\j",
138 "GPRINT:systempct:MAX:$tr{'maximal'} $tr{'system cpu'}\\:%3.2lf%%",
139 "GPRINT:systempct:AVERAGE:$tr{'average'} $tr{'system cpu'}\\:%3.2lf%%",
140 "GPRINT:systempct:LAST:$tr{'current'} $tr{'system cpu'}\\:%3.2lf%%\\j",
141 "GPRINT:idlepct:MAX:$tr{'maximal'} $tr{'idle cpu'}\\:%3.2lf%%",
142 "GPRINT:idlepct:AVERAGE:$tr{'average'} $tr{'idle cpu'}\\:%3.2lf%%",
143 "GPRINT:idlepct:LAST:$tr{'current'} $tr{'idle cpu'}\\:%3.2lf%%\\j");
144 $ERROR = RRDs
::error
;
145 print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
149 if ( ! -e
"$rrdlog/cpu.rrd") {
150 RRDs
::create
("$rrdlog/cpu.rrd", "--step=300",
151 "DS:user:COUNTER:600:0:500000000",
152 "DS:system:COUNTER:600:0:500000000",
153 "DS:idle:COUNTER:600:0:500000000",
154 "RRA:AVERAGE:0.5:1:576",
155 "RRA:AVERAGE:0.5:6:672",
156 "RRA:AVERAGE:0.5:24:732",
157 "RRA:AVERAGE:0.5:144:1460");
158 $ERROR = RRDs
::error
;
159 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
162 my ($cpu, $user, $nice, $system, $idle);
164 open STAT
, "/proc/stat";
168 ($cpu, $user, $nice, $system, $idle) = split /\s+/;
174 RRDs
::update
("$rrdlog/cpu.rrd",
175 "-t", "user:system:idle",
176 "N:$user:$system:$idle");
177 $ERROR = RRDs
::error
;
178 print "Error in RRD::update for cpu: $ERROR\n" if $ERROR;
182 sub updateloadgraph
{
185 RRDs
::graph
("$graphs/load-$period.png",
186 "--start", "-1$period", "-aPNG",
187 "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid",
189 "--color", "SHADEA".$color{"color19"},
190 "--color", "SHADEB".$color{"color20"},
191 "--color", "BACK".$color{"color21"},
192 "DEF:load1=$rrdlog/load.rrd:load1:AVERAGE",
193 "DEF:load5=$rrdlog/load.rrd:load5:AVERAGE",
194 "DEF:load15=$rrdlog/load.rrd:load15:AVERAGE",
195 "AREA:load1".$color{"color13"}.":1 Minute, letzter\\:",
196 "GPRINT:load1:LAST:%5.2lf\\j",
197 "AREA:load5".$color{"color18"}.":5 Minuten, letzter\\:",
198 "GPRINT:load5:LAST:%5.2lf\\j",
199 "AREA:load15".$color{"color14"}.":15 Minuten, letzter\\:",
200 "GPRINT:load15:LAST:%5.2lf\\j",
201 "LINE1:load5".$color{"color13"},
202 "LINE1:load1".$color{"color18"});
203 $ERROR = RRDs
::error
;
204 print "Error in RRD::graph for load: $ERROR\n" if $ERROR;
208 if ( ! -e
"$rrdlog/load.rrd") {
209 RRDs
::create
("$rrdlog/load.rrd", "--step=60",
210 "DS:load1:GAUGE:120:0:U",
211 "DS:load5:GAUGE:120:0:U",
212 "DS:load15:GAUGE:120:0:U",
213 "RRA:AVERAGE:0.5:1:2160",
214 "RRA:AVERAGE:0.5:5:2016",
215 "RRA:AVERAGE:0.5:15:2880",
216 "RRA:AVERAGE:0.5:60:8760");
218 $ERROR = RRDs
::error
;
219 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
226 RRDs
::graph
("$graphs/memory-$period.png",
227 "--start", "-1$period", "-aPNG", "-i", "-z",
228 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
229 "--color", "SHADEA".$color{"color19"},
230 "--color", "SHADEB".$color{"color20"},
231 "--color", "BACK".$color{"color21"},
232 "-t $tr{'memory usage per'} $tr{$period}",
233 "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE",
234 "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE",
235 "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE",
236 "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE",
237 "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE",
238 "CDEF:total=used,free,+",
239 "CDEF:used2=used,buffer,cache,shared,+,+,-",
240 "CDEF:usedpct=100,used2,total,/,*",
241 "CDEF:sharedpct=100,shared,total,/,*",
242 "CDEF:bufferpct=100,buffer,total,/,*",
243 "CDEF:cachepct=100,cache,total,/,*",
244 "CDEF:freepct=100,free,total,/,*",
245 "AREA:usedpct".$color{"color11"}.":$tr{'used memory'}\\j",
246 "STACK:sharedpct".$color{"color13"}.":$tr{'shared memory'}\\j",
247 "STACK:bufferpct".$color{"color23"}.":$tr{'buffered memory'}\\j",
248 "STACK:cachepct".$color{"color14"}.":$tr{'cached memory'}\\j",
249 "STACK:freepct".$color{"color12"}.":$tr{'free memory'}\\j",
250 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used memory'}\\:%3.2lf%%",
251 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used memory'}\\:%3.2lf%%",
252 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used memory'}\\:%3.2lf%%\\j",
253 "GPRINT:sharedpct:MAX:$tr{'maximal'} $tr{'shared memory'}\\:%3.2lf%%",
254 "GPRINT:sharedpct:AVERAGE:$tr{'average'} $tr{'shared memory'}\\:%3.2lf%%",
255 "GPRINT:sharedpct:LAST:$tr{'current'} $tr{'shared memory'}\\:%3.2lf%%\\j",
256 "GPRINT:bufferpct:MAX:$tr{'maximal'} $tr{'buffered memory'}\\:%3.2lf%%",
257 "GPRINT:bufferpct:AVERAGE:$tr{'average'} $tr{'buffered memory'}\\:%3.2lf%%",
258 "GPRINT:bufferpct:LAST:$tr{'current'} $tr{'buffered memory'}\\:%3.2lf%%\\j",
259 "GPRINT:cachepct:MAX:$tr{'maximal'} $tr{'cached memory'}\\:%3.2lf%%",
260 "GPRINT:cachepct:AVERAGE:$tr{'average'} $tr{'cached memory'}\\:%3.2lf%%",
261 "GPRINT:cachepct:LAST:$tr{'current'} $tr{'cached memory'}\\:%3.2lf%%\\j",
262 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free memory'}\\:%3.2lf%%",
263 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free memory'}\\:%3.2lf%%",
264 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free memory'}\\:%3.2lf%%\\j");
265 $ERROR = RRDs
::error
;
266 print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
268 RRDs
::graph
("$graphs/swap-$period.png",
269 "--start", "-1$period", "-aPNG", "-i", "-z",
270 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
271 "--color", "SHADEA".$color{"color19"},
272 "--color", "SHADEB".$color{"color20"},
273 "--color", "BACK".$color{"color21"},
274 "-t $tr{'swap usage per'} $tr{$period}",
275 "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE",
276 "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE",
277 "CDEF:total=used,free,+",
278 "CDEF:usedpct=100,used,total,/,*",
279 "CDEF:freepct=100,free,total,/,*",
280 "AREA:usedpct".$color{"color11"}.":$tr{'used swap'}\\j",
281 "STACK:freepct".$color{"color12"}.":$tr{'free swap'}\\j",
282 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used swap'}\\:%3.2lf%%",
283 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used swap'}\\:%3.2lf%%",
284 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used swap'}\\:%3.2lf%%\\j",
285 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free swap'}\\:%3.2lf%%",
286 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free swap'}\\:%3.2lf%%",
287 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free swap'}\\:%3.2lf%%\\j");
288 $ERROR = RRDs
::error
;
289 print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
293 my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree, $swaptotal);
294 if ( ! -e
"$rrdlog/mem.rrd") {
295 RRDs
::create
("$rrdlog/mem.rrd", "--step=300",
296 "DS:memused:ABSOLUTE:600:0:5000000000",
297 "DS:memfree:ABSOLUTE:600:0:5000000000",
298 "DS:memshared:ABSOLUTE:600:0:5000000000",
299 "DS:membuffers:ABSOLUTE:600:0:5000000000",
300 "DS:memcache:ABSOLUTE:600:0:5000000000",
301 "DS:swapused:ABSOLUTE:600:0:5000000000",
302 "DS:swapfree:ABSOLUTE:600:0:5000000000",
303 "RRA:AVERAGE:0.5:1:576",
304 "RRA:AVERAGE:0.5:6:672",
305 "RRA:AVERAGE:0.5:24:732",
306 "RRA:AVERAGE:0.5:144:1460");
307 $ERROR = RRDs
::error
;
308 print "Error in RRD::create for mem: $ERROR\n" if $ERROR;
311 open MEM
, "/proc/meminfo";
314 if ($_ =~ /^MemTotal:/) {
315 my @temp = split (/\s+/, $_);
317 } elsif ($_ =~ /^MemFree:/) {
318 my @temp = split (/\s+/, $_);
320 } elsif ($_ =~ /^Cached:/) {
321 my @temp = split (/\s+/, $_);
322 $memcache = $temp[1];
323 } elsif ($_ =~ /^Buffers:/) {
324 my @temp = split (/\s+/, $_);
325 $membuffers = $temp[1];
326 } elsif ($_ =~ /^SwapTotal:/) {
327 my @temp = split (/\s+/, $_);
328 $swaptotal = $temp[1];
329 } elsif ($_ =~ /^SwapFree:/) {
330 my @temp = split (/\s+/, $_);
331 $swapfree = $temp[1];
336 system("/bin/df > /tmp/diskfree");
337 open DF
, "/tmp/diskfree";
341 my @temp = split (/\s+/, $_);
342 $memshared = $temp[2];
346 system("/bin/rm -f /tmp/diskfree");
348 $swapused = $swaptotal-$swapfree;
349 RRDs
::update
("$rrdlog/mem.rrd",
350 "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree",
351 "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree");
352 $ERROR = RRDs
::error
;
353 print "Error in RRD::update for mem: $ERROR\n" if $ERROR;
356 sub updatediskgraph
{
359 RRDs
::graph
("$graphs/disk-$period.png",
360 "--start", "-1$period", "-aPNG", "-i", "-z",
361 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
362 "--color", "SHADEA".$color{"color19"},
363 "--color", "SHADEB".$color{"color20"},
364 "--color", "BACK".$color{"color21"},
365 "-t $tr{'disk access per'} $tr{$period}",
366 "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE",
367 "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE",
368 "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}\\j",
369 "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j",
370 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
371 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
372 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
373 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
374 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
375 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
376 $ERROR = RRDs
::error
;
377 print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
381 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
382 if ( ! -e
"$rrdlog/disk.rrd") {
383 RRDs
::create
("$rrdlog/disk.rrd", "--step=300",
384 "DS:readsect:COUNTER:600:0:5000000000",
385 "DS:writesect:COUNTER:600:0:5000000000",
386 "RRA:AVERAGE:0.5:1:576",
387 "RRA:AVERAGE:0.5:6:672",
388 "RRA:AVERAGE:0.5:24:732",
389 "RRA:AVERAGE:0.5:144:1460");
390 $ERROR = RRDs
::error
;
391 print "Error in RRD::create for disk: $ERROR\n" if $ERROR;
394 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
395 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk");
397 my $major = $rdev >> 8;
398 my $minor = $rdev & 0xFF;
400 open STAT
, "/proc/stat";
401 my @diskstat = <STAT
>;
403 foreach my $line (@diskstat)
406 my @temp = split(/\:\ /,$line);
408 my @devicestat = split(/\ /,$temp[1]);
409 foreach my $stats (@devicestat)
412 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
413 if ($major eq $fields[1] and $minor eq $fields[2])
415 $readwritereq = $fields[3];
416 $readreq = $fields[4];
417 $readsect = $fields[5];
418 $writereq = $fields[6];
419 $writesect = $fields[7];
425 if ($readsect && $writesect) {
426 RRDs
::update
("$rrdlog/disk.rrd",
427 "-t", "readsect:writesect",
428 "N:$readsect:$writesect");
429 $ERROR = RRDs
::error
;
430 print "Error in RRD::update for disk: $ERROR\n" if $ERROR;
432 print "Error in RRD::update for disk: no data available\n";
436 sub updatediskgraphnew
{
440 RRDs
::graph
("$graphs/disk-$disk-$period.png",
441 "--start", "-1$period", "-aPNG", "-i", "-z",
442 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
443 "--color", "SHADEA".$color{"color19"},
444 "--color", "SHADEB".$color{"color20"},
445 "--color", "BACK".$color{"color21"},
446 "-t $tr{'disk access per'} $tr{$period}",
447 "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
448 "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
449 "DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE",
450 "CDEF:sl_state=sleep,INF,*",
452 "AREA:sl_state#a0a0a0:disk standby\\j",
453 "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}\\j",
454 "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j",
456 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
457 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
458 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
459 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
460 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
461 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
462 $ERROR = RRDs
::error
;
463 print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR;
466 sub updatediskdatanew
{
469 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
470 if ( ! -e
"$rrdlog/disk-$disk.rrd") {
471 RRDs
::create
("$rrdlog/disk-$disk.rrd", "--step=300",
472 "DS:readsect:COUNTER:600:0:5000000000",
473 "DS:writesect:COUNTER:600:0:5000000000",
474 "DS:sleeping:GAUGE:600:0:1",
475 "RRA:AVERAGE:0.5:1:576",
476 "RRA:AVERAGE:0.5:6:672",
477 "RRA:AVERAGE:0.5:24:732",
478 "RRA:AVERAGE:0.5:144:1460");
479 $ERROR = RRDs
::error
;
480 print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR;
483 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
484 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk");
486 print "\n\n$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks\n\n";
488 my $major = $rdev >> 8;
489 my $minor = ($rdev & 0xFF) >>6;
491 open STAT
, "/proc/stat";
492 my @diskstat = <STAT
>;
494 foreach my $line (@diskstat)
497 my @temp = split(/\:\ /,$line);
499 my @devicestat = split(/\ /,$temp[1]);
500 foreach my $stats (@devicestat)
503 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
504 if ($major eq $fields[1] and $minor eq $fields[2])
506 $readwritereq = $fields[3];
507 $readreq = $fields[4];
508 $readsect = $fields[5];
509 $writereq = $fields[6];
510 $writesect = $fields[7];
517 my $lastsleepstate=0;
519 if ( -e
"/tmp/hddshutdown-$disk" ) {
520 open STAT
,"/tmp/hddshutdown-$disk";
521 $lastsleepstate = <STAT
>;
523 if ($lastsleepstate==$readwritereq) {
528 if ($readsect && $writesect) {
529 RRDs
::update
("$rrdlog/disk-$disk.rrd",
530 "-t", "readsect:writesect:sleeping",
531 "N:$readsect:$writesect:$sleeping");
532 $ERROR = RRDs
::error
;
533 print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR;
535 print "Error in RRD::update for disk-$disk: no data available\n";
540 my $interface = $_[0];
543 RRDs
::graph
("$graphs/$interface-$period.png",
544 "--start", "-1$period", "-aPNG", "-i", "-z",
545 "--alt-y-grid", "-w 600", "-h 100",
546 "--color", "SHADEA".$color{"color19"},
547 "--color", "SHADEB".$color{"color20"},
548 "--color", "BACK".$color{"color21"},
549 "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})",
550 "-v$tr{'bytes per second'}",
551 "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE",
552 "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE",
553 "AREA:incoming".$color{"color11"}.":$tr{'incoming traffic in bytes per second'}\\j",
554 "LINE1:outgoing".$color{"color12"}.":$tr{'outgoing traffic in bytes per second'}\\j",
555 "GPRINT:incoming:MAX:$tr{'maximal'} $tr{'in'}\\:%8.3lf %sBps",
556 "GPRINT:incoming:AVERAGE:$tr{'average'} $tr{'in'}\\:%8.3lf %sBps",
557 "GPRINT:incoming:LAST:$tr{'current'} $tr{'in'}\\:%8.3lf %sBps\\j",
558 "GPRINT:outgoing:MAX:$tr{'maximal'} $tr{'out'}\\:%8.3lf %sBps",
559 "GPRINT:outgoing:AVERAGE:$tr{'average'} $tr{'out'}\\:%8.3lf %sBps",
560 "GPRINT:outgoing:LAST:$tr{'current'} $tr{'out'}\\:%8.3lf %sBps\\j");
561 $ERROR = RRDs
::error
;
562 print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
566 my $interface = $_[0];
568 if ( ! -e
"$rrdlog/$interface.rrd") {
569 RRDs
::create
("$rrdlog/$interface.rrd", "--step=300",
570 "DS:incoming:ABSOLUTE:600:0:12500000",
571 "DS:outgoing:ABSOLUTE:600:0:12500000",
572 "RRA:AVERAGE:0.5:1:576",
573 "RRA:AVERAGE:0.5:6:672",
574 "RRA:AVERAGE:0.5:24:732",
575 "RRA:AVERAGE:0.5:144:1460");
576 $ERROR = RRDs
::error
;
577 print "Error in RRD::create for $interface: $ERROR\n" if $ERROR;
580 my $traffic = gettraffic
($interface);
581 RRDs
::update
("$rrdlog/$interface.rrd",
582 "-t", "incoming:outgoing",
584 $ERROR = RRDs
::error
;
585 print "Error in RRD::update for $interface: $ERROR\n" if $ERROR;
588 sub updatefwhitsgraph
{
589 my $interval = $_[0];
591 RRDs
::graph
("$graphs/firewallhits-$interval-area.png",
592 "--start", "-1$interval", "-aPNG", "-i", "-z",
593 "--alt-y-grid", "-w 600", "-h 200",
594 "--color", "SHADEA".$color{"color19"},
595 "--color", "SHADEB".$color{"color20"},
596 "--color", "BACK".$color{"color21"},
597 "-t firewall hits over the last $interval",
598 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
599 "AREA:amount".$color{"color24"}.":firewallhits",
600 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
601 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
602 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
603 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
604 "AREA:portamount".$color{"color25"}.":portscans",
605 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
606 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
607 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
608 $ERROR = RRDs
::error
;
609 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
611 RRDs
::graph
("$graphs/firewallhits-$interval-line.png",
612 "--start", "-1$interval", "-aPNG", "-i", "-z",
613 "--alt-y-grid", "-w 600", "-h 200",
614 "--color", "SHADEA".$color{"color19"},
615 "--color", "SHADEB".$color{"color20"},
616 "--color", "BACK".$color{"color21"},
617 "-t firewall hits over the last $interval",
618 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
619 "LINE2:amount".$color{"color24"}.":firewallhits",
620 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
621 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
622 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
623 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
624 "LINE2:portamount".$color{"color25"}.":portscans",
625 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
626 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
627 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
628 $ERROR = RRDs
::error
;
629 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
632 sub updatefwhitsdata
{
639 if (! -e
"$rrdlog/firewallhits.rrd")
641 RRDs
::create
("$rrdlog/firewallhits.rrd", "--step=300",
642 "DS:amount:GAUGE:600:0:U",
643 "DS:portamount:GAUGE:600:0:U",
644 "RRA:AVERAGE:0.5:1:576",
645 "RRA:AVERAGE:0.5:6:672",
646 "RRA:AVERAGE:0.5:24:732",
647 "RRA:AVERAGE:0.5:144:1460");
648 $ERROR = RRDs
::error
;
649 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
652 system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits");
653 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
659 if (/kernel:.*(IN=.*)$/) {
666 system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits");
667 if (!(open (FILE
,'/tmp/snort.fwhits'))) {
680 if (!(open (FILE
,'/tmp/messages.fwhits'))) {
686 if (/kernel:.*(Scan.*)$/) {
693 system("rm /tmp/messages.fwhits");
694 system("rm /tmp/snort.fwhits");
696 $portamount = $portaktuell + $alertaktuell;
698 RRDs
::update
("$rrdlog/firewallhits.rrd",
699 "N:$aktuell:$portamount");
700 $ERROR = RRDs
::error
;
701 print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR;
704 # Creates and updates a link quality database
705 # -------------------------------------------
707 if ( ! -e
"$rrdlog/lq.rrd") {
708 RRDs
::create
("$rrdlog/lq.rrd", "--step=300",
709 "DS:loss:GAUGE:600:0:100",
710 "DS:roundtrip:GAUGE:600:0:10000",
711 "RRA:AVERAGE:0.5:1:576",
712 "RRA:AVERAGE:0.5:6:672",
713 "RRA:AVERAGE:0.5:24:732",
714 "RRA:AVERAGE:0.5:144:1460");
715 $ERROR = RRDs
::error
;
716 print "Error in RRD::create for link: $ERROR\n" if $ERROR;
721 # LQ_GATEWAY is the ip of your isp's public ip facing you
722 my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`;
724 my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`;
726 my @temp = split (/\/|\
%|\s
/, $pingoutput);
727 $packetloss = $temp[17];
728 $roundtrip = $temp[28];
729 RRDs
::update
("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip");
730 $ERROR = RRDs
::error
;
731 print "Error in RRD::update for line quality: $ERROR\n" if $ERROR;
736 RRDs
::graph
("$graphs/lq-$period.png",
737 "--start", "-1$period", "-aPNG", "-i", "-z",
738 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
739 "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})",
741 "--color", "SHADEA".$color{"color19"},
742 "--color", "SHADEB".$color{"color20"},
743 "--color", "BACK".$color{"color21"},
744 "-v ms / pkts (% x10)",
745 "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE",
746 "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE",
747 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
748 "CDEF:loss10=loss,10,*",
749 "CDEF:r0=roundtrip,30,MIN",
750 "CDEF:r1=roundtrip,70,MIN",
751 "CDEF:r2=roundtrip,150,MIN",
752 "CDEF:r3=roundtrip,300,MIN",
753 "AREA:roundtrip".$color{"color25"}.":>300 ms",
754 "AREA:r3".$color{"color18"}.":150-300 ms",
755 "AREA:r2".$color{"color14"}.":70-150 ms",
756 "AREA:r1".$color{"color17"}.":30-70 ms",
757 "AREA:r0".$color{"color12"}.":<30 ms",
758 "AREA:loss10".$color{"color13"}.":Packet loss (x10)",
759 "LINE1:roundtrip#707070:",
760 "GPRINT:roundtrip:MAX:$tr{'maximal'}\\:%3.2lf ms",
761 "GPRINT:roundtrip:AVERAGE:$tr{'average'}\\:%3.2lf ms",
762 "GPRINT:roundtrip:LAST:$tr{'current'}\\:%3.2lf ms\\j",
763 "GPRINT:loss:MAX:$tr{'maximal'} Loss\\:%3.2lf%%",
764 "GPRINT:loss:AVERAGE:$tr{'average'} Loss\\:%3.2lf%%",
765 "GPRINT:loss:LAST:$tr{'current'} Loss\\:%3.2lf%%\\j"
767 $ERROR = RRDs
::error
;
768 print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
774 if ( ! -e
"$rrdlog/hddtemp-$disk.rrd")
776 # database did not exist -> create
777 RRDs
::create
("$rrdlog/hddtemp-$disk.rrd", "--step=300",
778 "DS:temperature:GAUGE:600:0:100",
779 "RRA:AVERAGE:0.5:1:576",
780 "RRA:AVERAGE:0.5:6:672",
781 "RRA:AVERAGE:0.5:24:732",
782 "RRA:AVERAGE:0.5:144:1460");
783 $ERROR = RRDs
::error
;
784 print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR;
789 my $smart_output = '';
791 if ( -e
"$path_smartctl" )
793 system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
796 if ( -e
"$path_hddtemp" )
798 $hdd_output = `$path_hddtemp -qn /dev/$disk`;
800 # I know 4 response possible responses:
802 # /dev/harddisk: harddisk type: S.M.A.R.T. not available
803 # /dev/harddisk: harddisk type: no sensor
804 # /dev/harddisk: harddisk type: 37°C or °F
807 if ( index($hdd_output, "S.M.A.R.T.") != -1 )
811 elsif ( index($hdd_output, "no sensor") != -1 )
815 elsif ( index($hdd_output, "$disk") != -1 )
817 $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
822 $hdd_output =~ /(\d+)\s/;
826 elsif ( -e
"/var/log/smartctl_out_hddtemp-$disk" )
828 $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`;
829 my @t = split(/\s+/,$hdd_output);
837 # print "hdd $hdd_output \n";
838 # print "temp $temp \n";
840 RRDs
::update
("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
842 $ERROR = RRDs
::error
;
843 print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
850 RRDs
::graph
("$graphs/hddtemp-$disk-$period.png",
851 "--start", "-1$period", "-aPNG", "-i", "-z",
852 "--alt-y-grid", "-w 600", "-h 100",
853 "--color", "SHADEA".$color{"color19"},
854 "--color", "SHADEB".$color{"color20"},
855 "--color", "BACK".$color{"color21"},
856 "-t $tr{'harddisk temperature'} ($tr{'graph per'} $tr{$period})",
857 "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
858 "LINE2:temperature".$color{"color11"}.":$tr{'hdd temperature in'} °C",
859 "GPRINT:temperature:MAX:$tr{'maximal'}\\:%3.0lf °C",
860 "GPRINT:temperature:AVERAGE:$tr{'average'}\\:%3.0lf °C",
861 "GPRINT:temperature:LAST:$tr{'current'}\\:%3.0lf °C",
863 $ERROR = RRDs
::error
;
864 print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;
869 if ( ! -e
"$rrdlog/mbmon.rrd" )
871 # database did not exist -> create
873 @args = ("$rrdlog/mbmon.rrd");
875 push(@args, "--step=300");
876 foreach $key ( sort(keys %mbmon_values) )
878 push(@args, "DS:$key:GAUGE:600:U:U");
880 push(@args, "RRA:AVERAGE:0.5:1:576");
881 push(@args, "RRA:AVERAGE:0.5:6:672");
882 push(@args, "RRA:AVERAGE:0.5:24:732");
883 push(@args, "RRA:AVERAGE:0.5:144:1460");
885 print("create ". join( ", ", @args)) if ( $dbg );
887 RRDs
::create
(@args);
888 $ERROR = RRDs
::error
;
889 print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
896 foreach $key ( sort(keys %mbmon_values) )
899 push(@val, $mbmon_values{$key});
902 $template = join(':', @ds);
903 $value = "N:".join(':', @val);
905 print("update template = '$template'\n") if ( $dbg );
906 print("update value = '$value'\n") if ( $dbg );
908 RRDs
::update
("$rrdlog/mbmon.rrd", "-t", $template, $value);
909 $ERROR = RRDs
::error
;
910 print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
918 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
919 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
920 "--color", "SHADEA".$color{"color19"},
921 "--color", "SHADEB".$color{"color20"},
922 "--color", "BACK".$color{"color21"},
923 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
926 foreach $key ( sort(keys %mbmon_values) )
928 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
930 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
932 $mbmon_settings{'LABEL-'.$key} = $key;
935 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
936 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C");
937 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C");
938 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C");
939 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j");
947 RRDs
::graph
( @args );
948 $ERROR = RRDs
::error
;
949 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
958 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
959 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
960 "--color", "SHADEA".$color{"color19"},
961 "--color", "SHADEB".$color{"color20"},
962 "--color", "BACK".$color{"color21"},
963 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
966 foreach $key ( sort(keys %mbmon_values) )
968 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
970 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
972 $mbmon_settings{'LABEL-'.$key} = $key;
975 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
976 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm");
977 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm");
978 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm");
979 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j");
987 RRDs
::graph
( @args );
988 $ERROR = RRDs
::error
;
989 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
998 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
999 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
1000 "--color", "SHADEA".$color{"color19"},
1001 "--color", "SHADEB".$color{"color20"},
1002 "--color", "BACK".$color{"color21"},
1003 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
1006 foreach $key ( sort(keys %mbmon_values) )
1008 my $v = substr($key,0,1);
1009 if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') )
1011 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
1013 $mbmon_settings{'LABEL-'.$key} = $key;
1016 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
1017 push(@args, "LINE2:$key$color{$count}:$mbmon_settings{'LABEL-'.$key} V");
1018 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V");
1019 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V");
1020 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j");
1028 RRDs
::graph
( @args );
1029 $ERROR = RRDs
::error
;
1030 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
1035 system ('/usr/sbin/fetchipac');
1041 if ( -e
"/var/log/squid/access.log") {
1042 system ("/usr/bin/squid-graph -o=/srv/web/ipfire/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1");
1048 if ((${Lang
::language
} eq 'cs') ||
1049 (${Lang
::language
} eq 'hu') ||
1050 (${Lang
::language
} eq 'pl') ||
1051 (${Lang
::language
} eq 'sk')) {
1052 # Czech, Hungarian, Polish and Slovak character set
1053 foreach my $key(keys %Lang::tr
) {
1054 from_to
($tr{$key}, "utf-8", "iso-8859-2");
1056 } elsif (${Lang
::language
} eq 'tr') {
1058 foreach my $key(keys %Lang::tr
) {
1059 from_to
($tr{$key}, "utf-8", "iso-8859-9");
1062 foreach my $key(keys %Lang::tr
) {
1063 from_to
($tr{$key}, "utf-8", "iso-8859-1");
1071 updatecpugraph
("day");
1072 updatecpugraph
("week");
1073 updatecpugraph
("month");
1074 updatecpugraph
("year");
1077 updateloadgraph
("day");
1078 updateloadgraph
("week");
1079 updateloadgraph
("month");
1080 updateloadgraph
("year");
1083 updatememgraph
("day");
1084 updatememgraph
("week");
1085 updatememgraph
("month");
1086 updatememgraph
("year");
1089 updatediskgraph
("day");
1090 updatediskgraph
("week");
1091 updatediskgraph
("month");
1092 updatediskgraph
("year");
1094 if (open STAT
,"/dev/hda") {
1096 updatediskdatanew
("hda");
1097 updatediskgraphnew
("hda","day");
1098 updatediskgraphnew
("hda","week");
1099 updatediskgraphnew
("hda","month");
1100 updatediskgraphnew
("hda","year");
1102 if (-e
"$graphs/disk-hda-day.png") {
1103 system("rm $graphs/disk-hda-day.png");
1107 if (open STAT
,"/dev/hdb") {
1109 updatediskdatanew
("hdb");
1110 updatediskgraphnew
("hdb","day");
1111 updatediskgraphnew
("hdb","week");
1112 updatediskgraphnew
("hdb","month");
1113 updatediskgraphnew
("hdb","year");
1115 if (-e
"$graphs/disk-hdb-day.png") {
1116 system("rm $graphs/disk-hdb-day.png");
1120 if (open STAT
,"/dev/hdc") {
1122 updatediskdatanew
("hdc");
1123 updatediskgraphnew
("hdc","day");
1124 updatediskgraphnew
("hdc","week");
1125 updatediskgraphnew
("hdc","month");
1126 updatediskgraphnew
("hdc","year");
1128 if (-e
"$graphs/disk-hdc-day.png") {
1129 system("rm $graphs/disk-hdc-day.png");
1133 if (open STAT
,"/dev/hdd") {
1135 updatediskdatanew
("hdd");
1136 updatediskgraphnew
("hdd","day");
1137 updatediskgraphnew
("hdd","week");
1138 updatediskgraphnew
("hdd","month");
1139 updatediskgraphnew
("hdd","year");
1141 if (-e
"$graphs/disk-hdd-day.png") {
1142 system("rm $graphs/disk-hdd-day.png");
1146 if (open STAT
,"/dev/hde") {
1148 updatediskdatanew
("hde");
1149 updatediskgraphnew
("hde","day");
1150 updatediskgraphnew
("hde","week");
1151 updatediskgraphnew
("hde","month");
1152 updatediskgraphnew
("hde","year");
1154 if (-e
"$graphs/disk-hde-day.png") {
1155 system("rm $graphs/disk-hde-day.png");
1159 if (open STAT
,"/dev/hdf") {
1161 updatediskdatanew
("hdf");
1162 updatediskgraphnew
("hdf","day");
1163 updatediskgraphnew
("hdf","week");
1164 updatediskgraphnew
("hdf","month");
1165 updatediskgraphnew
("hdf","year");
1167 if (-e
"$graphs/disk-hdf-day.png") {
1168 system("rm $graphs/disk-hdf-day.png");
1172 if (open STAT
,"/dev/hdg") {
1174 updatediskdatanew
("hdg");
1175 updatediskgraphnew
("hdg","day");
1176 updatediskgraphnew
("hdg","week");
1177 updatediskgraphnew
("hdg","month");
1178 updatediskgraphnew
("hdg","year");
1180 if (-e
"$graphs/disk-hdg-day.png") {
1181 system("rm $graphs/disk-hdg-day.png");
1185 if (open STAT
,"/dev/hdh") {
1187 updatediskdatanew
("hdh");
1188 updatediskgraphnew
("hdh","day");
1189 updatediskgraphnew
("hdh","week");
1190 updatediskgraphnew
("hdh","month");
1191 updatediskgraphnew
("hdh","year");
1193 if (-e
"$graphs/disk-hdh-day.png") {
1194 system("rm $graphs/disk-hdh-day.png");
1202 updatefwhitsgraph
("day");
1203 updatefwhitsgraph
("week");
1204 updatefwhitsgraph
("month");
1205 updatefwhitsgraph
("year");
1212 updatelqgraph
("day");
1213 updatelqgraph
("week");
1214 updatelqgraph
("month");
1215 updatelqgraph
("year");
1218 ### HDDTEMP-Graphs for /dev/harddisk
1220 if (open STAT
,"/dev/hda") {
1222 updatehdddata
("hda");
1223 updatehddgraph
("hda","day");
1224 updatehddgraph
("hda","week");
1225 updatehddgraph
("hda","month");
1226 updatehddgraph
("hda","year");
1228 if (-e
"$graphs/hddtemp-hda-day.png") {
1229 system("rm $graphs/hddtemp-hda-day.png");
1233 if (open STAT
,"/dev/hdb") {
1235 updatehdddata
("hdb");
1236 updatehddgraph
("hdb","day");
1237 updatehddgraph
("hdb","week");
1238 updatehddgraph
("hdb","month");
1239 updatehddgraph
("hdb","year");
1241 if (-e
"$graphs/hddtemp-hdb-day.png") {
1242 system("rm $graphs/hddtemp-hdb-day.png");
1246 if (open STAT
,"/dev/hdc") {
1248 updatehdddata
("hdc");
1249 updatehddgraph
("hdc","day");
1250 updatehddgraph
("hdc","week");
1251 updatehddgraph
("hdc","month");
1252 updatehddgraph
("hdc","year");
1254 if (-e
"$graphs/hddtemp-hdc-day.png") {
1255 system("rm $graphs/hddtemp-hdc-day.png");
1259 if (open STAT
,"/dev/hdd") {
1261 updatehdddata
("hdd");
1262 updatehddgraph
("hdd","day");
1263 updatehddgraph
("hdd","week");
1264 updatehddgraph
("hdd","month");
1265 updatehddgraph
("hdd","year");
1267 if (-e
"$graphs/hddtemp-hdd-day.png") {
1268 system("rm $graphs/hddtemp-hdd-day.png");
1272 if (open STAT
,"/dev/hde") {
1274 updatehdddata
("hde");
1275 updatehddgraph
("hde","day");
1276 updatehddgraph
("hde","week");
1277 updatehddgraph
("hde","month");
1278 updatehddgraph
("hde","year");
1280 if (-e
"$graphs/hddtemp-hde-day.png") {
1281 system("rm $graphs/hddtemp-hde-day.png");
1285 if (open STAT
,"/dev/hdf") {
1287 updatehdddata
("hdf");
1288 updatehddgraph
("hdf","day");
1289 updatehddgraph
("hdf","week");
1290 updatehddgraph
("hdf","month");
1291 updatehddgraph
("hdf","year");
1293 if (-e
"$graphs/hddtemp-hdf-day.png") {
1294 system("rm $graphs/hddtemp-hdf-day.png");
1298 if (open STAT
,"/dev/hdg") {
1300 updatehdddata
("hdg");
1301 updatehddgraph
("hdg","day");
1302 updatehddgraph
("hdg","week");
1303 updatehddgraph
("hdg","month");
1304 updatehddgraph
("hdg","year");
1306 if (-e
"$graphs/hddtemp-hdg-day.png") {
1307 system("rm $graphs/hddtemp-hdg-day.png");
1311 if (open STAT
,"/dev/hdh") {
1313 updatehdddata
("hdh");
1314 updatehddgraph
("hdh","day");
1315 updatehddgraph
("hdh","week");
1316 updatehddgraph
("hdh","month");
1317 updatehddgraph
("hdh","year");
1319 if (-e
"$graphs/hddtemp-hdh-day.png") {
1320 system("rm $graphs/hddtemp-hdh-day.png");
1326 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1328 updatetempgraph
("day");
1329 updatetempgraph
("week");
1330 updatetempgraph
("month");
1331 updatetempgraph
("year");
1333 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1335 updatefangraph
("day");
1336 updatefangraph
("week");
1337 updatefangraph
("month");
1338 updatefangraph
("year");
1340 if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
1342 updatevoltgraph
("day");
1343 updatevoltgraph
("week");
1344 updatevoltgraph
("month");
1345 updatevoltgraph
("year");
1351 @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`;
1353 updateifdata
("GREEN");
1354 updateifdata
("RED");
1355 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ ) {
1356 updateifdata
("ORANGE");
1358 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ ) {
1359 updateifdata
("BLUE");
1362 if ( -e
"$rrdlog/GREEN.rrd") {
1363 updateifgraph
("GREEN", "day");
1364 updateifgraph
("GREEN", "week");
1365 updateifgraph
("GREEN", "month");
1366 updateifgraph
("GREEN", "year");
1369 if ( -e
"$rrdlog/RED.rrd") {
1370 updateifgraph
("RED", "day");
1371 updateifgraph
("RED", "week");
1372 updateifgraph
("RED", "month");
1373 updateifgraph
("RED", "year");
1376 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ && -e
"$rrdlog/ORANGE.rrd") {
1377 updateifgraph
("ORANGE", "day");
1378 updateifgraph
("ORANGE", "week");
1379 updateifgraph
("ORANGE", "month");
1380 updateifgraph
("ORANGE", "year");
1383 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ && -e
"$rrdlog/BLUE.rrd") {
1384 updateifgraph
("BLUE", "day");
1385 updateifgraph
("BLUE", "week");
1386 updateifgraph
("BLUE", "month");
1387 updateifgraph
("BLUE", "year");
1390 system("chmod -R 0777 /srv/web/ipfire/html/graphs");
1391 system("chmod -R 0777 /srv/web/ipfire/html/sgraph");