File: kernel

package info (click to toggle)
logwatch 7.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (295 lines) | stat: -rw-r--r-- 11,662 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

#####################################################
## Copyright (c) 2008 Kirk Bauer
## Covered under the included MIT/X-Consortium License:
##    http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms.  If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions.  If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################

use strict;
use Logwatch ':ip';

my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
my $Ignore_cpu_throttled = $ENV{'ignore_cpu_throttled'} || 0;
my $Ignore_faults = $ENV{'ignore_faults'};
my $Ignore_rpcsec_expired = $ENV{'ignore_rpcsec_expired'} || 0;
my $Ignore_messages = $ENV{'kernel_ignore_messages'} || '^$';
my $CPUThrottled = 0;
my %SYNflood = ();
my %RAIDErrors = ();
my %DRBDErrors = ();
my %SegFaults = ();
my %GPFaults = ();
my %TrapInt3s = ();
my %UnalignedErrors = ();
my %FPAssists = ();
my %OOM = ();
my %Errors = ();
my %Kernel = ();
my %EDACs = ();
my %NFS = ();
my %EXT4Volume = ();
my %EXT4 = ();

#Init String Containers
my (
$Volume,    $errormsg,  $from,
$host,      $on
);
while (defined(my $ThisLine = <STDIN>)) {
   chomp($ThisLine);
   next if ($ThisLine eq '');
   # Remove timestamp if present
   $ThisLine =~ s/^\[\s*\d+\.\d+\]\s*//;

   if (
      # filter out audit messages - these should be parsed by the audit
      # service
      ($ThisLine =~ /(type=\d+\s+)?audit\(/)
      # following now in iptables service
      or ($ThisLine =~ /^Packet log: .*PROTO=/)
      or ($ThisLine =~ /IN=.*OUT=.*SRC=.*DST=.*PROTO=/)
      or ($ThisLine =~ /RAS: Correctable Errors collector initialized/)
      # user specified ignore messages, lower cased
      or ($ThisLine =~ /$Ignore_messages/i)
      ) { # ignore the above strings
   } elsif ( ($from,$on) = ( $ThisLine =~ /^Warning: possible SYN flood from ([^ ]+) on ([^ ]+):.+ Sending cookies/ ) ) {
      my $Fullfrom = LookupIP($from);
      my $Fullon = LookupIP($on);
      $SYNflood{$Fullon}{$Fullfrom}++;
   } elsif ($ThisLine =~ /temperature above threshold, cpu clock throttled/) {
      $CPUThrottled++ if not $Ignore_cpu_throttled;
   } elsif ($ThisLine =~ /continuing in degraded mode/) {
      $RAIDErrors{$ThisLine}++;
   } elsif ($ThisLine =~ /([^(]*)\[\d+\]: segfault at/) {
      $SegFaults{$1}++;
   } elsif ($ThisLine =~ /([^(]*)\[\d+\] general protection/) {
      $GPFaults{$1}++;
   } elsif ($ThisLine =~ /([^(]*)\[\d+\] trap int3 /) {
      $TrapInt3s{$1}++;
   } elsif ($ThisLine =~ /([^(]*)\(\d+\): unaligned access to/) {
      $UnalignedErrors{$1}++;
   } elsif ($ThisLine =~ /([^(]*)\(\d+\): floating-point assist fault at ip/) {
      $FPAssists{$1}++;
   } elsif ($ThisLine =~ /(?:[Kk]illed|[Kk]ill) process \d+ \((.*)\)/) {
      $OOM{$1}++;
   } elsif ($ThisLine =~ /(EDAC (?:igen6 )?(?:MC|PCI)\d:.*)/) {
      # Standard boot messages
      next if $ThisLine =~ /(?:Giving out device to |HANDLING IBECC MEMORY |MC\d+: ADDR 0x[0-9a-f]* *$)/;
      $EDACs{$1}++;
   } elsif ($ThisLine =~ /(block drbd\d+): Online verify found (\d+) \d+k block out of sync/) {
      $DRBDErrors{$1}{"$2 block(s) out of sync"} = 1;
   } elsif ($ThisLine =~ /(block drbd\d+): \[.*\] sock_sendmsg time expired/) {
      $DRBDErrors{$1}{"sock_sendmsg time expired"}++;
   } elsif ($ThisLine =~ /(block drbd\d+): Began resync as (SyncSource|SyncTarget)/) {
      $DRBDErrors{$1}{"Began resync as $2"}++;
   } elsif ( $ThisLine =~ /raid.*CRIT/) {
      # kernel: megaraid_sas 0000:88:00.0: 781934 (727946738s/0x0004/CRIT) - Enclosure PD 08(c Port 0 - 3/p1) phy bad for slot 19
      # de-dupe
      $ThisLine =~ s/: \d+ /: /;
      $ThisLine =~ s/\(\d+s\//(Xs\//;
      $Errors{$ThisLine}++;
   } elsif ( ( $errormsg ) = ( $ThisLine =~ /(.*?error.{0,17})/i ) ) {
      # filter out smb open/read errors cased by insufficient permissions
      my $SkipError = 0;
      $SkipError = 1 if $ThisLine =~ /smb_readpage_sync: .*open failed, error=-13/;
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, result=-13/;
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, error=-13/;
      # filter out error_exit in stack traces caused by OOM conditions
      $SkipError = 1 if $ThisLine =~ /\[<[\da-f]+>\] error_exit\+0x/;
      # These are informative, not errors
      $SkipError = 1 if $ThisLine =~ /ACPI _OSC request failed \(AE_ERROR\), returned control mask: 0x1d/;
      $SkipError = 1 if $ThisLine =~ /ERST: Error Record Serialization Table \(ERST\) support is initialized/;
      $SkipError = 1 if $ThisLine =~ /GHES: Generic hardware error source: \d+ notified via .* is not supported/;
      $SkipError = 1 if $ThisLine =~ /HEST: Enabling Firmware First mode for corrected errors/;
      $SkipError = 1 if $ThisLine =~ /PCIe errors handled by (?:BIOS|OS)/;
      # These happen when kerberos tickets expire, which can be normal
      $SkipError = 1 if $ThisLine =~ /Error: state manager encountered RPCSEC_GSS session expired against NFSv4 server/ && $Ignore_rpcsec_expired;
      $SkipError = 1 if $ThisLine =~ /RAS: Correctable Errors collector initialized/;
      # filter out mount options
      $SkipError = 1 if $ThisLine =~ /errors=(?:continue|remount-ro|panic)/;
      $Errors{$errormsg}++ if ( (! $SkipError) || ($Detail > 8));
   } elsif ( ( ($Volume, $errormsg) ) = ( $ThisLine =~ /^EXT4-fs \(([^)]+)\): (.*)/ ) ) {
      if ($errormsg =~ /INFO: recovery required on readonly filesystem/) {
         $EXT4Volume{$Volume} = 1;
         push @{$EXT4{$Volume}}, $errormsg;
      } elsif ($EXT4Volume{$Volume}) {
         push @{$EXT4{$Volume}}, $errormsg if $EXT4{$Volume};
         delete $EXT4Volume{$Volume} if ($errormsg =~ /recovery complete/);
      }
   } elsif ( ( $errormsg ) = ( $ThisLine =~ /((BUG|WARNING|INFO):.{0,40})/ ) ) {
      $Errors{$errormsg}++;
   } elsif ( ( $host ) = ( $ThisLine =~ /^nfs: server (.*) not responding/ ) ) {
      $NFS{$host}++;
   # OTHER
   } else {
      # XXX For now, going to ignore all other kernel messages as there
      # XXX are practically an infinite number and most of them are obviously
      # XXX not parsed here at this time.
      # filter out smb open/read errors cased by insufficient permissions
      my $SkipError = 0;
      $SkipError = 1 if $ThisLine =~ /smb_readpage_sync: .*open failed, error=-13/;
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, result=-13/;
      $SkipError = 1 if $ThisLine =~ /smb_open: .* open failed, error=-13/;
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: Out of sync: start=\d+/;
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: updated( sync)? UUIDs?/i;
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: Resync done/;
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: cs:(?:Ahead|Behind) rs_left/;
      $SkipError = 1 if $ThisLine =~ /block drbd\d+: \d+ % had equal checksums, eliminated:/;
      $Kernel{$ThisLine}++ if ( (! $SkipError) || ($Detail > 8)) ;
   }
}

if (keys %SYNflood) {
   print "\nWarning: SYN flood on:\n";
   foreach my $Thisone (sort {$a cmp $b} keys %SYNflood) {
      print "   " . $Thisone . " from:\n";
      foreach my $Next (sort {$a cmp $b} keys %{$SYNflood{$Thisone}}) {
         print "      " . $Next . ": $SYNflood{$Thisone}{$Next} Time(s)\n";
      }
   }
}

if (keys %RAIDErrors) {
   print "\nWARNING:  RAID Errors Present\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %RAIDErrors ) {
      print "   $Thisone ...:  $RAIDErrors{$Thisone} Time(s)\n";
   }
}

if (keys %DRBDErrors) {
   print "\nWARNING:  DRBD Errors Present\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %DRBDErrors ) {
      foreach my $Msg (sort {$a cmp $b} keys %{$DRBDErrors{$Thisone}}) {
         print "   $Thisone: $Msg";
         print " :  $DRBDErrors{$Thisone}{$Msg} Time(s)" if $DRBDErrors{$Thisone}{$Msg} > 1;
         print "\n";
      }
   }
}

if (keys %SegFaults) {
   my $header_printed=0;
   foreach my $Thisone ( sort {$a cmp $b} keys %SegFaults ) {
      if ($Thisone =~ /^$Ignore_faults$/) { next; }
      if (!$header_printed) {
         print "\nWARNING:  Segmentation Faults in these executables\n";
         $header_printed=1;
      }
      print "   $Thisone :  $SegFaults{$Thisone} Time(s)\n";
   }
}

if (keys %GPFaults) {
   my $header_printed=0;
   foreach my $Thisone ( sort {$a cmp $b} keys %GPFaults ) {
      if ($Thisone =~ /^$Ignore_faults$/) { next; }
      if (!$header_printed) {
         print "\nWARNING:  General Protection Faults in these executables\n";
         $header_printed=1;
      }
      print "   $Thisone :  $GPFaults{$Thisone} Time(s)\n";
   }
}

if (keys %TrapInt3s) {
   my $header_printed=0;
   foreach my $Thisone ( sort {$a cmp $b} keys %TrapInt3s ) {
      if ($Ignore_faults =~ /\b\Q$Thisone\E\b/i) { next; }
      if (!$header_printed) {
         print "\nWARNING:  Trap int3 in these executables\n";
         $header_printed=1;
      }
      print "   $Thisone :  $TrapInt3s{$Thisone} Time(s)\n";
   }
}

if (keys %UnalignedErrors) {
   print "\nWARNING:  Unaligned Errors in these executables\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %UnalignedErrors ) {
      print "   $Thisone :  $UnalignedErrors{$Thisone} Time(s)\n";
   }
}

if (keys %FPAssists) {
   print "\nWARNING:  Floating-Point Assists in these executables\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %FPAssists ) {
      print "   $Thisone :  $FPAssists{$Thisone} Time(s)\n";
   }
}

if (keys %OOM) {
   print "\nWARNING:  Out of memory killer killed these executables\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %OOM ) {
      print "   $Thisone :  $OOM{$Thisone} Time(s)\n";
   }
}

if (keys %Errors) {
   print "\nWARNING:  Kernel Errors Present\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %Errors ) {
      print "   $Thisone ...:  $Errors{$Thisone} Time(s)\n";
   }
}

if (keys %EDACs) {
   print "\nWARNING:  Kernel EDAC Messages\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %EDACs ) {
      print "   $Thisone ...:  $EDACs{$Thisone} Time(s)\n";
   }
}

if (keys %NFS) {
   print "\nWARNING:  NFS Server Not Responding Messages\n";
   foreach my $Thisone ( sort {$a cmp $b} keys %NFS ) {
      print "   $Thisone ...:  $NFS{$Thisone} Time(s)\n";
   }
}

if (keys %EXT4) {
   print "\nWARNING:  Ext4 Errors Present\n";
   foreach my $Volume ( sort {$a cmp $b} keys %EXT4 ) {
      print "   $Volume:\n";
      foreach my $Msg (@{$EXT4{$Volume}}) {
         print "      $Msg\n";
      }
   }
}

if ($CPUThrottled) {
   print "\nWARNING:  CPU Package temperature above threshold, cpu clock throttled $CPUThrottled Time(s)\n";
}

# OTHER
if ( ($Detail >= 5) and (keys %Kernel) ) {
   print "\n";
   foreach my $Thisone (sort {$a cmp $b} keys %Kernel) {
      print $Kernel{$Thisone} . " Time(s): " . $Thisone . "\n";
   }
}

exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End: