Hinzugefuegt:
[ipfire-2.x.git] / src / scripts / makegraphs
1 #!/usr/bin/perl
2
3 ############################################################################
4 # #
5 # This file is part of the IPCop Firewall. #
6 # #
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. #
11 # #
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. #
16 # #
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 #
20 # #
21 # Copyright (C) 2004-01-19 Mark Wormgoor <mark@wormgoor.com>. #
22 # #
23 ############################################################################
24
25 use strict;
26 #use warnings;
27
28 use RRDs;
29 require "/var/ipfire/general-functions.pl";
30 require "${General::swroot}/lang.pl";
31
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);
36
37 # Added for conversion of utf-8 characters
38 use Encode 'from_to';
39 my %tr=();
40
41 # Force language back to English (ugly hack!)
42 # Modified to only force if we are unable to convert charset
43 # from utf-8
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"`;
52 } else {
53 %tr=%Lang::tr; # use translated version for other languages
54 }
55
56 # Settings
57 my $rrdlog = "/var/log/rrd";
58 my $graphs = "/home/httpd/html/graphs";
59 $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
60 my $hdd_device = "/dev/harddisk";
61 my $temp = '';
62 my %mbmon_values = ();
63 my $key;
64 my $value;
65 my @args = ();
66 my $count = 0;
67 my $ERROR;
68 my $dbg = 0;
69 my $path_smartctl = "/usr/sbin/smartctl";
70 my $path_hddtemp = "/usr/sbin/hddtemp";
71
72 my %colors = ();
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";
81
82 open(MBMON_OUT, ">/var/log/mbmon-values");
83 open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ;
84
85 while( $_ = <FD> )
86 {
87 next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ;
88 $key = $1 ;
89 $value = $2 ;
90 $key =~ y/A-Z/a-z/ ;
91 $mbmon_values{$key} = $value;
92 print(MBMON_OUT "$key=$value\n");
93 }
94 close(FD);
95 close(MBMON_OUT);
96
97 sub gettraffic {
98 my $interface = $_[0];
99
100 my $bytesin=0;
101 my $bytesout=0;
102
103 foreach (@ipacsum)
104 {
105 # Incoming...
106 $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/);
107
108 # Forwarded Incoming...
109 $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/);
110
111 # Outgoing...
112 $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/);
113
114 # Forwarded Outgoing...
115 $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/);
116 }
117 return "$bytesin:$bytesout";
118 }
119
120 sub updatecpugraph {
121 my $period = $_[0];
122
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;
151 }
152
153 sub updatecpudata {
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;
165 }
166
167 my ($cpu, $user, $nice, $system, $idle);
168
169 open STAT, "/proc/stat";
170 while(<STAT>) {
171 chomp;
172 /^cpu\s/ or next;
173 ($cpu, $user, $nice, $system, $idle) = split /\s+/;
174 last;
175 }
176 close STAT;
177 $user += $nice;
178
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;
184
185 }
186
187 sub updatememgraph {
188 my $period = $_[0];
189
190 RRDs::graph ("$graphs/memory-$period.png",
191 "--start", "-1$period", "-aPNG", "-i", "-z",
192 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
193 "--color", "SHADEA#EAE9EE",
194 "--color", "SHADEB#EAE9EE",
195 "--color", "BACK#FFFFFF",
196 "-t $tr{'memory usage per'} $tr{$period}",
197 "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE",
198 "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE",
199 "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE",
200 "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE",
201 "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE",
202 "CDEF:total=used,free,+",
203 "CDEF:used2=used,buffer,cache,shared,+,+,-",
204 "CDEF:usedpct=100,used2,total,/,*",
205 "CDEF:sharedpct=100,shared,total,/,*",
206 "CDEF:bufferpct=100,buffer,total,/,*",
207 "CDEF:cachepct=100,cache,total,/,*",
208 "CDEF:freepct=100,free,total,/,*",
209 "AREA:usedpct#0000FF:$tr{'used memory'}\\j",
210 "STACK:sharedpct#FF0000:$tr{'shared memory'}\\j",
211 "STACK:bufferpct#FF00FF:$tr{'buffered memory'}\\j",
212 "STACK:cachepct#FFFF00:$tr{'cached memory'}\\j",
213 "STACK:freepct#00FF00:$tr{'free memory'}\\j",
214 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used memory'}\\:%3.2lf%%",
215 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used memory'}\\:%3.2lf%%",
216 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used memory'}\\:%3.2lf%%\\j",
217 "GPRINT:sharedpct:MAX:$tr{'maximal'} $tr{'shared memory'}\\:%3.2lf%%",
218 "GPRINT:sharedpct:AVERAGE:$tr{'average'} $tr{'shared memory'}\\:%3.2lf%%",
219 "GPRINT:sharedpct:LAST:$tr{'current'} $tr{'shared memory'}\\:%3.2lf%%\\j",
220 "GPRINT:bufferpct:MAX:$tr{'maximal'} $tr{'buffered memory'}\\:%3.2lf%%",
221 "GPRINT:bufferpct:AVERAGE:$tr{'average'} $tr{'buffered memory'}\\:%3.2lf%%",
222 "GPRINT:bufferpct:LAST:$tr{'current'} $tr{'buffered memory'}\\:%3.2lf%%\\j",
223 "GPRINT:cachepct:MAX:$tr{'maximal'} $tr{'cached memory'}\\:%3.2lf%%",
224 "GPRINT:cachepct:AVERAGE:$tr{'average'} $tr{'cached memory'}\\:%3.2lf%%",
225 "GPRINT:cachepct:LAST:$tr{'current'} $tr{'cached memory'}\\:%3.2lf%%\\j",
226 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free memory'}\\:%3.2lf%%",
227 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free memory'}\\:%3.2lf%%",
228 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free memory'}\\:%3.2lf%%\\j");
229 $ERROR = RRDs::error;
230 print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
231
232 RRDs::graph ("$graphs/swap-$period.png",
233 "--start", "-1$period", "-aPNG", "-i", "-z",
234 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
235 "--color", "SHADEA#EAE9EE",
236 "--color", "SHADEB#EAE9EE",
237 "--color", "BACK#FFFFFF",
238 "-t $tr{'swap usage per'} $tr{$period}",
239 "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE",
240 "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE",
241 "CDEF:total=used,free,+",
242 "CDEF:usedpct=100,used,total,/,*",
243 "CDEF:freepct=100,free,total,/,*",
244 "AREA:usedpct#0000FF:$tr{'used swap'}\\j",
245 "STACK:freepct#00FF00:$tr{'free swap'}\\j",
246 "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used swap'}\\:%3.2lf%%",
247 "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used swap'}\\:%3.2lf%%",
248 "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used swap'}\\:%3.2lf%%\\j",
249 "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free swap'}\\:%3.2lf%%",
250 "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free swap'}\\:%3.2lf%%",
251 "GPRINT:freepct:LAST:$tr{'current'} $tr{'free swap'}\\:%3.2lf%%\\j");
252 $ERROR = RRDs::error;
253 print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
254 }
255
256 sub updatememdata {
257 my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree);
258 if ( ! -e "$rrdlog/mem.rrd") {
259 RRDs::create ("$rrdlog/mem.rrd", "--step=300",
260 "DS:memused:ABSOLUTE:600:0:5000000000",
261 "DS:memfree:ABSOLUTE:600:0:5000000000",
262 "DS:memshared:ABSOLUTE:600:0:5000000000",
263 "DS:membuffers:ABSOLUTE:600:0:5000000000",
264 "DS:memcache:ABSOLUTE:600:0:5000000000",
265 "DS:swapused:ABSOLUTE:600:0:5000000000",
266 "DS:swapfree:ABSOLUTE:600:0:5000000000",
267 "RRA:AVERAGE:0.5:1:576",
268 "RRA:AVERAGE:0.5:6:672",
269 "RRA:AVERAGE:0.5:24:732",
270 "RRA:AVERAGE:0.5:144:1460");
271 $ERROR = RRDs::error;
272 print "Error in RRD::create for mem: $ERROR\n" if $ERROR;
273 }
274
275 open MEM, "/proc/meminfo";
276 while(<MEM>) {
277 chomp;
278 if ($_ =~ /^Mem:/) {
279 my @temp = split (/\s+/, $_);
280 $memused = $temp[2];
281 $memfree = $temp[3];
282 $memshared = $temp[4];
283 $membuffers = $temp[5];
284 $memcache = $temp[6];
285 } elsif ($_ =~ /^Swap:/) {
286 my @temp = split (/\s+/, $_);
287 $swapused = $temp[2];
288 $swapfree = $temp[3];
289 }
290 }
291 close MEM;
292
293 RRDs::update ("$rrdlog/mem.rrd",
294 "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree",
295 "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree");
296 $ERROR = RRDs::error;
297 print "Error in RRD::update for mem: $ERROR\n" if $ERROR;
298 }
299
300 sub updatediskgraph {
301 my $period = $_[0];
302
303 RRDs::graph ("$graphs/disk-$period.png",
304 "--start", "-1$period", "-aPNG", "-i", "-z",
305 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
306 "--color", "SHADEA#EAE9EE",
307 "--color", "SHADEB#EAE9EE",
308 "--color", "BACK#FFFFFF",
309 "-t $tr{'disk access per'} $tr{$period}",
310 "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE",
311 "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE",
312 "AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j",
313 "STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j",
314 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
315 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
316 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
317 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
318 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
319 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
320 $ERROR = RRDs::error;
321 print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;
322 }
323
324 sub updatediskdata {
325 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
326 if ( ! -e "$rrdlog/disk.rrd") {
327 RRDs::create ("$rrdlog/disk.rrd", "--step=300",
328 "DS:readsect:COUNTER:600:0:5000000000",
329 "DS:writesect:COUNTER:600:0:5000000000",
330 "RRA:AVERAGE:0.5:1:576",
331 "RRA:AVERAGE:0.5:6:672",
332 "RRA:AVERAGE:0.5:24:732",
333 "RRA:AVERAGE:0.5:144:1460");
334 $ERROR = RRDs::error;
335 print "Error in RRD::create for disk: $ERROR\n" if $ERROR;
336 }
337
338 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
339 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk");
340
341 my $major = $rdev >> 8;
342 my $minor = $rdev & 0xFF;
343
344 open STAT, "/proc/stat";
345 my @diskstat = <STAT>;
346 close (STAT);
347 foreach my $line (@diskstat)
348 {
349 chomp ($line);
350 my @temp = split(/\:\ /,$line);
351 if ($temp[1]) {
352 my @devicestat = split(/\ /,$temp[1]);
353 foreach my $stats (@devicestat)
354 {
355 chomp ($stats);
356 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
357 if ($major eq $fields[1] and $minor eq $fields[2])
358 {
359 $readwritereq = $fields[3];
360 $readreq = $fields[4];
361 $readsect = $fields[5];
362 $writereq = $fields[6];
363 $writesect = $fields[7];
364 }
365 }
366 }
367 }
368
369 if ($readsect && $writesect) {
370 RRDs::update ("$rrdlog/disk.rrd",
371 "-t", "readsect:writesect",
372 "N:$readsect:$writesect");
373 $ERROR = RRDs::error;
374 print "Error in RRD::update for disk: $ERROR\n" if $ERROR;
375 } else {
376 print "Error in RRD::update for disk: no data available\n";
377 }
378 }
379
380 sub updatediskgraphnew {
381 my $disk = $_[0];
382 my $period = $_[1];
383
384 RRDs::graph ("$graphs/disk-$disk-$period.png",
385 "--start", "-1$period", "-aPNG", "-i", "-z",
386 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
387 "--color", "SHADEA#EAE9EE",
388 "--color", "SHADEB#EAE9EE",
389 "--color", "BACK#FFFFFF",
390 "-t $tr{'disk access per'} $tr{$period}",
391 "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
392 "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
393 "DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE",
394 "CDEF:sl_state=sleep,INF,*",
395
396 "AREA:sl_state#a0a0a0:disk standby\\j",
397 "AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j",
398 "STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j",
399
400 "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
401 "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
402 "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
403 "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
404 "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
405 "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
406 $ERROR = RRDs::error;
407 print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR;
408 }
409
410 sub updatediskdatanew {
411 my $disk = $_[0];
412
413 my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
414 if ( ! -e "$rrdlog/disk-$disk.rrd") {
415 RRDs::create ("$rrdlog/disk-$disk.rrd", "--step=300",
416 "DS:readsect:COUNTER:600:0:5000000000",
417 "DS:writesect:COUNTER:600:0:5000000000",
418 "DS:sleeping:GAUGE:600:0:1",
419 "RRA:AVERAGE:0.5:1:576",
420 "RRA:AVERAGE:0.5:6:672",
421 "RRA:AVERAGE:0.5:24:732",
422 "RRA:AVERAGE:0.5:144:1460");
423 $ERROR = RRDs::error;
424 print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR;
425 }
426
427 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
428 $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk");
429
430 my $major = $rdev >> 8;
431 my $minor = ($rdev & 0xFF) >>6;
432
433 open STAT, "/proc/stat";
434 my @diskstat = <STAT>;
435 close (STAT);
436 foreach my $line (@diskstat)
437 {
438 chomp ($line);
439 my @temp = split(/\:\ /,$line);
440 if ($temp[1]) {
441 my @devicestat = split(/\ /,$temp[1]);
442 foreach my $stats (@devicestat)
443 {
444 chomp ($stats);
445 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
446 if ($major eq $fields[1] and $minor eq $fields[2])
447 {
448 $readwritereq = $fields[3];
449 $readreq = $fields[4];
450 $readsect = $fields[5];
451 $writereq = $fields[6];
452 $writesect = $fields[7];
453 }
454 }
455 }
456 }
457
458 my $sleeping=0;
459 my $lastsleepstate=0;
460
461 if ( -e "/tmp/hddshutdown-$disk" ) {
462 open STAT,"/tmp/hddshutdown-$disk";
463 $lastsleepstate = <STAT>;
464 close (STAT);
465 if ($lastsleepstate==$readwritereq) {
466 $sleeping=1;
467 }
468 }
469
470 if ($readsect && $writesect) {
471 RRDs::update ("$rrdlog/disk-$disk.rrd",
472 "-t", "readsect:writesect:sleeping",
473 "N:$readsect:$writesect:$sleeping");
474 $ERROR = RRDs::error;
475 print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR;
476 } else {
477 print "Error in RRD::update for disk-$disk: no data available\n";
478 }
479 }
480
481 sub updateifgraph {
482 my $interface = $_[0];
483 my $period = $_[1];
484
485 RRDs::graph ("$graphs/$interface-$period.png",
486 "--start", "-1$period", "-aPNG", "-i", "-z",
487 "--alt-y-grid", "-w 600", "-h 100",
488 "--color", "SHADEA#EAE9EE",
489 "--color", "SHADEB#EAE9EE",
490 "--color", "BACK#FFFFFF",
491 "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})",
492 "-v$tr{'bytes per second'}",
493 "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE",
494 "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE",
495 "AREA:incoming#00FF00:$tr{'incoming traffic in bytes per second'}\\j",
496 "LINE1:outgoing#0000FF:$tr{'outgoing traffic in bytes per second'}\\j",
497 "GPRINT:incoming:MAX:$tr{'maximal'} $tr{'in'}\\:%8.3lf %sBps",
498 "GPRINT:incoming:AVERAGE:$tr{'average'} $tr{'in'}\\:%8.3lf %sBps",
499 "GPRINT:incoming:LAST:$tr{'current'} $tr{'in'}\\:%8.3lf %sBps\\j",
500 "GPRINT:outgoing:MAX:$tr{'maximal'} $tr{'out'}\\:%8.3lf %sBps",
501 "GPRINT:outgoing:AVERAGE:$tr{'average'} $tr{'out'}\\:%8.3lf %sBps",
502 "GPRINT:outgoing:LAST:$tr{'current'} $tr{'out'}\\:%8.3lf %sBps\\j");
503 $ERROR = RRDs::error;
504 print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;
505 }
506
507 sub updateifdata {
508 my $interface = $_[0];
509
510 if ( ! -e "$rrdlog/$interface.rrd") {
511 RRDs::create ("$rrdlog/$interface.rrd", "--step=300",
512 "DS:incoming:ABSOLUTE:600:0:12500000",
513 "DS:outgoing:ABSOLUTE:600:0:12500000",
514 "RRA:AVERAGE:0.5:1:576",
515 "RRA:AVERAGE:0.5:6:672",
516 "RRA:AVERAGE:0.5:24:732",
517 "RRA:AVERAGE:0.5:144:1460");
518 $ERROR = RRDs::error;
519 print "Error in RRD::create for $interface: $ERROR\n" if $ERROR;
520 }
521
522 my $traffic = gettraffic ($interface);
523 RRDs::update ("$rrdlog/$interface.rrd",
524 "-t", "incoming:outgoing",
525 "N:$traffic");
526 $ERROR = RRDs::error;
527 print "Error in RRD::update for $interface: $ERROR\n" if $ERROR;
528 }
529
530 sub updatefwhitsgraph {
531 my $interval = $_[0];
532
533 RRDs::graph ("$graphs/firewallhits-$interval-area.png",
534 "--start", "-1$interval", "-aPNG", "-i", "-z",
535 "--alt-y-grid", "-w 600", "-h 200",
536 "--color", "SHADEA#EAE9EE",
537 "--color", "SHADEB#EAE9EE",
538 "--color", "BACK#FFFFFF",
539 "-t firewall hits over the last $interval",
540 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
541 "AREA:amount#6464FF:firewallhits",
542 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
543 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
544 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
545 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
546 "AREA:portamount#FF6464:portscans",
547 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
548 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
549 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
550 $ERROR = RRDs::error;
551 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
552
553 RRDs::graph ("$graphs/firewallhits-$interval-line.png",
554 "--start", "-1$interval", "-aPNG", "-i", "-z",
555 "--alt-y-grid", "-w 600", "-h 200",
556 "--color", "SHADEA#EAE9EE",
557 "--color", "SHADEB#EAE9EE",
558 "--color", "BACK#FFFFFF",
559 "-t firewall hits over the last $interval",
560 "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE",
561 "LINE2:amount#6464FF:firewallhits",
562 "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S",
563 "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
564 "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n",
565 "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE",
566 "LINE2:portamount#FF6464:portscans",
567 "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S",
568 "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S",
569 "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min");
570 $ERROR = RRDs::error;
571 print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;
572 }
573
574 sub updatefwhitsdata {
575 my $portamount=0;
576 my $alertaktuell=0;
577 my $aktuell=0;
578 my $portaktuell=0;
579 my $skip=0;
580
581 if (! -e "$rrdlog/firewallhits.rrd")
582 {
583 RRDs::create ("$rrdlog/firewallhits.rrd", "--step=300",
584 "DS:amount:GAUGE:600:0:U",
585 "DS:portamount:GAUGE:600:0:U",
586 "RRA:AVERAGE:0.5:1:576",
587 "RRA:AVERAGE:0.5:6:672",
588 "RRA:AVERAGE:0.5:24:732",
589 "RRA:AVERAGE:0.5:144:1460");
590 $ERROR = RRDs::error;
591 print "Error in RRD::create for cpu: $ERROR\n" if $ERROR;
592 }
593
594 system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits");
595 if (!(open (FILE,'/tmp/messages.fwhits'))) {
596 $skip=1;
597 }
598 $aktuell = 0;
599 if (!$skip) {
600 while (<FILE>) {
601 if (/kernel:.*(IN=.*)$/) {
602 $aktuell++;
603 }
604 }
605 close (FILE);
606 }
607
608 system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits");
609 if (!(open (FILE,'/tmp/snort.fwhits'))) {
610 $skip=1;
611 }
612 $alertaktuell = 0;
613 if (!$skip) {
614 while (<FILE>) {
615 if (/scan.*$/) {
616 $alertaktuell++;
617 }
618 }
619 close (FILE);
620 }
621
622 if (!(open (FILE,'/tmp/messages.fwhits'))) {
623 $skip=1;
624 }
625 $portaktuell = 0;
626 if (!$skip) {
627 while (<FILE>) {
628 if (/kernel:.*(Scan.*)$/) {
629 $portaktuell++;
630 }
631 }
632 close (FILE);
633 }
634
635 system("rm /tmp/messages.fwhits");
636 system("rm /tmp/snort.fwhits");
637
638 $portamount = $portaktuell + $alertaktuell;
639 chomp($portamount);
640 RRDs::update ("$rrdlog/firewallhits.rrd",
641 "N:$aktuell:$portamount");
642 $ERROR = RRDs::error;
643 print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR;
644 }
645
646 # Creates and updates a link quality database
647 # -------------------------------------------
648 sub updatelq {
649 if ( ! -e "$rrdlog/lq.rrd") {
650 RRDs::create ("$rrdlog/lq.rrd", "--step=300",
651 "DS:loss:GAUGE:600:0:100",
652 "DS:roundtrip:GAUGE:600:0:10000",
653 "RRA:AVERAGE:0.5:1:576",
654 "RRA:AVERAGE:0.5:6:672",
655 "RRA:AVERAGE:0.5:24:732",
656 "RRA:AVERAGE:0.5:144:1460");
657 $ERROR = RRDs::error;
658 print "Error in RRD::create for link: $ERROR\n" if $ERROR;
659 }
660 my $packetloss=0;
661 my $roundtrip=0;
662 my $test=0;
663 # LQ_GATEWAY is the ip of your isp's public ip facing you
664 my $LQ_GATEWAY='www.heise.de';
665 my $NUMPINGS=10;
666 my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`;
667 chomp;
668 my @temp = split (/\/|\%|\s/, $pingoutput);
669 $packetloss = $temp[17];
670 $roundtrip = $temp[28];
671 RRDs::update ("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip");
672 $ERROR = RRDs::error;
673 print "Error in RRD::update for line quality: $ERROR\n" if $ERROR;
674 }
675
676 sub updatelqgraph {
677 my $period = $_[0];
678 RRDs::graph ("$graphs/lq-$period.png",
679 "--start", "-1$period", "-aPNG", "-i", "-z",
680 "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
681 "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})",
682 "--lazy",
683 "--color", "SHADEA#EAE9EE",
684 "--color", "SHADEB#EAE9EE",
685 "--color", "BACK#FFFFFF",
686 "-v ms / pkts (% x10)",
687 "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE",
688 "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE",
689 "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
690 "CDEF:loss10=loss,10,*",
691 "CDEF:r0=roundtrip,30,MIN",
692 "CDEF:r1=roundtrip,70,MIN",
693 "CDEF:r2=roundtrip,150,MIN",
694 "CDEF:r3=roundtrip,300,MIN",
695 "AREA:roundtrip#EE7000:>300 ms",
696 "AREA:r3#D88E1B:150-300 ms",
697 "AREA:r2#B9B63F:70-150 ms",
698 "AREA:r1#99E064:30-70 ms",
699 "AREA:r0#80FF80:<30 ms",
700 "AREA:loss10#800000:Packet loss (x10)",
701 "LINE1:roundtrip#707070:",
702 "GPRINT:roundtrip:MAX:$tr{'maximal'}\\:%3.2lf ms",
703 "GPRINT:roundtrip:AVERAGE:$tr{'average'}\\:%3.2lf ms",
704 "GPRINT:roundtrip:LAST:$tr{'current'}\\:%3.2lf ms\\j",
705 "GPRINT:loss:MAX:$tr{'maximal'} Loss\\:%3.2lf%%",
706 "GPRINT:loss:AVERAGE:$tr{'average'} Loss\\:%3.2lf%%",
707 "GPRINT:loss:LAST:$tr{'current'} Loss\\:%3.2lf%%\\j"
708 );
709 $ERROR = RRDs::error;
710 print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
711 }
712
713 sub updatehdddata
714 {
715 if ( ! -e "$rrdlog/hddtemp.rrd")
716 {
717 # database did not exist -> create
718 RRDs::create ("$rrdlog/hddtemp.rrd", "--step=300",
719 "DS:temperature:GAUGE:600:0:100",
720 "RRA:AVERAGE:0.5:1:576",
721 "RRA:AVERAGE:0.5:6:672",
722 "RRA:AVERAGE:0.5:24:732",
723 "RRA:AVERAGE:0.5:144:1460");
724 $ERROR = RRDs::error;
725 print "Error in RRD::create for hdd: $ERROR\n" if $ERROR;
726 }
727
728 $temp = 0;
729 my $hdd_output = '';
730 my $smart_output = '';
731
732 if ( -e "$path_smartctl" )
733 {
734 system("$path_smartctl -iHA $hdd_device > /var/log/hddgraph_smartctl_out");
735 }
736
737 if ( -e "$path_hddtemp" )
738 {
739 $hdd_output = `$path_hddtemp -qn $hdd_device`;
740
741 # I know 4 response possible responses:
742 #
743 # /dev/harddisk: harddisk type: S.M.A.R.T. not available
744 # /dev/harddisk: harddisk type: no sensor
745 # /dev/harddisk: harddisk type: 37°C or °F
746 # 37
747
748 if ( index($hdd_output, "S.M.A.R.T.") != -1 )
749 {
750 $temp = 0;
751 }
752 elsif ( index($hdd_output, "no sensor") != -1 )
753 {
754 $temp = 1;
755 }
756 elsif ( index($hdd_output, "$hdd_device") != -1 )
757 {
758 $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
759 $temp = $1;
760 }
761 else
762 {
763 $hdd_output =~ /(\d+)\s/;
764 $temp = $1;
765 }
766 }
767 elsif ( -e "/var/log/hddgraph_smartctl_out" )
768 {
769 $hdd_output = `cat /var/log/hddgraph_smartctl_out | grep Temperature_`;
770 my @t = split(/\s+/,$hdd_output);
771 $temp = $t[9];
772 }
773 else
774 {
775 $temp = 0;
776 }
777
778 # print "hdd $hdd_output \n";
779 # print "temp $temp \n";
780
781 RRDs::update ("$rrdlog/hddtemp.rrd", "-t", "temperature", "N:$temp");
782
783 $ERROR = RRDs::error;
784 print "Error in RRD::update for hdd: $ERROR\n" if $ERROR;
785 }
786
787 sub updatehddgraph {
788 my $period = $_[0];
789
790 RRDs::graph ("$graphs/hddtemp-$period.png",
791 "--start", "-1$period", "-aPNG", "-i", "-z",
792 "--alt-y-grid", "-w 600", "-h 100",
793 "--color", "SHADEA#EAE9EE",
794 "--color", "SHADEB#EAE9EE",
795 "--color", "BACK#FFFFFF",
796 "-t $tr{'harddisk temperature'} ($tr{'graph per'} $tr{$period})",
797 "DEF:temperature=$rrdlog/hddtemp.rrd:temperature:AVERAGE",
798 "LINE2:temperature#0000FF:$tr{'hdd temperature in'} °C",
799 "GPRINT:temperature:MAX:$tr{'maximal'}\\:%3.0lf °C",
800 "GPRINT:temperature:AVERAGE:$tr{'average'}\\:%3.0lf °C",
801 "GPRINT:temperature:LAST:$tr{'current'}\\:%3.0lf °C",
802 );
803 $ERROR = RRDs::error;
804 print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;
805 }
806
807 sub updatembmondata
808 {
809 if ( ! -e "$rrdlog/mbmon.rrd" )
810 {
811 # database did not exist -> create
812
813 @args = ("$rrdlog/mbmon.rrd");
814
815 push(@args, "--step=300");
816 foreach $key ( sort(keys %mbmon_values) )
817 {
818 push(@args, "DS:$key:GAUGE:600:U:U");
819 }
820 push(@args, "RRA:AVERAGE:0.5:1:576");
821 push(@args, "RRA:AVERAGE:0.5:6:672");
822 push(@args, "RRA:AVERAGE:0.5:24:732");
823 push(@args, "RRA:AVERAGE:0.5:144:1460");
824
825 print("create ". join( ", ", @args)) if ( $dbg );
826
827 RRDs::create (@args);
828 $ERROR = RRDs::error;
829 print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
830 }
831
832 my @ds;
833 my @val;
834 my $template;
835
836 foreach $key ( sort(keys %mbmon_values) )
837 {
838 push(@ds, $key);
839 push(@val, $mbmon_values{$key});
840 }
841
842 $template = join(':', @ds);
843 $value = "N:".join(':', @val);
844
845 print("update template = '$template'\n") if ( $dbg );
846 print("update value = '$value'\n") if ( $dbg );
847
848 RRDs::update("$rrdlog/mbmon.rrd", "-t", $template, $value);
849 $ERROR = RRDs::error;
850 print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
851 }
852
853 sub updatetempgraph
854 {
855 my $type = "temp";
856 my $period = $_[0];
857
858 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
859 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
860 "--color", "SHADEA#EAE9EE",
861 "--color", "SHADEB#EAE9EE",
862 "--color", "BACK#EAE9EE",
863 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
864
865 $count = 1;
866 foreach $key ( sort(keys %mbmon_values) )
867 {
868 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
869 {
870 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
871 {
872 $mbmon_settings{'LABEL-'.$key} = $key;
873 }
874
875 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
876 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C");
877 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C");
878 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C");
879 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j");
880
881 $count++;
882 }
883 }
884
885 if ( $count > 1 )
886 {
887 RRDs::graph ( @args );
888 $ERROR = RRDs::error;
889 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
890 }
891 }
892
893 sub updatefangraph
894 {
895 my $type = "fan";
896 my $period = $_[0];
897
898 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
899 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
900 "--color", "SHADEA#EAE9EE",
901 "--color", "SHADEB#EAE9EE",
902 "--color", "BACK#EAE9EE",
903 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
904
905 $count = 1;
906 foreach $key ( sort(keys %mbmon_values) )
907 {
908 if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
909 {
910 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
911 {
912 $mbmon_settings{'LABEL-'.$key} = $key;
913 }
914
915 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
916 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm");
917 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm");
918 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm");
919 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j");
920
921 $count++;
922 }
923 }
924
925 if ( $count > 1 )
926 {
927 RRDs::graph ( @args );
928 $ERROR = RRDs::error;
929 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
930 }
931 }
932
933 sub updatevoltgraph
934 {
935 my $type = "volt";
936 my $period = $_[0];
937
938 @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
939 "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
940 "--color", "SHADEA#EAE9EE",
941 "--color", "SHADEB#EAE9EE",
942 "--color", "BACK#EAE9EE",
943 "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
944
945 $count = 1;
946 foreach $key ( sort(keys %mbmon_values) )
947 {
948 my $v = substr($key,0,1);
949 if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') )
950 {
951 if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
952 {
953 $mbmon_settings{'LABEL-'.$key} = $key;
954 }
955
956 push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE");
957 push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} V");
958 push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V");
959 push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V");
960 push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j");
961
962 $count++;
963 }
964 }
965
966 if ( $count > 1 )
967 {
968 RRDs::graph ( @args );
969 $ERROR = RRDs::error;
970 print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
971 }
972 }
973
974 ## Update ipac logs
975 system ('/usr/sbin/fetchipac');
976 sleep 8;
977
978 ###
979 ### Squid Graphs
980 ###
981 if ( -e "/var/log/squid/access.log") {
982 system ("/usr/bin/squid-graph -o=/home/httpd/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1");
983 }
984
985 ###
986 ### utf8 conversion
987 ###
988 if ((${Lang::language} eq 'cs') ||
989 (${Lang::language} eq 'hu') ||
990 (${Lang::language} eq 'pl') ||
991 (${Lang::language} eq 'sk')) {
992 # Czech, Hungarian, Polish and Slovak character set
993 foreach my $key(keys %Lang::tr) {
994 from_to($tr{$key}, "utf-8", "iso-8859-2");
995 }
996 } elsif (${Lang::language} eq 'tr') {
997 # Turkish
998 foreach my $key(keys %Lang::tr) {
999 from_to($tr{$key}, "utf-8", "iso-8859-9");
1000 }
1001 } else {
1002 foreach my $key(keys %Lang::tr) {
1003 from_to($tr{$key}, "utf-8", "iso-8859-1");
1004 }
1005 }
1006
1007 ###
1008 ### System graphs
1009 ###
1010 updatecpudata();
1011 updatecpugraph ("day");
1012 updatecpugraph ("week");
1013 updatecpugraph ("month");
1014 updatecpugraph ("year");
1015
1016 updatememdata();
1017 updatememgraph ("day");
1018 updatememgraph ("week");
1019 updatememgraph ("month");
1020 updatememgraph ("year");
1021
1022 updatediskdata();
1023 updatediskgraph ("day");
1024 updatediskgraph ("week");
1025 updatediskgraph ("month");
1026 updatediskgraph ("year");
1027
1028 if (open STAT,"/dev/hda") {
1029 close STAT;
1030 updatediskdatanew ("hda");
1031 updatediskgraphnew ("hda","day");
1032 updatediskgraphnew ("hda","week");
1033 updatediskgraphnew ("hda","month");
1034 updatediskgraphnew ("hda","year");
1035 } else {
1036 if (-e "$graphs/disk-hda-day.png") {
1037 system("rm $graphs/disk-hda-day.png");
1038 }
1039 }
1040
1041 if (open STAT,"/dev/hdb") {
1042 close STAT;
1043 updatediskdatanew ("hdb");
1044 updatediskgraphnew ("hdb","day");
1045 updatediskgraphnew ("hdb","week");
1046 updatediskgraphnew ("hdb","month");
1047 updatediskgraphnew ("hdb","year");
1048 } else {
1049 if (-e "$graphs/disk-hdb-day.png") {
1050 system("rm $graphs/disk-hdb-day.png");
1051 }
1052 }
1053
1054 if (open STAT,"/dev/hdc") {
1055 close STAT;
1056 updatediskdatanew ("hdc");
1057 updatediskgraphnew ("hdc","day");
1058 updatediskgraphnew ("hdc","week");
1059 updatediskgraphnew ("hdc","month");
1060 updatediskgraphnew ("hdc","year");
1061 } else {
1062 if (-e "$graphs/disk-hdc-day.png") {
1063 system("rm $graphs/disk-hdc-day.png");
1064 }
1065 }
1066
1067 if (open STAT,"/dev/hdd") {
1068 close STAT;
1069 updatediskdatanew ("hdd");
1070 updatediskgraphnew ("hdd","day");
1071 updatediskgraphnew ("hdd","week");
1072 updatediskgraphnew ("hdd","month");
1073 updatediskgraphnew ("hdd","year");
1074 } else {
1075 if (-e "$graphs/disk-hdd-day.png") {
1076 system("rm $graphs/disk-hdd-day.png");
1077 }
1078 }
1079
1080 if (open STAT,"/dev/hde") {
1081 close STAT;
1082 updatediskdatanew ("hde");
1083 updatediskgraphnew ("hde","day");
1084 updatediskgraphnew ("hde","week");
1085 updatediskgraphnew ("hde","month");
1086 updatediskgraphnew ("hde","year");
1087 } else {
1088 if (-e "$graphs/disk-hde-day.png") {
1089 system("rm $graphs/disk-hde-day.png");
1090 }
1091 }
1092
1093 if (open STAT,"/dev/hdf") {
1094 close STAT;
1095 updatediskdatanew ("hdf");
1096 updatediskgraphnew ("hdf","day");
1097 updatediskgraphnew ("hdf","week");
1098 updatediskgraphnew ("hdf","month");
1099 updatediskgraphnew ("hdf","year");
1100 } else {
1101 if (-e "$graphs/disk-hdf-day.png") {
1102 system("rm $graphs/disk-hdf-day.png");
1103 }
1104 }
1105
1106 if (open STAT,"/dev/hdg") {
1107 close STAT;
1108 updatediskdatanew ("hdg");
1109 updatediskgraphnew ("hdg","day");
1110 updatediskgraphnew ("hdg","week");
1111 updatediskgraphnew ("hdg","month");
1112 updatediskgraphnew ("hdg","year");
1113 } else {
1114 if (-e "$graphs/disk-hdg-day.png") {
1115 system("rm $graphs/disk-hdg-day.png");
1116 }
1117 }
1118
1119 if (open STAT,"/dev/hdh") {
1120 close STAT;
1121 updatediskdatanew ("hdh");
1122 updatediskgraphnew ("hdh","day");
1123 updatediskgraphnew ("hdh","week");
1124 updatediskgraphnew ("hdh","month");
1125 updatediskgraphnew ("hdh","year");
1126 } else {
1127 if (-e "$graphs/disk-hdh-day.png") {
1128 system("rm $graphs/disk-hdh-day.png");
1129 }
1130 }
1131
1132 ###
1133 ### Firewallhits
1134 ###
1135 updatefwhitsdata();
1136 updatefwhitsgraph ("day");
1137 updatefwhitsgraph ("week");
1138 updatefwhitsgraph ("month");
1139 updatefwhitsgraph ("year");
1140
1141 ###
1142 ### Link Quality
1143 ###
1144 updatelq();
1145 sleep 2;
1146 updatelqgraph("day");
1147 updatelqgraph("week");
1148 updatelqgraph("month");
1149 updatelqgraph("year");
1150
1151 ###
1152 ### HDDTEMP-Graphs for /dev/harddisk
1153 ###
1154 updatehdddata();
1155 updatehddgraph ("day");
1156 updatehddgraph ("week");
1157 updatehddgraph ("month");
1158 updatehddgraph ("year");
1159
1160 updatembmondata();
1161
1162 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1163 {
1164 updatetempgraph ("day");
1165 updatetempgraph ("week");
1166 updatetempgraph ("month");
1167 updatetempgraph ("year");
1168 }
1169 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
1170 {
1171 updatefangraph ("day");
1172 updatefangraph ("week");
1173 updatefangraph ("month");
1174 updatefangraph ("year");
1175 }
1176 if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
1177 {
1178 updatevoltgraph ("day");
1179 updatevoltgraph ("week");
1180 updatevoltgraph ("month");
1181 updatevoltgraph ("year");
1182 }
1183
1184 ###
1185 ### Network Graphs
1186 ###
1187 @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`;
1188 if (@ipacsum) {
1189 updateifdata ("GREEN");
1190 updateifdata ("RED");
1191 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ ) {
1192 updateifdata ("ORANGE");
1193 }
1194 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ ) {
1195 updateifdata ("BLUE");
1196 }
1197 }
1198 if ( -e "$rrdlog/GREEN.rrd") {
1199 updateifgraph ("GREEN", "day");
1200 updateifgraph ("GREEN", "week");
1201 updateifgraph ("GREEN", "month");
1202 updateifgraph ("GREEN", "year");
1203 }
1204
1205 if ( -e "$rrdlog/RED.rrd") {
1206 updateifgraph ("RED", "day");
1207 updateifgraph ("RED", "week");
1208 updateifgraph ("RED", "month");
1209 updateifgraph ("RED", "year");
1210 }
1211
1212 if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ && -e "$rrdlog/ORANGE.rrd") {
1213 updateifgraph ("ORANGE", "day");
1214 updateifgraph ("ORANGE", "week");
1215 updateifgraph ("ORANGE", "month");
1216 updateifgraph ("ORANGE", "year");
1217 }
1218
1219 if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ && -e "$rrdlog/BLUE.rrd") {
1220 updateifgraph ("BLUE", "day");
1221 updateifgraph ("BLUE", "week");
1222 updateifgraph ("BLUE", "month");
1223 updateifgraph ("BLUE", "year");
1224 }
1225
1226 system("chmod -R 0777 /home/httpd/html/graphs");
1227 system("chmod -R 0777 /home/httpd/html/sgraph");
1228