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