##########################################################################
# $Id: openvpn,v 1.3 2005/02/24 17:08:05 kirk Exp $
##########################################################################

########################################################
# Logwatch was written and is maintained by:
#    Kirk Bauer <kirk@kaybee.org>
#
# The openvpn script was written by:
#    Jim Richardson <develop@aidant.net>
#
########################################################

my $Debug = $ENV{'LOGWATCH_DEBUG'};
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'};
   
if ( $Debug >= 5 ) {
    print STDERR "\n\nDEBUG \n\n";
}

while (defined($ThisLine = <STDIN>)) {
   chomp($ThisLine);
   if (
      ($ThisLine =~ /^TLS: soft reset/) or
      ($ThisLine =~ /^TLS: tls_process: killed expiring key$/) or
      ($ThisLine =~ /^Control Channel: TLSv1, cipher/) or
      ($ThisLine =~ /^Data Channel Decrypt: Cipher/) or
      ($ThisLine =~ /^Data Channel Decrypt: Using/) or
      ($ThisLine =~ /^Data Channel Encrypt: Cipher/) or
      ($ThisLine =~ /^Data Channel Encrypt: Using/)
   ) {
      # Don't care about these...
   }  elsif (($status, $org, $cn) = ( $ThisLine =~ /^VERIFY (.*): depth=.*O=(.*)\/OU=.*CN=(.*)\// )) {

		#TLS: tls_process: killed expiring key:
		#VERIFY OK: depth=0, /C=US/ST=TX/O=Aidant.Enterprises/OU=IT/CN=delta.aidant.net/Email=keymaster@aidant.net: 23 Time(s)
      $VerifyList{"status: $status ORG: $org CN: $cn"}++;
		 

   } else {
      # Report any unmatched entries...
      # remove PID from named messages
      #$ThisLine =~ s/^(client [.0-9]+)\S+/$1/;
      $OtherList{$ThisLine}++;
   }
   #$LastLine = $ThisLine;
}

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


if (keys %VerifyList) {
   print "Verify\n";
   foreach $line (sort {$a cmp $b} keys %VerifyList) {
      print "   $line: $VerifyList{$line} Time(s)\n";
   }
}

if (keys %OtherList) {
   print "\n**Unmatched Entries**\n";
   foreach $line (sort {$a cmp $b} keys %OtherList) {
      print "   $line: $OtherList{$line} Time(s)\n";
   }
}

exit(0);


# vi: shiftwidth=3 tabstop=3 syntax=perl et

