|
Packit Bot |
ea69bd |
########################################################
|
|
Packit Bot |
ea69bd |
## Copyright (c) 2016 Orion Poplawski
|
|
Packit Bot |
ea69bd |
## Covered under the included MIT/X-Consortium License:
|
|
Packit Bot |
ea69bd |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit Bot |
ea69bd |
## All modifications and contributions by other persons to
|
|
Packit Bot |
ea69bd |
## this script are assumed to have been donated to the
|
|
Packit Bot |
ea69bd |
## Logwatch project and thus assume the above copyright
|
|
Packit Bot |
ea69bd |
## and licensing terms. If you want to make contributions
|
|
Packit Bot |
ea69bd |
## under your own copyright or a different license this
|
|
Packit Bot |
ea69bd |
## must be explicitly stated in the contribution an the
|
|
Packit Bot |
ea69bd |
## Logwatch project reserves the right to not accept such
|
|
Packit Bot |
ea69bd |
## contributions. If you have made significant
|
|
Packit Bot |
ea69bd |
## contributions to this script and want to claim
|
|
Packit Bot |
ea69bd |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit Bot |
ea69bd |
#########################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
use strict;
|
|
Packit Bot |
ea69bd |
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Packit Bot |
ea69bd |
my %Activated;
|
|
Packit Bot |
ea69bd |
my %Failed;
|
|
Packit Bot |
ea69bd |
my $Reexecuted = 0;
|
|
Packit Bot |
ea69bd |
my %Reloaded;
|
|
Packit Bot |
ea69bd |
my %Slice;
|
|
Packit Bot |
ea69bd |
my %Started;
|
|
Packit Bot |
ea69bd |
my %Target;
|
|
Packit Bot |
ea69bd |
my $TimeChanged = 0;
|
|
Packit Bot |
ea69bd |
my $LastTarget;
|
|
Packit Bot |
ea69bd |
my %UserSession;
|
|
Packit Bot |
ea69bd |
my %OtherList;
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
# Failue will generate multiple messages like:
|
|
Packit Bot |
ea69bd |
# Feb 5 16:37:50 hostname systemd: ansible-pull.service: main process exited, code=exited, status=2/INVALIDARGUMENT
|
|
Packit Bot |
ea69bd |
# Feb 5 16:37:50 hostname systemd: Failed to start Run ansible-pull on boot.
|
|
Packit Bot |
ea69bd |
# Feb 5 16:37:50 hostname systemd: Unit ansible-pull.service entered failed state.
|
|
Packit Bot |
ea69bd |
# Feb 5 16:37:50 hostname systemd: ansible-pull.service failed.
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
while (defined(my $ThisLine = <STDIN>)) {
|
|
Packit Bot |
ea69bd |
chomp($ThisLine);
|
|
Packit Bot |
ea69bd |
if ($ThisLine =~ /^(Activating|Deactivating|Mounting|Unmounting|Starting|Stopping) / or
|
|
Packit Bot |
ea69bd |
# These events will be caught with the Unit X entered failed state message
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Failed to start / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ / failed\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /: (control|main) process exited, code=(exited|killed),? status=/ or
|
|
Packit Bot |
ea69bd |
# Informational
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Closed .* socket\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Closed udev / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Detected (architecture|virtualization) / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Found device / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Got automount request for \/proc\// or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Inserted module / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Listening on / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Mounted / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Relabelled / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Reloading\.$/ or # Happens on each boot at switch root
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Running in initial RAM disk\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Set hostname to / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Shutting down\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Startup finished in / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Stopped / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Switching root\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Successfully loaded SELinux policy in / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /: Supervising process .* which is not our child\. We'll most likely not notice when it exits\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^systemd (\d+) running in system mode/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Unit .* is bound to inactive unit .*\. Stopping, too\./ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Unit .* is not needed anymore\. Stopping\./ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Unmounted / or
|
|
Packit Bot |
ea69bd |
# Units can depend on files that do not exist
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Cannot add dependency job for unit .*, ignoring: Unit .* failed to load: No such file or directory\.$/ or
|
|
Packit Bot |
ea69bd |
# https://bugs.freedesktop.org/show_bug.cgi?id=90386
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Device .* appeared twice with different sysfs paths .* and / or
|
|
Packit Bot |
ea69bd |
# Inactive units are sometimes reloaded
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Unit .* cannot be reloaded because it is inactive\.$/ or
|
|
Packit Bot |
ea69bd |
# https://bugzilla.redhat.com/show_bug.cgi?id=1293941
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Configuration file \/usr\/lib\/systemd\/system\/auditd\.service is marked world-inaccessible/ or
|
|
Packit Bot |
ea69bd |
# https://bugzilla.redhat.com/show_bug.cgi?id=1301182
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Configuration file \/usr\/lib\/systemd\/system\/wpa_supplicant\.service is marked executable/ or
|
|
Packit Bot |
ea69bd |
# https://bugzilla.redhat.com/show_bug.cgi?id=1306452
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^tmp\.mount: Directory \/tmp to mount over is not empty, mounting anyway\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Received SIGRTMIN\+2[01] from PID \d+ \(plymouthd\)\.$/ or
|
|
Packit Bot |
ea69bd |
# https://bugzilla.redhat.com/show_bug.cgi?id=1072368
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Received SIGRTMIN\+24 from PID \d+ \(kill\)\.$/ or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^Removed slice / or
|
|
Packit Bot |
ea69bd |
$ThisLine =~ /^pam_unix\(systemd-user:session\): session (?:opened|closed) for user/
|
|
Packit Bot |
ea69bd |
) {
|
|
Packit Bot |
ea69bd |
# Ignore these
|
|
Packit Bot |
ea69bd |
} elsif (my ($service) = ($ThisLine =~ /^Unit (.*) entered failed state\.$/)) {
|
|
Packit Bot |
ea69bd |
$Failed{$service}++;
|
|
Packit Bot |
ea69bd |
} elsif (my ($target) = ($ThisLine =~ /^Reached target (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$Target{$target}++;
|
|
Packit Bot |
ea69bd |
$LastTarget = $target;
|
|
Packit Bot |
ea69bd |
} elsif (my ($session, $user) = ($ThisLine =~ /^Started Session (\d+) of user (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$UserSession{$user}->{$session}++;
|
|
Packit Bot |
ea69bd |
} elsif (my ($service) = ($ThisLine =~ /^Activated (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$Activated{$service}++;
|
|
Packit Bot |
ea69bd |
} elsif (my ($service) = ($ThisLine =~ /^Started (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$Started{$service}++;
|
|
Packit Bot |
ea69bd |
} elsif (my ($service) = ($ThisLine =~ /^Reloaded (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$Reloaded{$service}++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine eq "Reexecuting.") {
|
|
Packit Bot |
ea69bd |
$Reexecuted++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ /^Time has been changed$/) {
|
|
Packit Bot |
ea69bd |
$TimeChanged++;
|
|
Packit Bot |
ea69bd |
} elsif (my ($slice) = ($ThisLine =~ /^Created slice (.*)\.$/)) {
|
|
Packit Bot |
ea69bd |
$Slice{$slice}++;
|
|
Packit Bot |
ea69bd |
} else {
|
|
Packit Bot |
ea69bd |
$OtherList{$ThisLine}++;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Failed) {
|
|
Packit Bot |
ea69bd |
print "ERROR: Failed state:\n";
|
|
Packit Bot |
ea69bd |
foreach my $item (sort {$a cmp $b} keys %Failed) {
|
|
Packit Bot |
ea69bd |
print " $item $Failed{$item} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if ($Reexecuted && $Detail) {
|
|
Packit Bot |
ea69bd |
print "Reexecuted systemd: $Reexecuted Time(s)\n\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Target && $Detail > 3) {
|
|
Packit Bot |
ea69bd |
print "Reached target $LastTarget: $Target{$LastTarget} Time(s)";
|
|
Packit Bot |
ea69bd |
if ($Detail > 10) {
|
|
Packit Bot |
ea69bd |
print ", and:\n";
|
|
Packit Bot |
ea69bd |
foreach my $target (sort {$a cmp $b} keys %Target) {
|
|
Packit Bot |
ea69bd |
print " $target: $Target{$target} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
} else {
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Started && $Detail > 3) {
|
|
Packit Bot |
ea69bd |
print "Started:\n";
|
|
Packit Bot |
ea69bd |
foreach my $started (sort {$a cmp $b} keys %Started) {
|
|
Packit Bot |
ea69bd |
print " $started: $Started{$started} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Activated && $Detail > 3) {
|
|
Packit Bot |
ea69bd |
print "Activated:\n";
|
|
Packit Bot |
ea69bd |
foreach my $item (sort {$a cmp $b} keys %Activated) {
|
|
Packit Bot |
ea69bd |
print " $item: $Activated{$item} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Reloaded && $Detail > 5) {
|
|
Packit Bot |
ea69bd |
print "Reloaded:\n";
|
|
Packit Bot |
ea69bd |
foreach my $item (sort {$a cmp $b} keys %Reloaded) {
|
|
Packit Bot |
ea69bd |
print " $item: $Reloaded{$item} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if ($TimeChanged && $Detail > 5) {
|
|
Packit Bot |
ea69bd |
print "Time Changed $TimeChanged Time(s)\n\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %UserSession && $Detail > 3) {
|
|
Packit Bot |
ea69bd |
print "User Sessions:\n";
|
|
Packit Bot |
ea69bd |
foreach my $user (sort {$a cmp $b} keys %UserSession) {
|
|
Packit Bot |
ea69bd |
print " $user: ";
|
|
Packit Bot |
ea69bd |
if ($Detail >= 10) {
|
|
Packit Bot |
ea69bd |
foreach my $session (sort {$a cmp $b} keys %{$UserSession{$user}}) {
|
|
Packit Bot |
ea69bd |
print " $session";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
} else {
|
|
Packit Bot |
ea69bd |
print scalar(keys %{$UserSession{$user}}) . ": Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %Slice && $Detail > 5) {
|
|
Packit Bot |
ea69bd |
print "Slices created:\n";
|
|
Packit Bot |
ea69bd |
foreach my $slice (sort {$a cmp $b} keys %Slice) {
|
|
Packit Bot |
ea69bd |
print " $slice $Slice{$slice} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %OtherList) {
|
|
Packit Bot |
ea69bd |
print "\n\n**Unmatched Entries**\n";
|
|
Packit Bot |
ea69bd |
foreach my $line (sort {$a cmp $b} keys %OtherList) {
|
|
Packit Bot |
ea69bd |
print " $line: $OtherList{$line} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
exit(0);
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit Bot |
ea69bd |
# Local Variables:
|
|
Packit Bot |
ea69bd |
# mode: perl
|
|
Packit Bot |
ea69bd |
# perl-indent-level: 3
|
|
Packit Bot |
ea69bd |
# indent-tabs-mode: nil
|
|
Packit Bot |
ea69bd |
# End:
|