SF.net SVN: logwatch:[113] scripts/services/cron

[email protected]
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Revision: 113
          http://logwatch.svn.sourceforge.net/logwatch/?rev=113&view=rev
Author:   stefjakobs
Date:     2012-09-25 12:54:35 +0000 (Tue, 25 Sep 2012)
Log Message:
-----------
cron: "grandchild failed with" patch from Martin Gerdes. Thanks.

Modified Paths:
--------------
    scripts/services/cron

Modified: scripts/services/cron
===================================================================
--- scripts/services/cron	2012-07-30 18:58:44 UTC (rev 112)
+++ scripts/services/cron	2012-09-25 12:54:35 UTC (rev 113)
@@ -139,12 +139,14 @@
       # Ignore
    } elsif (
       ($ThisLine =~ s/^([^ ]+) \([^ ]+\)\s+//) or
-      ($ThisLine =~ s/^\S+\s+\S+\s+..:..:..\s+\S+\s+\S+\[\d+\]:\s+\((\S+)\)\s+//)
+      ($ThisLine =~ s/^\S+\s+\S+\s+..:..:..\s+\S+\s+\S+\[(\d+)\]:\s+\((\S+)\)\s+//)
    ) {
-      $User = $1;
+      $PID  = $1;
+      $User = $2;
 
       if ($ThisLine =~ s/^CMD \((.+)\)\s*$/$1/) {
          $Runs->{$User}->{$ThisLine}++;
+         $ExecutedCommand{$PID} = {command=>$ThisLine, user=>$User};
       } elsif ($ThisLine =~ s/^CMD FINISH \((.+)\)\s*$/$1/) {
          $Runs->{$User}->{$ThisLine}++;
       } elsif ($ThisLine =~ s/^(END|CMD START) \((.+)\)\s*$/$1/) {
@@ -174,7 +176,12 @@
                   $ThisLine =~ /session closed/ ) {
          # ignore
       } elsif ( ($Reason) = ($ThisLine =~ /^error \((.+)\)$/) ) {
-         $Errors{$Reason}++;
+         if ($Reason =~ /^grandchild #(\d+) failed with exit status (\d+)/ && \
+             $ExecutedCommand{$1}) {
+#            $Reason = $ExecutedCommand{$1}{user}.": command failed with error (".$2."): ".$ExecutedCommand{$1}{command};
+            $Reason = "failed with error (".$2."): ".$ExecutedCommand{$1}{command};
+         }
+         $Errors{$ExecutedCommand{$1}{user}}{$Reason}++;
       } elsif ( ($FileName) = ($ThisLine =~ /BAD FILE MODE \((.+)\)/) ) {
          $BFMFile{$FileName}++;
       } elsif ( ($FileName) = ($ThisLine =~ /WRONG FILE OWNER \((.+)\)/) ) {
@@ -271,8 +278,11 @@
 
 if (keys %Errors) {
    print "Errors when running cron:\n";
-   foreach $Reason (sort {$a cmp $b} keys %Errors) {
-      print "   $Reason: $Errors{$Reason} Time(s)\n";
+   foreach $User (sort {$a cmp $b} keys %Errors) {
+      print "   User $User:\n";
+      foreach $Reason (sort {$a cmp $b} keys %{$Errors{$User}}) {
+         print "      $Reason: $Errors{$User}{$Reason} Time(s)\n";
+      }
    }
 }
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.