]>
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 | ||
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"; | |
fd0763dc | 58 | my $graphs = "/srv/web/ipfire/html/graphs"; |
cd1a2927 | 59 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; |
60cbd6e7 | 60 | my $hdd_device = "/dev/harddisk"; |
a68fedca | 61 | my $temp = ''; |
52345790 MT |
62 | my %mbmon_values = (); |
63 | my $key; | |
64 | my $value; | |
65 | my @args = (); | |
66 | my $count = 0; | |
67 | my $ERROR; | |
68 | my $dbg = 0; | |
52345790 | 69 | my $path_smartctl = "/usr/sbin/smartctl"; |
e3a8510a | 70 | my $path_hddtemp = "/usr/sbin/hddtemp"; |
52345790 | 71 | |
4b4aec3a CS |
72 | my %color = (); |
73 | my %mainsettings = (); | |
74 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
75 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
52345790 MT |
76 | |
77 | open(MBMON_OUT, ">/var/log/mbmon-values"); | |
78 | open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ; | |
79 | ||
80 | while( $_ = <FD> ) | |
81 | { | |
82 | next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ; | |
83 | $key = $1 ; | |
84 | $value = $2 ; | |
85 | $key =~ y/A-Z/a-z/ ; | |
86 | $mbmon_values{$key} = $value; | |
87 | print(MBMON_OUT "$key=$value\n"); | |
88 | } | |
89 | close(FD); | |
90 | close(MBMON_OUT); | |
cd1a2927 MT |
91 | |
92 | sub gettraffic { | |
93 | my $interface = $_[0]; | |
94 | ||
95 | my $bytesin=0; | |
96 | my $bytesout=0; | |
97 | ||
98 | foreach (@ipacsum) | |
99 | { | |
100 | # Incoming... | |
101 | $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
102 | ||
103 | # Forwarded Incoming... | |
104 | $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
105 | ||
106 | # Outgoing... | |
107 | $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
108 | ||
109 | # Forwarded Outgoing... | |
110 | $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
111 | } | |
112 | return "$bytesin:$bytesout"; | |
113 | } | |
114 | ||
115 | sub updatecpugraph { | |
116 | my $period = $_[0]; | |
117 | ||
118 | RRDs::graph ("$graphs/cpu-$period.png", | |
119 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
120 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
4b4aec3a CS |
121 | "--color", "SHADEA".$color{"color19"}, |
122 | "--color", "SHADEB".$color{"color20"}, | |
123 | "--color", "BACK".$color{"color21"}, | |
cd1a2927 MT |
124 | "-t $tr{'cpu usage per'} $tr{$period}", |
125 | "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE", | |
126 | "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE", | |
127 | "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE", | |
128 | "CDEF:total=user,system,idle,+,+", | |
129 | "CDEF:userpct=100,user,total,/,*", | |
130 | "CDEF:systempct=100,system,total,/,*", | |
131 | "CDEF:idlepct=100,idle,total,/,*", | |
4b4aec3a CS |
132 | "AREA:userpct".$color{"color11"}.":$tr{'user cpu usage'}\\j", |
133 | "STACK:systempct".$color{"color13"}.":$tr{'system cpu usage'}\\j", | |
134 | "STACK:idlepct".$color{"color12"}.":$tr{'idle cpu usage'}\\j", | |
cd1a2927 MT |
135 | "GPRINT:userpct:MAX:$tr{'maximal'} $tr{'user cpu'}\\:%3.2lf%%", |
136 | "GPRINT:userpct:AVERAGE:$tr{'average'} $tr{'user cpu'}\\:%3.2lf%%", | |
137 | "GPRINT:userpct:LAST:$tr{'current'} $tr{'user cpu'}\\:%3.2lf%%\\j", | |
138 | "GPRINT:systempct:MAX:$tr{'maximal'} $tr{'system cpu'}\\:%3.2lf%%", | |
139 | "GPRINT:systempct:AVERAGE:$tr{'average'} $tr{'system cpu'}\\:%3.2lf%%", | |
140 | "GPRINT:systempct:LAST:$tr{'current'} $tr{'system cpu'}\\:%3.2lf%%\\j", | |
141 | "GPRINT:idlepct:MAX:$tr{'maximal'} $tr{'idle cpu'}\\:%3.2lf%%", | |
142 | "GPRINT:idlepct:AVERAGE:$tr{'average'} $tr{'idle cpu'}\\:%3.2lf%%", | |
143 | "GPRINT:idlepct:LAST:$tr{'current'} $tr{'idle cpu'}\\:%3.2lf%%\\j"); | |
144 | $ERROR = RRDs::error; | |
145 | print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; | |
146 | } | |
147 | ||
148 | sub updatecpudata { | |
149 | if ( ! -e "$rrdlog/cpu.rrd") { | |
150 | RRDs::create ("$rrdlog/cpu.rrd", "--step=300", | |
151 | "DS:user:COUNTER:600:0:500000000", | |
152 | "DS:system:COUNTER:600:0:500000000", | |
153 | "DS:idle:COUNTER:600:0:500000000", | |
154 | "RRA:AVERAGE:0.5:1:576", | |
155 | "RRA:AVERAGE:0.5:6:672", | |
156 | "RRA:AVERAGE:0.5:24:732", | |
157 | "RRA:AVERAGE:0.5:144:1460"); | |
158 | $ERROR = RRDs::error; | |
159 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
160 | } | |
161 | ||
162 | my ($cpu, $user, $nice, $system, $idle); | |
163 | ||
164 | open STAT, "/proc/stat"; | |
165 | while(<STAT>) { | |
166 | chomp; | |
167 | /^cpu\s/ or next; | |
168 | ($cpu, $user, $nice, $system, $idle) = split /\s+/; | |
169 | last; | |
170 | } | |
171 | close STAT; | |
172 | $user += $nice; | |
173 | ||
174 | RRDs::update ("$rrdlog/cpu.rrd", | |
175 | "-t", "user:system:idle", | |
176 | "N:$user:$system:$idle"); | |
177 | $ERROR = RRDs::error; | |
178 | print "Error in RRD::update for cpu: $ERROR\n" if $ERROR; | |
179 | ||
180 | } | |
181 | ||
207cc1cf MT |
182 | sub updateloadgraph { |
183 | my $period = $_[0]; | |
184 | ||
185 | RRDs::graph ("$graphs/load-$period.png", | |
186 | "--start", "-1$period", "-aPNG", | |
187 | "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid", | |
188 | "-t Load Average", | |
4b4aec3a CS |
189 | "--color", "SHADEA".$color{"color19"}, |
190 | "--color", "SHADEB".$color{"color20"}, | |
191 | "--color", "BACK".$color{"color21"}, | |
207cc1cf MT |
192 | "DEF:load1=$rrdlog/load.rrd:load1:AVERAGE", |
193 | "DEF:load5=$rrdlog/load.rrd:load5:AVERAGE", | |
194 | "DEF:load15=$rrdlog/load.rrd:load15:AVERAGE", | |
4b4aec3a | 195 | "AREA:load1".$color{"color13"}.":1 Minute, letzter\\:", |
c6aa4ac1 | 196 | "GPRINT:load1:LAST:%5.2lf\\j", |
4b4aec3a | 197 | "AREA:load5".$color{"color18"}.":5 Minuten, letzter\\:", |
c6aa4ac1 | 198 | "GPRINT:load5:LAST:%5.2lf\\j", |
4b4aec3a | 199 | "AREA:load15".$color{"color14"}.":15 Minuten, letzter\\:", |
c6aa4ac1 | 200 | "GPRINT:load15:LAST:%5.2lf\\j", |
4b4aec3a CS |
201 | "LINE1:load5".$color{"color13"}, |
202 | "LINE1:load1".$color{"color18"}); | |
207cc1cf MT |
203 | $ERROR = RRDs::error; |
204 | print "Error in RRD::graph for load: $ERROR\n" if $ERROR; | |
205 | } | |
206 | ||
207 | sub updateloaddata { | |
208 | if ( ! -e "$rrdlog/load.rrd") { | |
209 | RRDs::create ("$rrdlog/load.rrd", "--step=60", | |
210 | "DS:load1:GAUGE:120:0:U", | |
211 | "DS:load5:GAUGE:120:0:U", | |
212 | "DS:load15:GAUGE:120:0:U", | |
213 | "RRA:AVERAGE:0.5:1:2160", | |
214 | "RRA:AVERAGE:0.5:5:2016", | |
215 | "RRA:AVERAGE:0.5:15:2880", | |
216 | "RRA:AVERAGE:0.5:60:8760"); | |
217 | ||
218 | $ERROR = RRDs::error; | |
219 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
220 | } | |
221 | } | |
222 | ||
cd1a2927 MT |
223 | sub updatememgraph { |
224 | my $period = $_[0]; | |
225 | ||
226 | RRDs::graph ("$graphs/memory-$period.png", | |
227 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
228 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
4b4aec3a CS |
229 | "--color", "SHADEA".$color{"color19"}, |
230 | "--color", "SHADEB".$color{"color20"}, | |
231 | "--color", "BACK".$color{"color21"}, | |
cd1a2927 MT |
232 | "-t $tr{'memory usage per'} $tr{$period}", |
233 | "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE", | |
234 | "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE", | |
235 | "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE", | |
236 | "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE", | |
237 | "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE", | |
238 | "CDEF:total=used,free,+", | |
239 | "CDEF:used2=used,buffer,cache,shared,+,+,-", | |
240 | "CDEF:usedpct=100,used2,total,/,*", | |
241 | "CDEF:sharedpct=100,shared,total,/,*", | |
242 | "CDEF:bufferpct=100,buffer,total,/,*", | |
243 | "CDEF:cachepct=100,cache,total,/,*", | |
244 | "CDEF:freepct=100,free,total,/,*", | |
4b4aec3a CS |
245 | "AREA:usedpct".$color{"color11"}.":$tr{'used memory'}\\j", |
246 | "STACK:sharedpct".$color{"color13"}.":$tr{'shared memory'}\\j", | |
247 | "STACK:bufferpct".$color{"color23"}.":$tr{'buffered memory'}\\j", | |
248 | "STACK:cachepct".$color{"color14"}.":$tr{'cached memory'}\\j", | |
249 | "STACK:freepct".$color{"color12"}.":$tr{'free memory'}\\j", | |
cd1a2927 MT |
250 | "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used memory'}\\:%3.2lf%%", |
251 | "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used memory'}\\:%3.2lf%%", | |
252 | "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used memory'}\\:%3.2lf%%\\j", | |
253 | "GPRINT:sharedpct:MAX:$tr{'maximal'} $tr{'shared memory'}\\:%3.2lf%%", | |
254 | "GPRINT:sharedpct:AVERAGE:$tr{'average'} $tr{'shared memory'}\\:%3.2lf%%", | |
255 | "GPRINT:sharedpct:LAST:$tr{'current'} $tr{'shared memory'}\\:%3.2lf%%\\j", | |
256 | "GPRINT:bufferpct:MAX:$tr{'maximal'} $tr{'buffered memory'}\\:%3.2lf%%", | |
257 | "GPRINT:bufferpct:AVERAGE:$tr{'average'} $tr{'buffered memory'}\\:%3.2lf%%", | |
258 | "GPRINT:bufferpct:LAST:$tr{'current'} $tr{'buffered memory'}\\:%3.2lf%%\\j", | |
259 | "GPRINT:cachepct:MAX:$tr{'maximal'} $tr{'cached memory'}\\:%3.2lf%%", | |
260 | "GPRINT:cachepct:AVERAGE:$tr{'average'} $tr{'cached memory'}\\:%3.2lf%%", | |
261 | "GPRINT:cachepct:LAST:$tr{'current'} $tr{'cached memory'}\\:%3.2lf%%\\j", | |
262 | "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free memory'}\\:%3.2lf%%", | |
263 | "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free memory'}\\:%3.2lf%%", | |
264 | "GPRINT:freepct:LAST:$tr{'current'} $tr{'free memory'}\\:%3.2lf%%\\j"); | |
265 | $ERROR = RRDs::error; | |
266 | print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; | |
267 | ||
268 | RRDs::graph ("$graphs/swap-$period.png", | |
269 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
270 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
4b4aec3a CS |
271 | "--color", "SHADEA".$color{"color19"}, |
272 | "--color", "SHADEB".$color{"color20"}, | |
273 | "--color", "BACK".$color{"color21"}, | |
cd1a2927 MT |
274 | "-t $tr{'swap usage per'} $tr{$period}", |
275 | "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE", | |
276 | "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE", | |
277 | "CDEF:total=used,free,+", | |
278 | "CDEF:usedpct=100,used,total,/,*", | |
279 | "CDEF:freepct=100,free,total,/,*", | |
4b4aec3a CS |
280 | "AREA:usedpct".$color{"color11"}.":$tr{'used swap'}\\j", |
281 | "STACK:freepct".$color{"color12"}.":$tr{'free swap'}\\j", | |
cd1a2927 MT |
282 | "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used swap'}\\:%3.2lf%%", |
283 | "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used swap'}\\:%3.2lf%%", | |
284 | "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used swap'}\\:%3.2lf%%\\j", | |
285 | "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free swap'}\\:%3.2lf%%", | |
286 | "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free swap'}\\:%3.2lf%%", | |
287 | "GPRINT:freepct:LAST:$tr{'current'} $tr{'free swap'}\\:%3.2lf%%\\j"); | |
288 | $ERROR = RRDs::error; | |
289 | print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; | |
290 | } | |
291 | ||
292 | sub updatememdata { | |
4b4aec3a | 293 | my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree, $swaptotal); |
cd1a2927 MT |
294 | if ( ! -e "$rrdlog/mem.rrd") { |
295 | RRDs::create ("$rrdlog/mem.rrd", "--step=300", | |
296 | "DS:memused:ABSOLUTE:600:0:5000000000", | |
297 | "DS:memfree:ABSOLUTE:600:0:5000000000", | |
298 | "DS:memshared:ABSOLUTE:600:0:5000000000", | |
299 | "DS:membuffers:ABSOLUTE:600:0:5000000000", | |
300 | "DS:memcache:ABSOLUTE:600:0:5000000000", | |
301 | "DS:swapused:ABSOLUTE:600:0:5000000000", | |
302 | "DS:swapfree:ABSOLUTE:600:0:5000000000", | |
303 | "RRA:AVERAGE:0.5:1:576", | |
304 | "RRA:AVERAGE:0.5:6:672", | |
305 | "RRA:AVERAGE:0.5:24:732", | |
306 | "RRA:AVERAGE:0.5:144:1460"); | |
307 | $ERROR = RRDs::error; | |
308 | print "Error in RRD::create for mem: $ERROR\n" if $ERROR; | |
309 | } | |
310 | ||
311 | open MEM, "/proc/meminfo"; | |
312 | while(<MEM>) { | |
313 | chomp; | |
c6aa4ac1 | 314 | if ($_ =~ /^MemTotal:/) { |
cd1a2927 | 315 | my @temp = split (/\s+/, $_); |
c6aa4ac1 MT |
316 | $memused = $temp[1]; |
317 | } elsif ($_ =~ /^MemFree:/) { | |
cd1a2927 | 318 | my @temp = split (/\s+/, $_); |
c6aa4ac1 MT |
319 | $memfree = $temp[1]; |
320 | } elsif ($_ =~ /^Cached:/) { | |
321 | my @temp = split (/\s+/, $_); | |
322 | $memcache = $temp[1]; | |
323 | } elsif ($_ =~ /^Buffers:/) { | |
324 | my @temp = split (/\s+/, $_); | |
325 | $membuffers = $temp[1]; | |
326 | } elsif ($_ =~ /^SwapTotal:/) { | |
327 | my @temp = split (/\s+/, $_); | |
4b4aec3a | 328 | $swaptotal = $temp[1]; |
c6aa4ac1 MT |
329 | } elsif ($_ =~ /^SwapFree:/) { |
330 | my @temp = split (/\s+/, $_); | |
331 | $swapfree = $temp[1]; | |
cd1a2927 MT |
332 | } |
333 | } | |
334 | close MEM; | |
335 | ||
c6aa4ac1 MT |
336 | system("/bin/df > /tmp/diskfree"); |
337 | open DF, "/tmp/diskfree"; | |
338 | while(<DF>) { | |
339 | chomp; | |
340 | if ($_ =~ /^shm/) { | |
341 | my @temp = split (/\s+/, $_); | |
342 | $memshared = $temp[2]; | |
343 | } | |
344 | } | |
345 | close DF; | |
346 | system("/bin/rm -f /tmp/diskfree"); | |
4b4aec3a CS |
347 | |
348 | $swapused = $swaptotal-$swapfree; | |
cd1a2927 MT |
349 | RRDs::update ("$rrdlog/mem.rrd", |
350 | "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree", | |
351 | "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree"); | |
352 | $ERROR = RRDs::error; | |
353 | print "Error in RRD::update for mem: $ERROR\n" if $ERROR; | |
354 | } | |
355 | ||
356 | sub updatediskgraph { | |
357 | my $period = $_[0]; | |
358 | ||
359 | RRDs::graph ("$graphs/disk-$period.png", | |
360 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
361 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
4b4aec3a CS |
362 | "--color", "SHADEA".$color{"color19"}, |
363 | "--color", "SHADEB".$color{"color20"}, | |
364 | "--color", "BACK".$color{"color21"}, | |
cd1a2927 MT |
365 | "-t $tr{'disk access per'} $tr{$period}", |
366 | "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE", | |
367 | "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE", | |
4b4aec3a CS |
368 | "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}\\j", |
369 | "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j", | |
cd1a2927 MT |
370 | "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf", |
371 | "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf", | |
372 | "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j", | |
373 | "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf", | |
374 | "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf", | |
375 | "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j"); | |
376 | $ERROR = RRDs::error; | |
377 | print "Error in RRD::graph for disk: $ERROR\n" if $ERROR; | |
378 | } | |
379 | ||
380 | sub updatediskdata { | |
381 | my ($readwritereq, $readreq, $readsect, $writereq, $writesect); | |
382 | if ( ! -e "$rrdlog/disk.rrd") { | |
383 | RRDs::create ("$rrdlog/disk.rrd", "--step=300", | |
384 | "DS:readsect:COUNTER:600:0:5000000000", | |
385 | "DS:writesect:COUNTER:600:0:5000000000", | |
386 | "RRA:AVERAGE:0.5:1:576", | |
387 | "RRA:AVERAGE:0.5:6:672", | |
388 | "RRA:AVERAGE:0.5:24:732", | |
389 | "RRA:AVERAGE:0.5:144:1460"); | |
390 | $ERROR = RRDs::error; | |
391 | print "Error in RRD::create for disk: $ERROR\n" if $ERROR; | |
392 | } | |
393 | ||
394 | my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, | |
395 | $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk"); | |
396 | ||
397 | my $major = $rdev >> 8; | |
398 | my $minor = $rdev & 0xFF; | |
399 | ||
400 | open STAT, "/proc/stat"; | |
401 | my @diskstat = <STAT>; | |
402 | close (STAT); | |
403 | foreach my $line (@diskstat) | |
404 | { | |
405 | chomp ($line); | |
406 | my @temp = split(/\:\ /,$line); | |
407 | if ($temp[1]) { | |
408 | my @devicestat = split(/\ /,$temp[1]); | |
409 | foreach my $stats (@devicestat) | |
410 | { | |
411 | chomp ($stats); | |
412 | my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats); | |
413 | if ($major eq $fields[1] and $minor eq $fields[2]) | |
414 | { | |
415 | $readwritereq = $fields[3]; | |
416 | $readreq = $fields[4]; | |
417 | $readsect = $fields[5]; | |
418 | $writereq = $fields[6]; | |
419 | $writesect = $fields[7]; | |
420 | } | |
421 | } | |
422 | } | |
423 | } | |
424 | ||
425 | if ($readsect && $writesect) { | |
426 | RRDs::update ("$rrdlog/disk.rrd", | |
427 | "-t", "readsect:writesect", | |
428 | "N:$readsect:$writesect"); | |
429 | $ERROR = RRDs::error; | |
430 | print "Error in RRD::update for disk: $ERROR\n" if $ERROR; | |
431 | } else { | |
432 | print "Error in RRD::update for disk: no data available\n"; | |
433 | } | |
434 | } | |
435 | ||
6c666a3b MT |
436 | sub updatediskgraphnew { |
437 | my $disk = $_[0]; | |
438 | my $period = $_[1]; | |
439 | ||
440 | RRDs::graph ("$graphs/disk-$disk-$period.png", | |
441 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
442 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
4b4aec3a CS |
443 | "--color", "SHADEA".$color{"color19"}, |
444 | "--color", "SHADEB".$color{"color20"}, | |
445 | "--color", "BACK".$color{"color21"}, | |
6c666a3b MT |
446 | "-t $tr{'disk access per'} $tr{$period}", |
447 | "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE", | |
448 | "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE", | |
449 | "DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE", | |
450 | "CDEF:sl_state=sleep,INF,*", | |
451 | ||
452 | "AREA:sl_state#a0a0a0:disk standby\\j", | |
4b4aec3a CS |
453 | "AREA:read".$color{"color11"}.":$tr{'sectors read from disk per second'}\\j", |
454 | "STACK:write".$color{"color12"}.":$tr{'sectors written to disk per second'}\\j", | |
6c666a3b MT |
455 | |
456 | "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf", | |
457 | "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf", | |
458 | "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j", | |
459 | "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf", | |
460 | "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf", | |
461 | "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j"); | |
462 | $ERROR = RRDs::error; | |
463 | print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR; | |
464 | } | |
465 | ||
466 | sub updatediskdatanew { | |
467 | my $disk = $_[0]; | |
468 | ||
469 | my ($readwritereq, $readreq, $readsect, $writereq, $writesect); | |
470 | if ( ! -e "$rrdlog/disk-$disk.rrd") { | |
471 | RRDs::create ("$rrdlog/disk-$disk.rrd", "--step=300", | |
472 | "DS:readsect:COUNTER:600:0:5000000000", | |
473 | "DS:writesect:COUNTER:600:0:5000000000", | |
474 | "DS:sleeping:GAUGE:600:0:1", | |
475 | "RRA:AVERAGE:0.5:1:576", | |
476 | "RRA:AVERAGE:0.5:6:672", | |
477 | "RRA:AVERAGE:0.5:24:732", | |
478 | "RRA:AVERAGE:0.5:144:1460"); | |
479 | $ERROR = RRDs::error; | |
480 | print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR; | |
481 | } | |
482 | ||
483 | my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, | |
484 | $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk"); | |
485 | ||
c6aa4ac1 MT |
486 | print "\n\n$dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks\n\n"; |
487 | ||
6c666a3b MT |
488 | my $major = $rdev >> 8; |
489 | my $minor = ($rdev & 0xFF) >>6; | |
490 | ||
491 | open STAT, "/proc/stat"; | |
492 | my @diskstat = <STAT>; | |
493 | close (STAT); | |
494 | foreach my $line (@diskstat) | |
495 | { | |
496 | chomp ($line); | |
497 | my @temp = split(/\:\ /,$line); | |
498 | if ($temp[1]) { | |
499 | my @devicestat = split(/\ /,$temp[1]); | |
500 | foreach my $stats (@devicestat) | |
501 | { | |
502 | chomp ($stats); | |
503 | my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats); | |
504 | if ($major eq $fields[1] and $minor eq $fields[2]) | |
505 | { | |
506 | $readwritereq = $fields[3]; | |
507 | $readreq = $fields[4]; | |
508 | $readsect = $fields[5]; | |
509 | $writereq = $fields[6]; | |
510 | $writesect = $fields[7]; | |
511 | } | |
512 | } | |
513 | } | |
514 | } | |
515 | ||
516 | my $sleeping=0; | |
517 | my $lastsleepstate=0; | |
518 | ||
519 | if ( -e "/tmp/hddshutdown-$disk" ) { | |
520 | open STAT,"/tmp/hddshutdown-$disk"; | |
521 | $lastsleepstate = <STAT>; | |
522 | close (STAT); | |
523 | if ($lastsleepstate==$readwritereq) { | |
524 | $sleeping=1; | |
525 | } | |
c6aa4ac1 | 526 | } |
6c666a3b MT |
527 | |
528 | if ($readsect && $writesect) { | |
529 | RRDs::update ("$rrdlog/disk-$disk.rrd", | |
530 | "-t", "readsect:writesect:sleeping", | |
531 | "N:$readsect:$writesect:$sleeping"); | |
532 | $ERROR = RRDs::error; | |
533 | print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR; | |
534 | } else { | |
535 | print "Error in RRD::update for disk-$disk: no data available\n"; | |
536 | } | |
537 | } | |
538 | ||
cd1a2927 MT |
539 | sub updateifgraph { |
540 | my $interface = $_[0]; | |
541 | my $period = $_[1]; | |
542 | ||
543 | RRDs::graph ("$graphs/$interface-$period.png", | |
544 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
545 | "--alt-y-grid", "-w 600", "-h 100", | |
4b4aec3a CS |
546 | "--color", "SHADEA".$color{"color19"}, |
547 | "--color", "SHADEB".$color{"color20"}, | |
548 | "--color", "BACK".$color{"color21"}, | |
cd1a2927 MT |
549 | "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})", |
550 | "-v$tr{'bytes per second'}", | |
551 | "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE", | |
552 | "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE", | |
4b4aec3a CS |
553 | "AREA:incoming".$color{"color11"}.":$tr{'incoming traffic in bytes per second'}\\j", |
554 | "LINE1:outgoing".$color{"color12"}.":$tr{'outgoing traffic in bytes per second'}\\j", | |
cd1a2927 MT |
555 | "GPRINT:incoming:MAX:$tr{'maximal'} $tr{'in'}\\:%8.3lf %sBps", |
556 | "GPRINT:incoming:AVERAGE:$tr{'average'} $tr{'in'}\\:%8.3lf %sBps", | |
557 | "GPRINT:incoming:LAST:$tr{'current'} $tr{'in'}\\:%8.3lf %sBps\\j", | |
558 | "GPRINT:outgoing:MAX:$tr{'maximal'} $tr{'out'}\\:%8.3lf %sBps", | |
559 | "GPRINT:outgoing:AVERAGE:$tr{'average'} $tr{'out'}\\:%8.3lf %sBps", | |
560 | "GPRINT:outgoing:LAST:$tr{'current'} $tr{'out'}\\:%8.3lf %sBps\\j"); | |
561 | $ERROR = RRDs::error; | |
562 | print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR; | |
563 | } | |
564 | ||
565 | sub updateifdata { | |
566 | my $interface = $_[0]; | |
567 | ||
568 | if ( ! -e "$rrdlog/$interface.rrd") { | |
569 | RRDs::create ("$rrdlog/$interface.rrd", "--step=300", | |
570 | "DS:incoming:ABSOLUTE:600:0:12500000", | |
571 | "DS:outgoing:ABSOLUTE:600:0:12500000", | |
572 | "RRA:AVERAGE:0.5:1:576", | |
573 | "RRA:AVERAGE:0.5:6:672", | |
574 | "RRA:AVERAGE:0.5:24:732", | |
575 | "RRA:AVERAGE:0.5:144:1460"); | |
576 | $ERROR = RRDs::error; | |
577 | print "Error in RRD::create for $interface: $ERROR\n" if $ERROR; | |
578 | } | |
579 | ||
580 | my $traffic = gettraffic ($interface); | |
581 | RRDs::update ("$rrdlog/$interface.rrd", | |
582 | "-t", "incoming:outgoing", | |
583 | "N:$traffic"); | |
584 | $ERROR = RRDs::error; | |
585 | print "Error in RRD::update for $interface: $ERROR\n" if $ERROR; | |
586 | } | |
587 | ||
df8c7810 MT |
588 | sub updatefwhitsgraph { |
589 | my $interval = $_[0]; | |
590 | ||
591 | RRDs::graph ("$graphs/firewallhits-$interval-area.png", | |
592 | "--start", "-1$interval", "-aPNG", "-i", "-z", | |
072cd997 | 593 | "--alt-y-grid", "-w 600", "-h 200", |
4b4aec3a CS |
594 | "--color", "SHADEA".$color{"color19"}, |
595 | "--color", "SHADEB".$color{"color20"}, | |
596 | "--color", "BACK".$color{"color21"}, | |
df8c7810 MT |
597 | "-t firewall hits over the last $interval", |
598 | "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE", | |
4b4aec3a | 599 | "AREA:amount".$color{"color24"}.":firewallhits", |
c7acba4a MT |
600 | "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S", |
601 | "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S", | |
602 | "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n", | |
df8c7810 | 603 | "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE", |
4b4aec3a | 604 | "AREA:portamount".$color{"color25"}.":portscans", |
c7acba4a MT |
605 | "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S", |
606 | "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S", | |
607 | "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min"); | |
df8c7810 MT |
608 | $ERROR = RRDs::error; |
609 | print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR; | |
610 | ||
611 | RRDs::graph ("$graphs/firewallhits-$interval-line.png", | |
612 | "--start", "-1$interval", "-aPNG", "-i", "-z", | |
072cd997 | 613 | "--alt-y-grid", "-w 600", "-h 200", |
4b4aec3a CS |
614 | "--color", "SHADEA".$color{"color19"}, |
615 | "--color", "SHADEB".$color{"color20"}, | |
616 | "--color", "BACK".$color{"color21"}, | |
df8c7810 MT |
617 | "-t firewall hits over the last $interval", |
618 | "DEF:amount=$rrdlog/firewallhits.rrd:amount:AVERAGE", | |
4b4aec3a | 619 | "LINE2:amount".$color{"color24"}.":firewallhits", |
c7acba4a MT |
620 | "GPRINT:amount:MAX: $tr{'maximal'}\\: %2.2lf %S", |
621 | "GPRINT:amount:AVERAGE: $tr{'average'}\\: %2.2lf %S", | |
894c6feb | 622 | "GPRINT:amount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min\\n", |
df8c7810 | 623 | "DEF:portamount=$rrdlog/firewallhits.rrd:portamount:AVERAGE", |
4b4aec3a | 624 | "LINE2:portamount".$color{"color25"}.":portscans", |
c7acba4a MT |
625 | "GPRINT:portamount:MAX: $tr{'maximal'}\\: %2.2lf %S", |
626 | "GPRINT:portamount:AVERAGE: $tr{'average'}\\: %2.2lf %S", | |
627 | "GPRINT:portamount:LAST: $tr{'current'}\\: %2.2lf %Shits/5 min"); | |
df8c7810 MT |
628 | $ERROR = RRDs::error; |
629 | print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR; | |
630 | } | |
631 | ||
632 | sub updatefwhitsdata { | |
633 | my $portamount=0; | |
634 | my $alertaktuell=0; | |
635 | my $aktuell=0; | |
636 | my $portaktuell=0; | |
637 | my $skip=0; | |
638 | ||
639 | if (! -e "$rrdlog/firewallhits.rrd") | |
640 | { | |
641 | RRDs::create ("$rrdlog/firewallhits.rrd", "--step=300", | |
642 | "DS:amount:GAUGE:600:0:U", | |
643 | "DS:portamount:GAUGE:600:0:U", | |
644 | "RRA:AVERAGE:0.5:1:576", | |
645 | "RRA:AVERAGE:0.5:6:672", | |
646 | "RRA:AVERAGE:0.5:24:732", | |
647 | "RRA:AVERAGE:0.5:144:1460"); | |
648 | $ERROR = RRDs::error; | |
649 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
650 | } | |
651 | ||
652 | system("logtailfwhits /var/log/messages /var/log/fwhits.messages.offset >/tmp/messages.fwhits"); | |
653 | if (!(open (FILE,'/tmp/messages.fwhits'))) { | |
654 | $skip=1; | |
655 | } | |
656 | $aktuell = 0; | |
657 | if (!$skip) { | |
658 | while (<FILE>) { | |
659 | if (/kernel:.*(IN=.*)$/) { | |
660 | $aktuell++; | |
661 | } | |
662 | } | |
663 | close (FILE); | |
664 | } | |
665 | ||
666 | system("logtailfwhits /var/log/snort/alert /var/log/snort/fwhits.alert.offset >/tmp/snort.fwhits"); | |
667 | if (!(open (FILE,'/tmp/snort.fwhits'))) { | |
668 | $skip=1; | |
669 | } | |
670 | $alertaktuell = 0; | |
671 | if (!$skip) { | |
672 | while (<FILE>) { | |
673 | if (/scan.*$/) { | |
674 | $alertaktuell++; | |
675 | } | |
676 | } | |
677 | close (FILE); | |
678 | } | |
679 | ||
680 | if (!(open (FILE,'/tmp/messages.fwhits'))) { | |
681 | $skip=1; | |
682 | } | |
683 | $portaktuell = 0; | |
684 | if (!$skip) { | |
685 | while (<FILE>) { | |
686 | if (/kernel:.*(Scan.*)$/) { | |
687 | $portaktuell++; | |
688 | } | |
689 | } | |
690 | close (FILE); | |
691 | } | |
692 | ||
693 | system("rm /tmp/messages.fwhits"); | |
694 | system("rm /tmp/snort.fwhits"); | |
695 | ||
696 | $portamount = $portaktuell + $alertaktuell; | |
697 | chomp($portamount); | |
698 | RRDs::update ("$rrdlog/firewallhits.rrd", | |
699 | "N:$aktuell:$portamount"); | |
700 | $ERROR = RRDs::error; | |
701 | print "Error in RRD::update for Firewallhits: $ERROR\n" if $ERROR; | |
702 | } | |
703 | ||
072cd997 MT |
704 | # Creates and updates a link quality database |
705 | # ------------------------------------------- | |
706 | sub updatelq { | |
707 | if ( ! -e "$rrdlog/lq.rrd") { | |
708 | RRDs::create ("$rrdlog/lq.rrd", "--step=300", | |
709 | "DS:loss:GAUGE:600:0:100", | |
710 | "DS:roundtrip:GAUGE:600:0:10000", | |
711 | "RRA:AVERAGE:0.5:1:576", | |
712 | "RRA:AVERAGE:0.5:6:672", | |
713 | "RRA:AVERAGE:0.5:24:732", | |
714 | "RRA:AVERAGE:0.5:144:1460"); | |
715 | $ERROR = RRDs::error; | |
716 | print "Error in RRD::create for link: $ERROR\n" if $ERROR; | |
717 | } | |
718 | my $packetloss=0; | |
719 | my $roundtrip=0; | |
720 | my $test=0; | |
721 | # LQ_GATEWAY is the ip of your isp's public ip facing you | |
66801d8b | 722 | my $LQ_GATEWAY=`netstat -rn | grep ^0.0.0.0 | awk '{print \$2}'`; |
072cd997 MT |
723 | my $NUMPINGS=10; |
724 | my $pingoutput = `ping -c $NUMPINGS -q $LQ_GATEWAY`; | |
725 | chomp; | |
726 | my @temp = split (/\/|\%|\s/, $pingoutput); | |
727 | $packetloss = $temp[17]; | |
728 | $roundtrip = $temp[28]; | |
729 | RRDs::update ("$rrdlog/lq.rrd", "N:$packetloss:$roundtrip"); | |
730 | $ERROR = RRDs::error; | |
731 | print "Error in RRD::update for line quality: $ERROR\n" if $ERROR; | |
732 | } | |
733 | ||
734 | sub updatelqgraph { | |
735 | my $period = $_[0]; | |
736 | RRDs::graph ("$graphs/lq-$period.png", | |
737 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
738 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
739 | "-t $tr{'linkq'} ($tr{'graph per'} $tr{$period})", | |
740 | "--lazy", | |
4b4aec3a CS |
741 | "--color", "SHADEA".$color{"color19"}, |
742 | "--color", "SHADEB".$color{"color20"}, | |
743 | "--color", "BACK".$color{"color21"}, | |
072cd997 MT |
744 | "-v ms / pkts (% x10)", |
745 | "DEF:roundtrip=$rrdlog/lq.rrd:roundtrip:AVERAGE", | |
746 | "DEF:loss=$rrdlog/lq.rrd:loss:AVERAGE", | |
747 | "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/", | |
748 | "CDEF:loss10=loss,10,*", | |
749 | "CDEF:r0=roundtrip,30,MIN", | |
750 | "CDEF:r1=roundtrip,70,MIN", | |
751 | "CDEF:r2=roundtrip,150,MIN", | |
752 | "CDEF:r3=roundtrip,300,MIN", | |
4b4aec3a CS |
753 | "AREA:roundtrip".$color{"color25"}.":>300 ms", |
754 | "AREA:r3".$color{"color18"}.":150-300 ms", | |
755 | "AREA:r2".$color{"color14"}.":70-150 ms", | |
756 | "AREA:r1".$color{"color17"}.":30-70 ms", | |
757 | "AREA:r0".$color{"color12"}.":<30 ms", | |
758 | "AREA:loss10".$color{"color13"}.":Packet loss (x10)", | |
072cd997 | 759 | "LINE1:roundtrip#707070:", |
c7acba4a MT |
760 | "GPRINT:roundtrip:MAX:$tr{'maximal'}\\:%3.2lf ms", |
761 | "GPRINT:roundtrip:AVERAGE:$tr{'average'}\\:%3.2lf ms", | |
762 | "GPRINT:roundtrip:LAST:$tr{'current'}\\:%3.2lf ms\\j", | |
072cd997 MT |
763 | "GPRINT:loss:MAX:$tr{'maximal'} Loss\\:%3.2lf%%", |
764 | "GPRINT:loss:AVERAGE:$tr{'average'} Loss\\:%3.2lf%%", | |
765 | "GPRINT:loss:LAST:$tr{'current'} Loss\\:%3.2lf%%\\j" | |
766 | ); | |
767 | $ERROR = RRDs::error; | |
768 | print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR; | |
769 | } | |
770 | ||
60cbd6e7 MT |
771 | sub updatehdddata |
772 | { | |
9217f236 MT |
773 | my $disk = $_[0]; |
774 | if ( ! -e "$rrdlog/hddtemp-$disk.rrd") | |
60cbd6e7 MT |
775 | { |
776 | # database did not exist -> create | |
9217f236 | 777 | RRDs::create ("$rrdlog/hddtemp-$disk.rrd", "--step=300", |
60cbd6e7 MT |
778 | "DS:temperature:GAUGE:600:0:100", |
779 | "RRA:AVERAGE:0.5:1:576", | |
780 | "RRA:AVERAGE:0.5:6:672", | |
781 | "RRA:AVERAGE:0.5:24:732", | |
782 | "RRA:AVERAGE:0.5:144:1460"); | |
783 | $ERROR = RRDs::error; | |
9217f236 | 784 | print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR; |
60cbd6e7 MT |
785 | } |
786 | ||
52345790 MT |
787 | $temp = 0; |
788 | my $hdd_output = ''; | |
789 | my $smart_output = ''; | |
60cbd6e7 | 790 | |
52345790 | 791 | if ( -e "$path_smartctl" ) |
60cbd6e7 | 792 | { |
9217f236 | 793 | system("$path_smartctl -iHA /dev/$disk > /var/log/smartctl_out_hddtemp-$disk"); |
60cbd6e7 | 794 | } |
52345790 MT |
795 | |
796 | if ( -e "$path_hddtemp" ) | |
60cbd6e7 | 797 | { |
9217f236 | 798 | $hdd_output = `$path_hddtemp -qn /dev/$disk`; |
52345790 MT |
799 | |
800 | # I know 4 response possible responses: | |
801 | # | |
802 | # /dev/harddisk: harddisk type: S.M.A.R.T. not available | |
803 | # /dev/harddisk: harddisk type: no sensor | |
804 |