
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matt Rude &#187; Logwatch</title>
	<atom:link href="http://mattrude.com/tag/logwatch/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattrude.com</link>
	<description>Matt Rude’s Personal Website</description>
	<lastBuildDate>Thu, 15 Jul 2010 15:34:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Allow Logwatch to collect data from OpenVPN&#8217;s logs</title>
		<link>http://mattrude.com/2009/08/allow-logwatch-to-collect-data-from-openvpns-logs/</link>
		<comments>http://mattrude.com/2009/08/allow-logwatch-to-collect-data-from-openvpns-logs/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 21:46:12 +0000</pubDate>
		<dc:creator>Matt Rude</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Logwatch]]></category>
		<category><![CDATA[OpenVPN]]></category>

		<guid isPermaLink="false">http://mattrude.com/?p=959</guid>
		<description><![CDATA[To allow Logwatch to check OpenVPN&#8217;s logs running on a Fedora or other Linux system you need to install this script &#38; conf file. In order for this script &#38; config file to work you must disable both log &#38; log-append in the OpenVPN Server Config File. ;log openvpn.log ;log-append openvpn.log The Files are: /etc/logwatch/scripts/openvpn - Logwatch perl module /etc/logwatch/conf/openvpn.conf - Configuration file /etc/logwatch/scripts/openvpn #!/usr/bin/perl ########################################################################## # $Log: openvpn,v $ # Revision 1.0 2005/07/27 17:19:34 hyppo # Filippo Grassilli http://hyppo.com/email.php...


<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/06/tuning-the-number-of-processes-on-macos-x/" rel="bookmark">Tuning the number of processes on MacOS X</a><!-- (6.35184)--></li>
		<li><a href="http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/" rel="bookmark">Creating Self-signed SSL Certificates for Dovecot &#038; Postfix</a><!-- (5.92981)--></li>
		<li><a href="http://mattrude.com/2009/09/roundcube-regression-testing/" rel="bookmark">RoundCube Regression Testing</a><!-- (5.25482)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>To allow Logwatch to check OpenVPN&#8217;s logs running on a Fedora or other Linux system you need to install this script &amp; conf file.</p>
<p>In order for this script &amp; config file to work you must disable both <strong>log</strong> &amp; <strong>log-append</strong> in the OpenVPN Server Config File.</p>
<pre>;log          openvpn.log
;log-append   openvpn.log</pre>
<p><strong>The Files are:</strong></p>
<pre>/etc/logwatch/scripts/openvpn      - Logwatch perl module
/etc/logwatch/conf/openvpn.conf    - Configuration file</pre>
<p><strong>/etc/logwatch/scripts/openvpn</strong></p>
<pre>#!/usr/bin/perl
##########################################################################
# $Log: openvpn,v $
# Revision 1.0  2005/07/27 17:19:34  hyppo
# Filippo Grassilli http://hyppo.com/email.php
#
# Written and maintained by:
#    Filippo Grassilli http://hyppo.com/email.php
##########################################################################

use Logwatch ':ip';

$Debug = $ENV{'LOGWATCH_DEBUG'};
$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
$DoLookup = $ENV{'openvpn_ip_lookup'};
$Detail = $ENV{'openvpn_detail_level'} || $Detail;

if ( $Debug &gt;= 5 ) {
   print STDERR "\n\nDEBUG: Inside OpenVPN Filter \n\n";
}

while (defined($ThisLine = &lt;STDIN&gt;)) {
   if (  # Ignore...
      ($ThisLine =~ /Control Channel/) or
      ($ThisLine =~ /Data Channel (Decrypt|Encrypt|MTU)/) or
      ($ThisLine =~ /TLS: soft reset/) or
      ($ThisLine =~ /reading client specific options/) or
      ($ThisLine =~ /Expected Remote/) or
      ($ThisLine =~ /LZO compression/) or
      ($ThisLine =~ /killed expiring key/) or
      ($ThisLine =~ /Diffie-Hellman initialized/) or
      ($ThisLine =~ /Local Options hash/) or
      ($ThisLine =~ /Replay\-window backtrack/) or
      ($ThisLine =~ /TLS: Initial packet/) or
      ($ThisLine =~ /ip (addr add|link set) dev/) or
      ($ThisLine =~ /Re\-using SSL/) or
      ($ThisLine =~ /MULTI: Learn/) or
      ($ThisLine =~ /Received control message/) or
      ($ThisLine =~ /(Restart pause|process restarting)/) or
      ($ThisLine =~ /Inactivity timeout/) or
      ($ThisLine =~ /CRL CHECK OK/) or
      ($ThisLine =~ /VERIFY OK: nsCertType/) or
      ($ThisLine =~ /\d+:\d+ SIGUSR1\[.*restart/) or
      ($ThisLine =~ /^TCP\/UDP: Closing socket/) or
      ($ThisLine =~ /^UDPv4 link /) or
      ($ThisLine =~ /^TUN\/TAP device /) or
      ($ThisLine =~ /Closing TUN\/TAP interface/) or
      ($ThisLine =~ /Interrupted system call/) or
      ($ThisLine =~ /^TLS-Auth MTU parms/) or
      ($ThisLine =~ /^MULTI:/) or
      ($ThisLine =~ /^ succeeded$/) or
      ($ThisLine =~ /^IFCONFIG POOL/)
   ) {
      # Don't care about these...
   } elsif ( ($ThisLine =~ /^OpenVPN .* built on .*/) ) {
      # OpenVPN version
      chomp($ThisLine);
      $OpenVPNVersion=$ThisLine;
   } elsif ( ($ThisLine =~ /^Initialization Sequence Completed/) ) {
      $StartOpenVPN++;
   } elsif ( ($ThisLine =~ /^SIGTERM.* process exiting/) ) {
      $ShutdownOpenVPN++;
   } elsif ( ($Host,$Cert) = ( $ThisLine =~ /^([^:]*):\d+ VERIFY OK: depth=\d+, (.*)$/ ) ) {
      ## Successful cert exchange
      $FullHost = LookupIP ($Host);
      $CertVerified{$Cert}{$FullHost}++;
   } elsif ( ($Host,$User) = ( $ThisLine =~ /^([^:]*):\d+ \[([^\]]+)\] Peer Connection Init/ ) ) {
      ## x.x.x.x:y [user] Peer Connection Initiated with x.x.x.x:y
      $FullHost = LookupIP ($Host);
      $ClientConnection{$User}{$FullHost}++;
   } elsif ( ($HostUser,$Param) = ( $ThisLine =~ /^([^:]*):\d+ SENT CONTROL \[.*\]: (.*)/ ) ) {
      ## user/x.x.x.x:y SENT CONTROL [user]: xxxx....
      chomp($Param);
      $ClientParam{$HostUser}{$Param}++;
   } else {
      # Report any unmatched entries...
      chomp($ThisLine);
      $OtherList{$ThisLine}++;
   }
}

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

if ( ( $Detail &gt;= 5 ) and ($StartOpenVPN) ) {
   if ($OpenVPNVersion) { print "$OpenVPNVersion\n"; }
   print "OpenVPN started/reloaded: $StartOpenVPN Time(s)\n";
}
if ( ( $Detail &gt;= 5 ) and ($ShutdownOpenVPN) ) {
   print "OpenVPN shutdown: $ShutdownOpenVPN Time(s)\n";
}

if ( ( $Detail &gt;= 5 ) and (keys %ClientConnection) ) {
   print "\nOpenVPN Client Connections:\n";
   foreach $ThisOne (sort {$a cmp $b} keys %ClientConnection) {
      print "   $ThisOne:\n";
      foreach $Message (sort {$a cmp $b} keys %{$ClientConnection{$ThisOne}}) {
         print "       $Message: $ClientConnection{$ThisOne}{$Message} Time(s)\n";
      }
   }
}
if ( ( $Detail &gt;= 5 ) and (keys %ClientParam) ) {
   print "\nOpenVPN Client Connection Parameters:\n";
   foreach $ThisOne (sort {$a cmp $b} keys %ClientParam) {
      print "   $ThisOne:\n";
      foreach $Message (sort {$a cmp $b} keys %{$ClientParam{$ThisOne}}) {
         print "       $Message: $ClientParam{$ThisOne}{$Message} Time(s)\n";
      }
   }
}
if ( ( $Detail &gt;= 5 ) and (keys %CertVerified) ) {
   print "\nCertificates verified:\n";
   foreach $ThisOne (sort {$a cmp $b} keys %CertVerified) {
      ($Crt1,$Crt2) = ( $ThisOne =~ /^\/(.*)\/OU=(.*)$/ );
      # print " $ThisOne:\n";
      print " $Crt1\n OU=$Crt2:\n";
      foreach $Client (sort {$a cmp $b} keys %{$CertVerified{$ThisOne}}) {
         print "       $Client: $CertVerified{$ThisOne}{$Client} 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);</pre>
<p><strong>/etc/logwatch/conf/openvpn.conf</strong></p>
<pre>###########################################################################
# $Id: openvpn.conf,v 1.0 2005/07/27 17:08:09 hyppo Exp $
# Written and maintained by:
#    Filippo Grassilli &lt;http://hyppo.com/email.php&gt;
###########################################################################

Title = "OpenVPN"

# Which logfile group...
LogFile = messages

# Whether or not to lookup the IPs into hostnames...
# Setting this to Yes will significantly increase runtime
$openvpn_ip_lookup = Yes
$openvpn_detail_level = 5

# Only give lines pertaining to the named service...
*OnlyService = openvpn
*RemoveHeaders
</pre>


<br />
<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/06/tuning-the-number-of-processes-on-macos-x/" rel="bookmark">Tuning the number of processes on MacOS X</a><!-- (6.35184)--></li>
		<li><a href="http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/" rel="bookmark">Creating Self-signed SSL Certificates for Dovecot &#038; Postfix</a><!-- (5.92981)--></li>
		<li><a href="http://mattrude.com/2009/09/roundcube-regression-testing/" rel="bookmark">RoundCube Regression Testing</a><!-- (5.25482)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://mattrude.com/2009/08/allow-logwatch-to-collect-data-from-openvpns-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
