[Logwatch-Devel] logwatch script for slon (Slony daemon)

Jeff Frost jeff at frostconsultingllc.com
Tue Sep 27 13:58:48 MST 2005


I wrote a basic logwatch filter for the slon daemon, thought I'd submit it. 
It's just an adaptation of the xntpd script by David Baldwin.

/etc/log.d/conf/services/slon.conf:

###########################################################################
# $Id: slon.conf,v 1.2 2005/09/27 20:56:17 jeff Exp $
# This config file assumes that slon is
# logging to /var/log/messages, if not, you need to
# update the /etc/log.d/conf/services/slon.conf and
# possibly add a new entry in /etc/log.d/conf/logfiles
#
###########################################################################

# You can put comments anywhere you want to.  They are effective for the
# rest of the line.

# this is in the format of <name> = <value>.  Whitespace at the beginning
# and end of the lines is removed.  Whitespace before and after the = sign
# is removed.  Everything is case *insensitive*.

# Yes = True  = On  = 1
# No  = False = Off = 0

Title = "slon"

# Which logfile group...
LogFile = messages

# Only give lines pertaining to the sshd service...
*OnlyService = slon
*RemoveHeaders



/etc/log.d/scripts/services/slon

#!/usr/bin/perl
##########################################################################
# $Id: slon,v 1.4 2005/09/27 20:56:20 jeff Exp $
##########################################################################

########################################################
# This was written and is maintained by:
#    Jeff Frost <jeff.frost at frostconsultingllc.com>
#
# Heavily based on xntpd script
#
# This script and config file assumes that slon is 
# logging to /var/log/messages, if not, you need to 
# update the /etc/log.d/conf/services/slon.conf and 
# possibly add a new entry in /etc/log.d/conf/logfiles
#
# Please send all comments, suggestions, bug reports,
#    etc, to jeff.frost at frostconsultingllc.com.
########################################################

use Logwatch ':all';

$Debug = ValueOrDefault($ENV{'LOGWATCH_DEBUG'}, 0);
$Detail = ValueOrDefault($ENV{'LOGWATCH_DETAIL_LEVEL'}, 0);

# Avoid "Use of uninitialized value" warning messages.
sub ValueOrDefault {
          my ($value, $default) = @_;
          return ($value ? $value : $default);
}

if ( $Debug >= 5 ) {
          print STDERR "\n\nDEBUG: Inside SLON Filter \n\n";
          $DebugCounter = 1;
}

while (defined($ThisLine = <STDIN>)) {
     if ( $Debug >= 5 ) {
        print STDERR "DEBUG($DebugCounter): $ThisLine";
        $DebugCounter++;
     }
     chomp($ThisLine);
     if ( 0 or
         ($ThisLine =~ m/new sl_action_seq/) or
         ($ThisLine =~ m/no sets need syncing/)
     ) {
        # Ignore these
     } elsif ($ThisLine =~ m/main process started/) {
       $Starts++;
     } elsif ($ThisLine =~ m/exit/) {
       $Kills++;
     } elsif ($ThisLine =~ m/Received event/) {
       $ReceivedEvent++;
     } elsif ($ThisLine =~ m/forward confirm/) {
       $ForwardConfirm++;
     } elsif ($ThisLine =~ m/queue event/) {
       $QueueEvent++;
     } elsif ($ThisLine =~ m/SYNC \d+ processing/) {
       $SyncsProcessed++;
     } elsif ($ThisLine =~ m/cleanupThread:/) {
       $CleanupThread++;
     } elsif ($ThisLine =~ m/ERROR/) {
       $Errors++;
       push @ErrorList, "$ThisLine\n";
     } else {
        # Report any unmatched entries...
        push @OtherList, "$ThisLine\n";
     }
}

###########################################################

if ($Detail >= 5) {
 	if ($Kills) {
 	    print "\nSLON Killed: " . $Kills . " Time(s)\n";
 	}
 	if ($Starts) {
 	    print "\nSLON Started: " . $Starts . " Time(s)\n";
 	}

 	if ($CleanupThread) {
 	   print "\nSLON CleanupThread Event: " . $CleanupThread . " Time(s)\n";
 	}

 	if ($ForwardConfirm) {
 	   print "\nSLON ForwardConfirm Event: " . $ForwardConfirm . " Time(s)\n";
 	}

 	if ($ReceivedEvent) {
 	   print "\nSLON Received Event: " . $ReceivedEvent . " Time(s)\n";
 	}

 	if ($QueueEvent) {
 	   print "\nSLON Queue Event: " . $QueueEvent . " Time(s)\n";
 	}

 	if ($SyncsProcessed) {
 	   print "\nSLON Syncs Processing: " . $SyncsProcessed . " Time(s)\n";
 	}
}

if ($Errors) {
     print "\nSLON Errors: " . $Errors . "\n";
     print @ErrorList;
}

if ($#OtherList >= 0) {
     print "\n**Unmatched Entries**\n";
     print @OtherList;
}

exit(0);


-- 
Jeff Frost, Owner 	<jeff at frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954


More information about the Logwatch-Devel mailing list