|
Packit |
57988d |
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# $Id$
|
|
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 |
$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Packit |
57988d |
|
|
Packit |
57988d |
while (defined($ThisLine = <STDIN>)) {
|
|
Packit |
57988d |
if (( $ThisLine =~ /open\(.*\): No such file or directory/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Id "r" respawning too fast: disabled for 5 minutes/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Re-reading inittab/) or
|
|
Packit |
57988d |
( $ThisLine =~ /.* main process ended, respawning/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Disconnected from system bus/)) {
|
|
Packit |
57988d |
# We don't care about these
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( $ThisLine =~ s/Switching to runlevel: (.)\s*$/$1/ ) {
|
|
Packit |
57988d |
# Which runlevel did we change to?
|
|
Packit |
57988d |
chomp ($ThisLine);
|
|
Packit |
57988d |
$RunLevel{$ThisLine}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( $ThisLine =~ s/^Entering runlevel: (.)\s*$/$1/ ) {
|
|
Packit |
57988d |
# Which runlevel did we enter?
|
|
Packit |
57988d |
chomp ($ThisLine);
|
|
Packit |
57988d |
$RunLevel{$ThisLine}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( $ThisLine =~ s/^Trying to re-exec init// ) {
|
|
Packit |
57988d |
# Look for telinit executions
|
|
Packit |
57988d |
chomp ($ThisLine);
|
|
Packit |
57988d |
$ReExecInit++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( ($Name,$Cause) = ($ThisLine =~ /(.*) main process \([0-9]*\) killed by (.*)/)) {
|
|
Packit |
57988d |
$ProcessKilled{"$Name,$Cause"}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( ($Name, $Status) = ($ThisLine =~ /(.*) main process \([0-9]*\) terminated with status ([0-9]*)/)) {
|
|
Packit |
57988d |
$ProcessTerminated{"$Name,Status"}++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
elsif ( $ThisLine =~ /Re-executing \/sbin\/init/) {
|
|
Packit |
57988d |
$ReExecSbinInit++;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
else {
|
|
Packit |
57988d |
# report any unmatched entries
|
|
Packit |
57988d |
push @OtherList,$ThisLine;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ((keys %RunLevel) and ($Detail >= 10)) {
|
|
Packit |
57988d |
foreach $Level (sort keys %RunLevel) {
|
|
Packit |
57988d |
print " Entered or switched to runlevel " . $Level . ": " . $RunLevel{$Level} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ReExecInit and $Detail) {
|
|
Packit |
57988d |
print "\n\nRe-execs of init: $ReExecInit times\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ReExecSbinInit and $Detail) {
|
|
Packit |
57988d |
print "\n\nRe-executing \/sbin\/init/: $ReExecSbinInit times\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ((keys %ProcessKilled) and ($Detail >=10)) {
|
|
Packit |
57988d |
print "\nKilled processses:\n";
|
|
Packit |
57988d |
foreach (keys %ProcessKilled) {
|
|
Packit |
57988d |
my ($Name,$Cause)=split ",";
|
|
Packit |
57988d |
print " Process " . $Name. " killed by " . $Cause . ": " . $ProcessKilled{"$Name,$Cause"} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ((keys %ProcessTerminated) and ($Detail >=10)) {
|
|
Packit |
57988d |
print "\nTerminated processses:\n";
|
|
Packit |
57988d |
foreach (keys %ProcessTerminated) {
|
|
Packit |
57988d |
my ($Name,$Status)=split ",";
|
|
Packit |
57988d |
print " Process " . $Name. " terminated with status " . $Cause . ": " . $ProcessTerminated{"$Name,$Status"} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($#OtherList >= 0) {
|
|
Packit |
57988d |
print "\n**Unmatched Entries**\n";
|
|
Packit |
57988d |
print @OtherList;
|
|
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:
|