Blame scripts/services/kernel

Packit 57988d
Packit 57988d
##########################################################################
Packit 57988d
# $Id$
Packit 57988d
##########################################################################
Packit 57988d
# $Log: kernel,v $
Packit 57988d
# Revision 1.35  2008/03/24 23:31:26  kirk
Packit 57988d
# added copyright/license notice to each script
Packit 57988d
#
Packit 57988d
# Revision 1.34  2008/02/14 19:01:51  mike
Packit 57988d
# Patch for OOM from Orion Poplawski -mgt
Packit 57988d
#
Packit 57988d
# Revision 1.33  2006/01/16 18:40:31  kirk
Packit 57988d
# fixed name to Logwatch (how I like it now)
Packit 57988d
#
Packit 57988d
# Revision 1.32  2005/11/30 05:35:11  bjorn
Packit 57988d
# Replaced compStr, by Markus Lude.
Packit 57988d
#
Packit 57988d
# Revision 1.31  2005/11/08 20:34:49  bjorn
Packit 57988d
# Fixed reporting of RAID errors and added 'use strict'. Adds support for
Packit 57988d
# reporting various execution/memory access errors. These are errors on
Packit 57988d
# 2.6.5-7 kernels, x86_64 and IA64 architectures, SuSE 9 distro.
Packit 57988d
# All these changes by David Baldwin.
Packit 57988d
#
Packit 57988d
# Revision 1.30  2005/07/25 22:17:31  bjorn
Packit 57988d
# Moved iptables (and ipchains, ipfwadm) code to its own service (iptables).
Packit 57988d
#
Packit 57988d
# Revision 1.29  2005/06/07 18:14:50  bjorn
Packit 57988d
# Filtering out audit statements, since we now have an "audit" service.
Packit 57988d
##########################################################################
Packit 57988d
# Kernel script for Logwatch
Packit 57988d
#
Packit 57988d
# Visit the Logwatch website at
Packit 57988d
#   http://www.logwatch.org
Packit 57988d
##########################################################################
Packit 57988d
Packit 57988d
#####################################################
Packit 57988d
## Copyright (c) 2008 Kirk Bauer
Packit 57988d
## Covered under the included MIT/X-Consortium License:
Packit 57988d
##    http://www.opensource.org/licenses/mit-license.php
Packit 57988d
## All modifications and contributions by other persons to
Packit 57988d
## this script are assumed to have been donated to the
Packit 57988d
## Logwatch project and thus assume the above copyright
Packit 57988d
## and licensing terms.  If you want to make contributions
Packit 57988d
## under your own copyright or a different license this
Packit 57988d
## must be explicitly stated in the contribution an the
Packit 57988d
## Logwatch project reserves the right to not accept such
Packit 57988d
## contributions.  If you have made significant
Packit 57988d
## contributions to this script and want to claim
Packit 57988d
## copyright please contact logwatch-devel@lists.sourceforge.net.
Packit 57988d
#########################################################
Packit 57988d
Packit 57988d
use strict;
Packit 57988d
use Logwatch ':ip';
Packit 57988d
Packit 57988d
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
Packit 57988d
my $Ignore_faults = $ENV{'ignore_faults'};
Packit 57988d
my $Ignore_rpcsec_expired = $ENV{'ignore_rpcsec_expired'} || 0;
Packit 57988d
my $Ignore_messages = $ENV{'kernel_ignore_messages'} || '^$';
Packit 57988d
my %SYNflood = ();
Packit 57988d
my %RAIDErrors = ();
Packit 57988d
my %DRBDErrors = ();
Packit 57988d
my %SegFaults = ();
Packit 57988d
my %GPFaults = ();
Packit 57988d
my %TrapInt3s = ();
Packit 57988d
my %UnalignedErrors = ();
Packit 57988d
my %FPAssists = ();
Packit 57988d
my %OOM = ();
Packit 57988d
my %Errors = ();
Packit 57988d
my %Kernel = ();
Packit 57988d
my %EDACs = ();
Packit 57988d
Packit 57988d
while (defined(my $ThisLine = <STDIN>)) {
Packit 57988d
   chomp($ThisLine);
Packit 57988d
   next if ($ThisLine eq '');
Packit 57988d
   # Remove timestamp if present
Packit 57988d
   $ThisLine =~ s/^\[\s*\d+\.\d+\]\s*//;
Packit 57988d
Packit 57988d
   if (
Packit 57988d
      # filter out audit messages - these should be parsed by the audit
Packit 57988d
      # service
Packit 57988d
      ($ThisLine =~ /^\s*(type=\d+\s+)?audit\(/)
Packit 57988d
      # following now in iptables service
Packit 57988d
      or ($ThisLine =~ /^Packet log: .*PROTO=/)
Packit 57988d
      or ($ThisLine =~ /IN=.*OUT=.*SRC=.*DST=.*PROTO=/)
Packit 57988d
      # user specified ignore messages, lower cased
Packit 57988d
      or ($ThisLine =~ /$Ignore_messages/i)
Packit 57988d
      ) { # ignore the above strings
Packit 57988d
   } elsif ( my ($from,$on) = ( $ThisLine =~ /^Warning: possible SYN flood from ([^ ]+) on ([^ ]+):.+ Sending cookies/ ) ) {
Packit 57988d
      my $Fullfrom = LookupIP($from);
Packit 57988d
      my $Fullon = LookupIP($on);
Packit 57988d
      $SYNflood{$Fullon}{$Fullfrom}++;
Packit 57988d
   } elsif ($ThisLine =~ /continuing in degraded mode/) {
Packit 57988d
      $RAIDErrors{$ThisLine}++;
Packit 57988d
   } elsif ($ThisLine =~ /([^(]*)\[\d+\]: segfault at/) {
Packit 57988d
      $SegFaults{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /([^(]*)\[\d+\] general protection/) {
Packit 57988d
      $GPFaults{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /([^(]*)\[\d+\] trap int3 /) {
Packit 57988d
      $TrapInt3s{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /([^(]*)\(\d+\): unaligned access to/) {
Packit 57988d
      $UnalignedErrors{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /([^(]*)\(\d+\): floating-point assist fault at ip/) {
Packit 57988d
      $FPAssists{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /Out of memory: Killed process \d+ \((.*)\)/) {
Packit 57988d
      $OOM{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /(\S+) invoked oom-killer/) {
Packit 57988d
      $OOM{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /(EDAC (MC|PCI)\d:.*)/) {
Packit 57988d
      # Standard boot messages
Packit 57988d
      next if $ThisLine =~ /Giving out device to /;
Packit 57988d
      $EDACs{$1}++;
Packit 57988d
   } elsif ($ThisLine =~ /(block drbd\d+): Online verify found (\d+) \d+k block out of sync/) {
Packit 57988d
      $DRBDErrors{$1}{"$2 block(s) out of sync"} = 1;
Packit 57988d
   } elsif ($ThisLine =~ /(block drbd\d+): \[.*\] sock_sendmsg time expired/) {
Packit 57988d
      $DRBDErrors{$1}{"sock_sendmsg time expired"}++;
Packit 57988d
   } elsif ($ThisLine =~ /(block drbd\d+): Began resync as (SyncSource|SyncTarget)/) {
Packit 57988d
      $DRBDErrors{$1}{"Began resync as $2"}++;
Packit 57988d
   } elsif ( ( my $errormsg ) = ( $ThisLine =~ /(.*?error.{0,17})/i ) ) {
Packit 57988d
      # filter out smb open/read errors cased by insufficient permissions
Packit 57988d
      my $SkipError = 0;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_readpage_sync: .*open failed, error=-13/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, result=-13/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, error=-13/;
Packit 57988d
      # filter out error_exit in stack traces caused by OOM conditions
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /\[<[\da-f]+>\] error_exit\+0x/;
Packit 57988d
      # These are informative, not errors
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /ACPI _OSC request failed \(AE_ERROR\), returned control mask: 0x1d/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /ERST: Error Record Serialization Table \(ERST\) support is initialized/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /GHES: Generic hardware error source: \d+ notified via .* is not supported/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /PCIe errors handled by (?:BIOS|OS)/;
Packit 57988d
      # These happen when kerberos tickets expire, which can be normal
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /Error: state manager encountered RPCSEC_GSS session expired against NFSv4 server/ && $Ignore_rpcsec_expired;
Packit 57988d
      # filter out mount options
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /errors=(?:continue|remount-ro|panic)/;
Packit 57988d
      $Errors{$errormsg}++ if ( (! $SkipError) || ($Detail > 8));
Packit 57988d
   } elsif ( ( my $errormsg ) = ( $ThisLine =~ /((BUG|WARNING|INFO):.{0,40})/ ) ) {
Packit 57988d
      $Errors{$errormsg}++;
Packit 57988d
   # OTHER
Packit 57988d
   } else {
Packit 57988d
      # XXX For now, going to ignore all other kernel messages as there
Packit 57988d
      # XXX are practically an infinite number and most of them are obviously
Packit 57988d
      # XXX not parsed here at this time.
Packit 57988d
      # filter out smb open/read errors cased by insufficient permissions
Packit 57988d
      my $SkipError = 0;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_readpage_sync: .*open failed, error=-13/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, result=-13/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, error=-13/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: Out of sync: start=\d+/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: updated( sync)? UUIDs?/i;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: Resync done/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: cs:(?:Ahead|Behind) rs_left/;
Packit 57988d
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: \d+ % had equal checksums, eliminated:/;
Packit 57988d
      $Kernel{$ThisLine}++ if ( (! $SkipError) || ($Detail > 8)) ;
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %SYNflood) {
Packit 57988d
   print "\nWarning: SYN flood on:\n";
Packit 57988d
   foreach my $ThisOne (sort {$a cmp $b} keys %SYNflood) {
Packit 57988d
      print "   " . $ThisOne . " from:\n";
Packit 57988d
      foreach my $Next (sort {$a cmp $b} keys %{$SYNflood{$ThisOne}}) {
Packit 57988d
         print "      " . $Next . ": $SYNflood{$ThisOne}{$Next} Time(s)\n";
Packit 57988d
      }
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %RAIDErrors) {
Packit 57988d
   print "\nWARNING:  RAID Errors Present\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %RAIDErrors ) {
Packit 57988d
      print "   $Thisone ...:  $RAIDErrors{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %DRBDErrors) {
Packit 57988d
   print "\nWARNING:  DRBD Errors Present\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %DRBDErrors ) {
Packit 57988d
      foreach my $Msg (sort {$a cmp $b} keys %{$DRBDErrors{$Thisone}}) {
Packit 57988d
         print "   $Thisone: $Msg";
Packit 57988d
         print " :  $DRBDErrors{$Thisone}{$Msg} Time(s)" if $DRBDErrors{$Thisone}{$Msg} > 1;
Packit 57988d
         print "\n";
Packit 57988d
      }
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %SegFaults) {
Packit 57988d
   my $header_printed=0;
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %SegFaults ) {
Packit 57988d
      if ($Ignore_faults =~ /\b\Q$Thisone\E\b/i) { next; }
Packit 57988d
      if (!$header_printed) {
Packit 57988d
         print "\nWARNING:  Segmentation Faults in these executables\n";
Packit 57988d
         $header_printed=1;
Packit 57988d
      }
Packit 57988d
      print "   $Thisone :  $SegFaults{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %GPFaults) {
Packit 57988d
   my $header_printed=0;
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %GPFaults ) {
Packit 57988d
      if ($Ignore_faults =~ /\b\Q$Thisone\E\b/i) { next; }
Packit 57988d
      if (!$header_printed) {
Packit 57988d
         print "\nWARNING:  General Protection Faults in these executables\n";
Packit 57988d
         $header_printed=1;
Packit 57988d
      }
Packit 57988d
      print "   $Thisone :  $GPFaults{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %TrapInt3s) {
Packit 57988d
   my $header_printed=0;
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %TrapInt3s ) {
Packit 57988d
      if ($Ignore_faults =~ /\b\Q$Thisone\E\b/i) { next; }
Packit 57988d
      if (!$header_printed) {
Packit 57988d
         print "\nWARNING:  Trap int3 in these executables\n";
Packit 57988d
         $header_printed=1;
Packit 57988d
      }
Packit 57988d
      print "   $Thisone :  $TrapInt3s{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %UnalignedErrors) {
Packit 57988d
   print "\nWARNING:  Unaligned Errors in these executables\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %UnalignedErrors ) {
Packit 57988d
      print "   $Thisone :  $UnalignedErrors{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %FPAssists) {
Packit 57988d
   print "\nWARNING:  Floating-Point Assists in these executables\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %FPAssists ) {
Packit 57988d
      print "   $Thisone :  $FPAssists{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %OOM) {
Packit 57988d
   print "\nWARNING:  Out of memory killer killed these executables\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %OOM ) {
Packit 57988d
      print "   $Thisone :  $OOM{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %Errors) {
Packit 57988d
   print "\nWARNING:  Kernel Errors Present\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %Errors ) {
Packit 57988d
      print "   $Thisone ...:  $Errors{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
if (keys %EDACs) {
Packit 57988d
   print "\nWARNING:  Kernel EDAC Messages\n";
Packit 57988d
   foreach my $Thisone ( sort {$a cmp $b} keys %EDACs ) {
Packit 57988d
      print "   $Thisone ...:  $EDACs{$Thisone} Time(s)\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
# OTHER
Packit 57988d
if ( ($Detail >= 5) and (keys %Kernel) ) {
Packit 57988d
   print "\n";
Packit 57988d
   foreach my $ThisOne (sort {$a cmp $b} keys %Kernel) {
Packit 57988d
      print $Kernel{$ThisOne} . " Time(s): " . $ThisOne . "\n";
Packit 57988d
   }
Packit 57988d
}
Packit 57988d
Packit 57988d
exit(0);
Packit 57988d
Packit 57988d
# vi: shiftwidth=3 tabstop=3 syntax=perl et
Packit 57988d
# Local Variables:
Packit 57988d
# mode: perl
Packit 57988d
# perl-indent-level: 3
Packit 57988d
# indent-tabs-mode: nil
Packit 57988d
# End: