SF.net SVN: logwatch:[98]

[email protected]
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Revision: 98
          http://logwatch.svn.sourceforge.net/logwatch/?rev=98&view=rev
Author:   stefjakobs
Date:     2012-04-16 15:18:54 +0000 (Mon, 16 Apr 2012)
Log Message:
-----------
stunnel format mismatch and allowed_services patch from Jonas Marczona

Modified Paths:
--------------
    conf/services/stunnel.conf
    scripts/services/stunnel

Modified: conf/services/stunnel.conf
===================================================================
--- conf/services/stunnel.conf	2012-04-16 14:11:25 UTC (rev 97)
+++ conf/services/stunnel.conf	2012-04-16 15:18:54 UTC (rev 98)
@@ -17,6 +17,11 @@
 # Which logfile group...
 LogFile = secure
 
+# Reduce output for allowed services
+# all services listed comma separated in the following variable will be
+# summarized to "how often was this service used"
+$STUNNEL_ALLOWED_SERVICES = ""
+
 *OnlyService = stunnel
 *RemoveHeaders
 

Modified: scripts/services/stunnel
===================================================================
--- scripts/services/stunnel	2012-04-16 14:11:25 UTC (rev 97)
+++ scripts/services/stunnel	2012-04-16 15:18:54 UTC (rev 98)
@@ -24,6 +24,7 @@
 
 my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
 my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
+my $allowedServicesInput = $ENV{'stunnel_allowed_services'} || "";
 
 my $DebugCounter = 0;
 
@@ -35,10 +36,23 @@
 my @OtherList = ();
 my %OtherList = ();
 my %connections = ();
+my %connectionsAllowed = ();
 my %versioninfo = ();
 my $sockdata = 0;
 my $ssldata = 0;
 
+$allowedServicesInput =~ s/[\t ]*,[\t ]*/,/g;
+my %allowedServices = ();
+@allowedServices{split(/,/, $allowedServicesInput)} = ();
+
+if ($Debug >= 5) {
+  print "Allowed services are set to: \n";
+  foreach my $allowedService (sort keys %allowedServices) {
+     print $allowedService, "\n";
+  }
+  print "\n\n\n";
+}
+
 sub other {
    my $msg = shift;
    unless (exists $OtherList{$msg}) {
@@ -56,14 +70,20 @@
       $DebugCounter++;
    }
    chomp($ThisLine);
-   my $origline = $ThisLine;
-   if ($ThisLine =~ m/^(.+) connected from (\d+\.\d+\.\d+\.\d+)/) {
+   # remove leading log level and ID, eg 'LOG5[2411:3084352400]: '
+   $ThisLine =~ s/^LOG\d\[\d+:\d+\]: //;
+
+   if ( ($ThisLine =~ m/^SSL_read: Connection reset by peer/)
+   ) {
+      # ignore
+   } elsif ($ThisLine =~ m/^(.+) connected from (\d+\.\d+\.\d+\.\d+)/) {
       my $service = $1;
       my $ip = $2;
-      if (! exists($connections{$service}{$ip})) {
-        $connections{$service}{$ip} = 0;
+      if (exists($allowedServices{$service})) {
+         ++$connectionsAllowed{$service};
+      } else {
+         ++$connections{$service}{$ip};
       }
-      ++$connections{$service}{$ip};
    } elsif ($ThisLine =~ m/^Connection (reset|closed): (\d+) bytes sent to SSL, (\d+) bytes sent to socket/) {
       $ssldata += $2;
       $sockdata += $3;
@@ -78,16 +98,23 @@
 }
 
 if (keys %connections) {
-   print "\nconnections:\n";
+   print "\nNumber of connections per service per ip:\n";
    foreach my $service (sort keys %connections) {
-     print "  $service\n";
+     printf " %7s \n", $service;
      my $ips = $connections{$service};
      foreach my $ip (sort keys %$ips) {
-        print "    $ip ", $ips->{$ip}, "\n";
+        printf "    %15s : %5d time(s)\n", $ip, $ips->{$ip};
      }
    }
 }
 
+if (keys %connectionsAllowed) {
+   print "\nNumber of connections per allowed service:\n";
+   foreach my $service (sort keys %connectionsAllowed) {
+     printf " %18s : %5d time(s)\n",  $service, $connectionsAllowed{$service};
+   }
+}
+
 if ($sockdata > 0) {
    printf "\namount of socket data transferred: %.2f KB\n", $sockdata / 1024;
 }

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


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
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.