]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
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 | ############################################################################ | |
60cbd6e7 | 24 | |
cd1a2927 MT |
25 | use strict; |
26 | #use warnings; | |
27 | ||
28 | use RRDs; | |
986e08d9 | 29 | require "/var/ipfire/general-functions.pl"; |
cd1a2927 MT |
30 | require "${General::swroot}/lang.pl"; |
31 | ||
32 | my (%settings, @ipacsum, $iface, $ERROR); | |
33 | &General::readhash("${General::swroot}/ethernet/settings", \%settings); | |
52345790 MT |
34 | my %mbmon_settings = (); |
35 | &General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); | |
36 | ||
cd1a2927 MT |
37 | # Added for conversion of utf-8 characters |
38 | use Encode 'from_to'; | |
39 | my %tr=(); | |
40 | ||
de53a053 CS |
41 | system("chmod 777 /srv/web/ipfire/html/graphs"); |
42 | ||
cd1a2927 MT |
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')) { | |
350b52c5 | 53 | eval `/bin/cat "${General::swroot}/langs/en.pl"`; |
cd1a2927 | 54 | } else { |
350b52c5 | 55 | %tr=%Lang::tr; # use translated version for other languages |
cd1a2927 MT |
56 | } |
57 | ||
58 | # Settings | |
59 | my $rrdlog = "/var/log/rrd"; | |
fd0763dc | 60 | my $graphs = "/srv/web/ipfire/html/graphs"; |
cd1a2927 | 61 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; |
60cbd6e7 | 62 | my $hdd_device = "/dev/harddisk"; |
a68fedca | 63 | my $temp = ''; |
52345790 MT |
64 | my %mbmon_values = (); |
65 | my $key; | |
66 | my $value; | |
67 | my @args = (); | |
68 | my $count = 0; | |
69 | my $ERROR; | |
70 | my $dbg = 0; | |
52345790 | 71 | my $path_smartctl = "/usr/sbin/smartctl"; |
e3a8510a | 72 | my $path_hddtemp = "/usr/sbin/hddtemp"; |
52345790 | 73 | |
4b4aec3a CS |
74 | my %color = (); |
75 | my %mainsettings = (); | |
76 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
77 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
52345790 MT |
78 | |
79 | open(MBMON_OUT, ">/var/log/mbmon-values"); | |
80 | open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ; | |
81 | ||
82 | while( $_ = <FD> ) | |
83 | { | |
84 | next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ; | |
85 | $key = $1 ; | |
86 | $value = $2 ; | |
87 | $key =~ y/A-Z/a-z/ ; | |
88 | $mbmon_values{$key} = $value; | |
89 | print(MBMON_OUT "$key=$value\n"); | |
90 | } | |
91 | close(FD); | |
92 | close(MBMON_OUT); | |
cd1a2927 MT |
93 | |
94 | sub gettraffic { | |
350b52c5 | 95 | my $interface = $_[0]; |
cd1a2927 | 96 | |
350b52c5 CS |
97 | my $bytesin=0; |
98 | my $bytesout=0; | |
cd1a2927 | 99 | |
350b52c5 CS |
100 | foreach (@ipacsum) |
101 | { | |
102 | # Incoming... | |
103 | $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
cd1a2927 | 104 | |
350b52c5 CS |
105 | # Forwarded Incoming... |
106 | $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
cd1a2927 | 107 | |
350b52c5 CS |
108 | # Outgoing... |
109 | $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
cd1a2927 | 110 | |
350b52c5 CS |
111 | # Forwarded Outgoing... |
112 | $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
113 | } | |
114 | return "$bytesin:$bytesout"; | |
cd1a2927 MT |
115 | } |
116 | ||
117 | sub updatecpudata { | |
350b52c5 CS |
118 | if ( ! -e "$rrdlog/cpu.rrd") { |
119 | RRDs::create ("$rrdlog/cpu.rrd", "--step=300", | |
60412147 CS |
120 | "DS:user:COUNTER:600:0:500000000", |
121 | "DS:system:COUNTER:600:0:500000000", | |
122 | "DS:idle:COUNTER:600:0:500000000", | |
123 | "DS:iowait:COUNTER:600:0:500000000", | |
124 | "DS:irq:COUNTER:600:0:500000000", | |
350b52c5 CS |
125 | "RRA:AVERAGE:0.5:1:576", |
126 | "RRA:AVERAGE:0.5:6:672", | |
127 | "RRA:AVERAGE:0.5:24:732", | |
128 | "RRA:AVERAGE:0.5:144:1460"); | |
129 | $ERROR = RRDs::error; | |
130 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
131 | } | |
132 | ||
60412147 | 133 | my ($cpu, $user, $nice, $system, $idle, $iowait, $irq, $softirq); |
350b52c5 | 134 | |
60412147 CS |
135 | open STAT, "/proc/stat"; |
136 | while(<STAT>) { | |
137 | chomp; | |
138 | /^cpu\s/ or next; | |
139 | ($cpu, $user, $nice, $system, $idle, $iowait, $irq, $softirq) = split /\s+/; | |
140 | last; | |
141 | } | |
142 | close STAT; | |
350b52c5 | 143 | $user += $nice; |
60412147 CS |
144 | $irq += $softirq; |
145 | ||
350b52c5 CS |
146 | |
147 | RRDs::update ("$rrdlog/cpu.rrd", | |
60412147 CS |
148 | "-t", "user:system:idle:iowait:irq", |
149 | "N:$user:$system:$idle:$iowait:$irq"); | |
350b52c5 CS |
150 | $ERROR = RRDs::error; |
151 | print "Error in RRD::update for cpu: $ERROR\n" if $ERROR; | |
cd1a2927 MT |
152 | |
153 | } | |
154 | ||
207cc1cf | 155 | sub updateloaddata { |
350b52c5 CS |
156 | if ( ! -e "$rrdlog/load.rrd") { |
157 | RRDs::create ("$rrdlog/load.rrd", "--step=60", | |
158 | "DS:load1:GAUGE:120:0:U", | |
159 | "DS:load5:GAUGE:120:0:U", | |
160 | "DS:load15:GAUGE:120:0:U", | |
161 | "RRA:AVERAGE:0.5:1:2160", | |
162 | "RRA:AVERAGE:0.5:5:2016", | |
163 | "RRA:AVERAGE:0.5:15:2880", | |
164 | "RRA:AVERAGE:0.5:60:8760"); | |
207cc1cf | 165 | |
350b52c5 CS |
166 | $ERROR = RRDs::error; |
167 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
168 | } | |
cd1a2927 MT |
169 | } |
170 | ||
171 | sub updatememdata { | |
350b52c5 CS |
172 | my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree, $swaptotal); |
173 | if ( ! -e "$rrdlog/mem.rrd") { | |
174 | RRDs::create ("$rrdlog/mem.rrd", "--step=300", | |
175 | "DS:memused:ABSOLUTE:600:0:5000000000", | |
176 | "DS:memfree:ABSOLUTE:600:0:5000000000", | |
177 | "DS:memshared:ABSOLUTE:600:0:5000000000", | |
178 | "DS:membuffers:ABSOLUTE:600:0:5000000000", | |
179 | "DS:memcache:ABSOLUTE:600:0:5000000000", | |
180 | "DS:swapused:ABSOLUTE:600:0:5000000000", | |
181 | "DS:swapfree:ABSOLUTE:600:0:5000000000", | |
182 | "RRA:AVERAGE:0.5:1:576", | |
183 | "RRA:AVERAGE:0.5:6:672", | |
184 | "RRA:AVERAGE:0.5:24:732", | |
185 | "RRA:AVERAGE:0.5:144:1460"); | |
186 | $ERROR = RRDs::error; | |
187 | print "Error in RRD::create for mem: $ERROR\n" if $ERROR; | |
188 | } | |
189 | ||
190 | open MEM, "/proc/meminfo"; | |
191 | while(<MEM>) { | |
192 | chomp; | |
193 | if ($_ =~ /^MemTotal:/) { | |
194 | my @temp = split (/\s+/, $_); | |
195 | $memused = $temp[1]; | |
196 | } elsif ($_ =~ /^MemFree:/) { | |
197 | my @temp = split (/\s+/, $_); | |
198 | $memfree = $temp[1]; | |
199 | } elsif ($_ =~ /^Cached:/) { | |
200 | my @temp = split (/\s+/, $_); | |
201 | $memcache = $temp[1]; | |
202 | } elsif ($_ =~ /^Buffers:/) { | |
203 | my @temp = split (/\s+/, $_); | |
204 | $membuffers = $temp[1]; | |
205 | } elsif ($_ =~ /^SwapTotal:/) { | |
206 | my @temp = split (/\s+/, $_); | |
207 | $swaptotal = $temp[1]; | |
208 | } elsif ($_ =~ /^SwapFree:/) { | |
209 | my @temp = split (/\s+/, $_); | |
210 | $swapfree = $temp[1]; | |
211 | } | |
212 | } | |
213 | close MEM; | |
214 | ||
215 | system("/bin/df > /tmp/diskfree"); | |
216 | open DF, "/tmp/diskfree"; | |
217 | while(<DF>) { | |
218 | chomp; | |
219 | if ($_ =~ /^shm/) { | |
220 | my @temp = split (/\s+/, $_); | |
221 | $memshared = $temp[2]; | |
222 | } | |
223 | } | |
224 | close DF; | |
225 | system("/bin/rm -f /tmp/diskfree"); | |
226 | ||
227 | $swapused = $swaptotal-$swapfree; | |
228 | RRDs::update ("$rrdlog/mem.rrd", | |
229 | "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree", | |
230 | "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree"); | |
231 | $ERROR = RRDs::error; | |
232 | print "Error in RRD::update for mem: $ERROR\n" if $ERROR; | |
cd1a2927 MT |
233 | } |
234 | ||
235 | sub updatediskdata { | |
350b52c5 CS |
236 | my $disk = $_[0]; |
237 | my ($readsect, $writesect, $trash); | |
238 | if ( ! -e "$rrdlog/disk-$disk.rrd") { | |
239 | RRDs::create ("$rrdlog/disk-$disk.rrd", "--step=300", | |
240 | "DS:readsect:COUNTER:600:0:5000000000", | |
241 | "DS:writesect:COUNTER:600:0:5000000000", | |
242 | "RRA:AVERAGE:0.5:1:576", | |
243 | "RRA:AVERAGE:0.5:6:672", | |
244 | "RRA:AVERAGE:0.5:24:732", | |
245 | "RRA:AVERAGE:0.5:144:1460"); | |
246 | $ERROR = RRDs::error; | |
247 | print "Error in RRD::create for disk $disk: $ERROR\n" if $ERROR; | |
248 | } | |
249 | ||
250 | my $Zeilen = `/usr/bin/iostat $disk | tail -2 | head -1`; | |
251 | ($trash, $trash, $trash, $trash, $readsect, $writesect) = split(/\s+/,$Zeilen); | |
252 | ||
253 | print "\nread:".$readsect."write:".$writesect."\n"; | |
254 | ||
255 | if ($readsect && $writesect) { | |
256 | RRDs::update ("$rrdlog/disk-$disk.rrd", | |
257 | "-t", "readsect:writesect", | |
258 | "N:$readsect:$writesect"); | |
259 | $ERROR = RRDs::error; | |
260 | print "Error in RRD::update for disk $disk: $ERROR\n" if $ERROR; | |
261 | } else { | |
262 | print "Error in RRD::update for disk: $disk no data available\n"; | |
263 | } | |
cd1a2927 MT |
264 | } |
265 | ||
266 | sub updateifdata { | |
350b52c5 CS |
267 | my $interface = $_[0]; |
268 | ||
269 | if ( ! -e "$rrdlog/$interface.rrd") { | |
270 | RRDs::create ("$rrdlog/$interface.rrd", "--step=300", | |
271 | "DS:incoming:ABSOLUTE:600:0:12500000", | |
272 | "DS:outgoing:ABSOLUTE:600:0:12500000", | |
273 | "RRA:AVERAGE:0.5:1:576", | |
274 | "RRA:AVERAGE:0.5:6:672", | |
275 | "RRA:AVERAGE:0.5:24:732", | |
276 | "RRA:AVERAGE:0.5:144:1460"); | |
277 | $ERROR = RRDs::error; | |
278 | print "Error in RRD::create for $interface: $ERROR\n" if $ERROR; | |
279 | } | |
280 | ||
281 | my $traffic = gettraffic ($interface); | |
282 | RRDs::update ("$rrdlog/$interface.rrd", | |
283 | "-t", "incoming:outgoing", | |
284 | "N:$traffic"); | |
285 | $ERROR = RRDs::error; | |
286 | print "Error in RRD::update for $interface: $ERROR\n" if $ERROR; | |
df8c7810 MT |
287 | } |
288 | ||
289 | sub updatefwhitsdata { | |
350b52c5 CS |
290 | my $portamount=0; |
291 | my $alertaktuell=0; | |
292 | my $aktuell=0; | |
293 | my $portaktuell=0; | |
294 | my $skip=0; | |
295 | ||
296 | if (! -e "$rrdlog/firewallhits.rrd") | |
297 | { | |
298 | RRDs::create ("$rrdlog/firewallhits.rrd", "--step=300", | |
299 | "DS:amount:GAUGE:600:0:U", | |
300 | "DS:portamount:GAUGE:600:0:U", | |
301 | "RRA:AVERAGE:0.5:1:576", | |
302 | "RRA:AVERAGE:0.5:6:672", | |
303 | "RRA:AVERAGE:0.5:24:732", | |
304 | "RRA:AVERAGE:0.5:144:1460"); | |
305 | $ERROR = RRDs::error; | |
306 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
307 | } | |
308 | ||
309 | system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits"); | |
310 | if (!(open (FILE,'/tmp/messages.fwhits'))) { | |
df8c7810 | 311 | $skip=1; |
350b52c5 CS |
312 | } |
313 | $aktuell = 0; | |
314 | if (!$skip) { | |
315 | while (<FILE>) { | |
316 | if (/kernel:.*(IN=.*)$/) { | |
317 | $aktuell++; | |
318 | } | |
319 | } | |
320 | close (FILE); | |
321 | } | |
322 | ||
323 | system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits"); | |
324 | if (!(open (FILE,'/tmp/snort.fwhits'))) { | |
df8c7810 | 325 | $skip=1; |
350b52c5 CS |
326 | } |
327 | $alertaktuell = 0; | |
328 | if (!$skip) { | |
329 | while (<FILE>) { | |
330 | if (/scan.*$/) { | |
331 | $alertaktuell++; | |
332 | } | |
333 | } | |
334 | close (FILE); | |
335 | } | |
336 | ||
337 | if (!(open (FILE,'/tmp/messages.fwhits'))) { | |
df8c7810 | 338 | $skip=1; |
350b52c5 CS |
339 | } |
340 | $portaktuell = 0; | |
341 | if (!$skip) { | |
342 | while (<FILE>) { | |
343 | if (/kernel:.*(Scan.*)$/) { | |
344 | $portaktuell++; | |
345 | } | |
346 | } | |
347 | close (FILE); | |
348 | } | |
349 | ||
350 | system("rm /tmp/messages.fwhits"); | |
351 | system("rm /tmp/snort.fwhits"); | |
352 | ||
353 | $portamount = $portaktuell + $alertaktuell; | |
354 | chomp($portamount); | |
355 | RRDs::update ("$rrdlog/firewallhits.rrd", | |
356 | "N:$aktuell:$portamount"); | |
357 | $ERROR = RRDs::error; | |
358 | print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR; | |
df8c7810 MT |
359 | } |
360 | ||
072cd997 MT |
361 | # Creates and updates a link quality database |
362 | # ------------------------------------------- | |
363 | sub updatelq { | |
350b52c5 CS |
364 | if ( ! -e "$rrdlog/lq.rrd") { |
365 | RRDs::create ("$rrdlog/lq.rrd", "--step=300", | |
366 | "DS:loss:GAUGE:600:0:100", | |
367 | "DS:roundtrip:GAUGE:600:0:10000", | |
368 | "RRA:AVERAGE:0.5:1:576", | |
369 | "RRA:AVERAGE:0.5:6:672", | |
370 | "RRA:AVERAGE:0.5:24:732", | |
371 | "RRA:AVERAGE:0.5:144:1460"); | |
372 | $ERROR = RRDs::error; | |
373 | print "Error in RRD::create for link: $ERROR\n" if $ERROR; | |
374 | } | |
375 | my $packetloss=0; | |
376 | my $roundtrip=0; | |
377 | my $test=0; | |
378 | # LQ_GATEWAY is the ip of your isp's public ip facing you | |
379 | my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`; | |
380 | my $NUMPINGS=10; | |
381 | my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`; | |
382 | chomp; | |
383 | my @temp = split (/\/|\%|\s/, $pingoutput); | |
384 | $packetloss = $temp[17]; | |
385 | $roundtrip = $temp[28]; | |
386 | RRDs::update ("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip"); | |
387 | $ERROR = RRDs::error; | |
388 | print "Error in RRD::update for line quality: $ERROR\n" if $ERROR; | |
072cd997 MT |
389 | } |
390 | ||
60cbd6e7 MT |
391 | sub updatehdddata |
392 | { | |
9217f236 MT |
393 | my $disk = $_[0]; |
394 | if ( ! -e "$rrdlog/hddtemp-$disk.rrd") | |
60cbd6e7 MT |
395 | { |
396 | # database did not exist -> create | |
9217f236 | 397 | RRDs::create ("$rrdlog/hddtemp-$disk.rrd", "--step=300", |
60cbd6e7 MT |
398 | "DS:temperature:GAUGE:600:0:100", |
399 | "RRA:AVERAGE:0.5:1:576", | |
400 | "RRA:AVERAGE:0.5:6:672", | |
401 | "RRA:AVERAGE:0.5:24:732", | |
402 | "RRA:AVERAGE:0.5:144:1460"); | |
403 | $ERROR = RRDs::error; | |
9217f236 | 404 | print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR; |
60cbd6e7 MT |
405 | } |
406 | ||
52345790 MT |
407 | $temp = 0; |
408 | my $hdd_output = ''; | |
409 | my $smart_output = ''; | |
60cbd6e7 | 410 | |
52345790 | 411 | if ( -e "$path_smartctl" ) |
60cbd6e7 | 412 | { |
9217f236 | 413 | system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk"); |
60cbd6e7 | 414 | } |
52345790 MT |
415 | |
416 | if ( -e "$path_hddtemp" ) | |
60cbd6e7 | 417 | { |
9217f236 | 418 | $hdd_output = `$path_hddtemp -qn /dev/$disk`; |
52345790 MT |
419 | |
420 | # I know 4 response possible responses: | |
421 | # | |
422 | # /dev/harddisk: harddisk type: S.M.A.R.T. not available | |
423 | # /dev/harddisk: harddisk type: no sensor | |
350b52c5 | 424 | # /dev/harddisk: harddisk type: 37?C or ?F |
52345790 MT |
425 | # 37 |
426 | ||
427 | if ( index($hdd_output, "S.M.A.R.T.") != -1 ) | |
428 | { | |
429 | $temp = 0; | |
430 | } | |
431 | elsif ( index($hdd_output, "no sensor") != -1 ) | |
432 | { | |
433 | $temp = 1; | |
434 | } | |
9217f236 | 435 | elsif ( index($hdd_output, "$disk") != -1 ) |
52345790 MT |
436 | { |
437 | $hdd_output =~ /.*:.*:\s*(\d+).*\s/; | |
438 | $temp = $1; | |
439 | } | |
440 | else | |
441 | { | |
442 | $hdd_output =~ /(\d+)\s/; | |
443 | $temp = $1; | |
444 | } | |
60cbd6e7 | 445 | } |
9217f236 | 446 | elsif ( -e "/var/log/smartctl_out_hddtemp-$disk" ) |
60cbd6e7 | 447 | { |
9217f236 | 448 | $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`; |
52345790 MT |
449 | my @t = split(/\s+/,$hdd_output); |
450 | $temp = $t[9]; | |
60cbd6e7 MT |
451 | } |
452 | else | |
453 | { | |
52345790 | 454 | $temp = 0; |
60cbd6e7 MT |
455 | } |
456 | ||
52345790 MT |
457 | # print "hdd $hdd_output \n"; |
458 | # print "temp $temp \n"; | |
459 | ||
9217f236 | 460 | RRDs::update ("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp"); |
60cbd6e7 MT |
461 | |
462 | $ERROR = RRDs::error; | |
9217f236 | 463 | print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR; |
60cbd6e7 MT |
464 | } |
465 | ||
52345790 MT |
466 | sub updatembmondata |
467 | { | |
e3a8510a | 468 | if ( ! -e "$rrdlog/mbmon.rrd" ) |
52345790 MT |
469 | { |
470 | # database did not exist -> create | |
471 | ||
e3a8510a | 472 | @args = ("$rrdlog/mbmon.rrd"); |
52345790 MT |
473 | |
474 | push(@args, "--step=300"); | |
475 | foreach $key ( sort(keys %mbmon_values) ) | |
476 | { | |
477 | push(@args, "DS:$key:GAUGE:600:U:U"); | |
478 | } | |
479 | push(@args, "RRA:AVERAGE:0.5:1:576"); | |
480 | push(@args, "RRA:AVERAGE:0.5:6:672"); | |
481 | push(@args, "RRA:AVERAGE:0.5:24:732"); | |
482 | push(@args, "RRA:AVERAGE:0.5:144:1460"); | |
483 | ||
484 | print("create ". join( ", ", @args)) if ( $dbg ); | |
485 | ||
486 | RRDs::create (@args); | |
487 | $ERROR = RRDs::error; | |
488 | print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR; | |
489 | } | |
490 | ||
491 | my @ds; | |
492 | my @val; | |
493 | my $template; | |
494 | ||
495 | foreach $key ( sort(keys %mbmon_values) ) | |
496 | { | |
497 | push(@ds, $key); | |
498 | push(@val, $mbmon_values{$key}); | |
499 | } | |
500 | ||
501 | $template = join(':', @ds); | |
502 | $value = "N:".join(':', @val); | |
503 | ||
504 | print("update template = '$template'\n") if ( $dbg ); | |
505 | print("update value = '$value'\n") if ( $dbg ); | |
506 | ||
e3a8510a | 507 | RRDs::update("$rrdlog/mbmon.rrd", "-t", $template, $value); |
52345790 MT |
508 | $ERROR = RRDs::error; |
509 | print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR; | |
510 | } | |
511 | ||
cd1a2927 MT |
512 | ## Update ipac logs |
513 | system ('/usr/sbin/fetchipac'); | |
514 | sleep 8; | |
515 | ||
516 | ### | |
517 | ### Squid Graphs | |
518 | ### | |
519 | if ( -e "/var/log/squid/access.log") { | |
350b52c5 | 520 | system ("/usr/bin/squid-graph -o=/srv/web/ipfire/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1"); |
cd1a2927 MT |
521 | } |
522 | ||
523 | ### | |
524 | ### utf8 conversion | |
525 | ### | |
526 | if ((${Lang::language} eq 'cs') || | |
527 | (${Lang::language} eq 'hu') || | |
528 | (${Lang::language} eq 'pl') || | |
529 | (${Lang::language} eq 'sk')) { | |
350b52c5 CS |
530 | # Czech, Hungarian, Polish and Slovak character set |
531 | foreach my $key(keys %Lang::tr) { | |
532 | from_to($tr{$key}, "utf-8", "iso-8859-2"); | |
533 | } | |
cd1a2927 | 534 | } elsif (${Lang::language} eq 'tr') { |
350b52c5 CS |
535 | # Turkish |
536 | foreach my $key(keys %Lang::tr) { | |
537 | from_to($tr{$key}, "utf-8", "iso-8859-9"); | |
538 | } | |
cd1a2927 | 539 | } else { |
350b52c5 CS |
540 | foreach my $key(keys %Lang::tr) { |
541 | from_to($tr{$key}, "utf-8", "iso-8859-1"); | |
542 | } | |
cd1a2927 MT |
543 | } |
544 | ||
545 | ### | |
546 | ### System graphs | |
547 | ### | |
548 | updatecpudata(); | |
207cc1cf | 549 | updateloaddata(); |
cd1a2927 | 550 | updatememdata(); |
6c666a3b | 551 | |
350b52c5 CS |
552 | my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; |
553 | print "\nFound following amount of disks:".@disks."\n"; | |
554 | foreach (@disks){ | |
555 | my $disk = $_; | |
556 | chomp $disk; | |
557 | print "Working on disk ".$disk.".\n"; | |
558 | updatediskdata($disk); | |
6c666a3b MT |
559 | } |
560 | ||
df8c7810 MT |
561 | ### |
562 | ### Firewallhits | |
563 | ### | |
564 | updatefwhitsdata(); | |
df8c7810 | 565 | |
072cd997 MT |
566 | ### |
567 | ### Link Quality | |
568 | ### | |
569 | updatelq(); | |
072cd997 | 570 | |
60cbd6e7 MT |
571 | ### |
572 | ### HDDTEMP-Graphs for /dev/harddisk | |
573 | ### | |
9217f236 | 574 | |
350b52c5 CS |
575 | my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; |
576 | print "\nFound following amount of disks for hddtemp:".@disks."\n"; | |
577 | foreach (@disks){ | |
578 | my $disk = $_; | |
579 | chomp $disk; | |
580 | updatehdddata ($disk); | |
52345790 MT |
581 | } |
582 | ||
cd1a2927 MT |
583 | ### |
584 | ### Network Graphs | |
585 | ### | |
586 | @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`; | |
587 | if (@ipacsum) { | |
350b52c5 CS |
588 | updateifdata ("GREEN"); |
589 | updateifdata ("RED"); | |
590 | if ($settings{'CONFIG_TYPE'} =~ /^(2|4)$/ ) { | |
591 | updateifdata ("ORANGE"); | |
592 | } | |
593 | if ($settings{'CONFIG_TYPE'} =~ /^(3|4)$/ ) { | |
594 | updateifdata ("BLUE"); | |
595 | } | |
cd1a2927 | 596 | } |