File: smartd

package info (click to toggle)
logwatch 5.2.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,112 kB
  • ctags: 42
  • sloc: perl: 9,032; sh: 65; makefile: 54
file content (48 lines) | stat: -rwxr-xr-x 1,816 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl -w
##########################################################################
# $Id: smartd,v 1.5 2004/02/03 03:36:39 kirk Exp $
##########################################################################

#$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;

while (defined($ThisLine = <STDIN>)) {
   chomp($ThisLine);
   if ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), No such device or address, open\(\) failed/ )) {
       # ignore
   } elsif ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), is SMART capable. Adding to "monitor" list./ )) {
       # ignore
   } elsif ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), found in smartd database./ )) {
       # ignore
   } elsif ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), opened/)) {
       # ignore
   } elsif ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), appears to lack SMART*/ )) {
       # ignore
#   } elsif ( ($Device,$Msg) = ($ThisLine =~ /^Device: ([^,]+), (.*)$/)) {
#      $ParamChanges{$Device}{$Msg}++;
   } elsif ( ($Device,$AttribType,$Code,$Name,undef,$NewVal) = ($ThisLine =~ /^Device: ([^,]+), SMART ([A-Za-z]+) Attribute: ([0-9]+) ([A-Za-z_]+) changed from ([0-9]+) to ([0-9]+)/)) {
      $ParamChanges{$Device}{"$AttribType: $Name ($Code)"}{$NewVal}++;
   }
}

if (keys %ParamChanges) {
   foreach $Device (sort keys %ParamChanges) {
      print "\n$Device :\n";
      foreach $Msg (sort keys %{$ParamChanges{$Device}}) {
         print "   $Msg changed to ";
         $vv="";
         foreach $Val (sort keys %{$ParamChanges{$Device}{$Msg}}) {
            if (! $vv eq "") {
               print "$vv, ";
            }
            $vv = "$Val";
            #$vv .= " ($ParamChanges{$Device}{$Msg}{$Val} times)";
         }
         print "$vv\n";
      }
   }
}

exit(0);

# vi: shiftwidth=3 tabstop=3 et