/usr/share/logwatch/scripts/services/stunnel is in logwatch 7.4.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | #!/usr/bin/perl
##########################################################################
# $Id: stunnel 238 2014-09-16 08:00:55Z stefjakobs $
##########################################################################
#######################################################
## Copyright (c) 2008 Kirk Bauer
## Covered under the included MIT/X-Consortium License:
## http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms. If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions. If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################
$^W=1;
use strict;
my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
my $DebugCounter = 0;
my $Top = $ENV{'stunnel_print_top'} || 20;
if ( $Debug >= 5 ) {
print STDERR "\n\nDEBUG: Inside stunnel Filter \n\n";
$DebugCounter = 1;
}
my @OtherList = ();
my %OtherList = ();
my %connections = ();
my %versioninfo = ();
my %errors = ();
my %notices = ();
my $sockdata = 0;
my $ssldata = 0;
sub other {
my $msg = shift;
unless (exists $OtherList{$msg}) {
$OtherList{$msg} = 1;
push(@OtherList, $msg);
} else {
$OtherList{$msg}++;
}
}
my $ThisLine;
while (defined($ThisLine = <STDIN>)) {
$ThisLine =~ s/LOG\d\[\d{1,5}:\d{15}\]: (.*)/$1/;
if ( $Debug >= 5 ) {
print STDERR "DEBUG($DebugCounter): $ThisLine";
$DebugCounter++;
}
chomp($ThisLine);
my $origline = $ThisLine;
if ($ThisLine =~ m/^(.+) connected from (\d+\.\d+\.\d+\.\d+)/) {
my $service = $1;
my $ip = $2;
if (! exists($connections{$service}{$ip})) {
$connections{$service}{$ip} = 0;
}
++$connections{$service}{$ip};
} elsif ($ThisLine =~ m/^Connection (reset|closed): (\d+) bytes sent to SSL, (\d+) bytes sent to socket/) {
$ssldata += $2;
$sockdata += $3;
} elsif ($ThisLine =~ m/^Connection (reset|closed)/) {
# ignore
} elsif ($ThisLine =~ m/^connect_blocking: connected/) {
# ignore
} elsif ($ThisLine =~ m/^Log file reopened$/) {
# ignore
} elsif ($ThisLine =~ m/^SSL socket closed on SSL_read with \d+ byte\(s\) in buffer$/) {
# ignore
} elsif ($ThisLine =~ m/^stunnel [\d\.]+ on [\w\-]+ [\w\+]+ with OpenSSL [\w\.]+ \d+ \w+ \d+/) {
$versioninfo{$ThisLine} = 1;
} elsif ($ThisLine =~ m/^Service (\S+) accepted connection from ([0-9a-fA-F.:]+):\d{1,5}/) {
$connections{$1}{$2}++;
} elsif ($ThisLine =~ m/^Service (\S+) connected remote server from ([0-9a-fA-F.:]+):\d{1,5}/) {
$connections{"remote: $1"}{$2}++;
} elsif ($ThisLine =~ m/^Error detected on (SSL|socket) \((read|write)\) file descriptor: (.*) \(\d+\)/) {
$errors{"$1 $2 file descriptor: $3"}++;
} elsif ($ThisLine =~ m/^transfer: s_poll_wait: TIMEOUTclose exceeded: closing$/) {
$notices{"TIMEOUTclose exceeded: closing connection"}++;
} elsif ($ThisLine =~ m/^(SSL_(?:accept|read|shutdown): .*|getpeerbyname: .*)(?: \(\d+\))?$/) {
$notices{$1}++;
} else {
# Report any unmatched entries...
other($ThisLine);
}
}
if (keys %errors) {
print "\nErrors:\n";
foreach my $e (sort keys %errors) {
printf " %-50s %6d time(s)\n", $e, $errors{$e};
}
}
if (keys %notices) {
print "\nNotices:\n";
foreach my $n (sort keys %notices) {
printf " %-50s %6d time(s)\n", $n, $notices{$n};
}
}
if (keys %connections) {
print "\nconnections:\n";
foreach my $service (sort keys %connections) {
print " $service\n";
my $ips = $connections{$service};
my $i = 0;
foreach my $ip (sort {$connections{$service}{$b} <=> $connections{$service}{$a}} keys %{$connections{$service}}) {
if ($i >= $Top) {
printf " %-48s\n", "... only top $Top printed ...";
last;
} else {
printf " %-48s %6d time(s)\n", $ip, $connections{$service}{$ip};
$i++;
}
}
}
}
if ($sockdata > 0) {
if ($sockdata > 1024*1024) {
printf "\n%-48s %10.2f MB\n", "amount of socket data transferred:", $sockdata / 1024 / 1024;
} else {
printf "\n%-48s %10.2f KB\n", "amount of socket data transferred:", $sockdata / 1024;
}
}
if ($ssldata > 0) {
if ($ssldata > 1024*1024) {
printf "\n%-48s %10.2f MB\n", "amount of SSL data transferred:", $ssldata / 1024 / 1024;
} else {
printf "\n%-48s %10.2f KB\n", "amount of SSL data transferred:", $ssldata / 1024;
}
}
if (keys %versioninfo) {
print "\nversion information:\n";
foreach my $v (sort keys %versioninfo) {
print " $v\n";
}
}
if (@OtherList) {
print "\n**Unmatched Entries**\n";
for (@OtherList) {
my $count = $OtherList{$_};
print "($count) $_\n";
}
}
exit(0);
# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End:
|