[Logwatch-Devel] Another Two Patches (Sendmail, QPopper)

Jim O'Halloran Jim@kendle.com.au
Mon, 17 Feb 2003 17:10:24 +1030


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C2D64F.7572B570
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C2D64F.7572B570"


------_=_NextPart_001_01C2D64F.7572B570
Content-Type: text/plain;
	charset="windows-1252"

Two more patches for LogWatch today. The first one is for the in.qpopper
script. When set to high detail, this script NOW reports a summary of all
connections for each user showing the number of messages and bytes deleted
from the server and the number and bytes in messages remaining on the
server. It also summarises duplicated unmatched entries rather than
reporting every occurrence.

The second is for the sendmail script and adds a counter for messages
scanned by MIMEDefang, and suppresses most of the log messages generated by
MIMEDefang's operations.


------_=_NextPart_001_01C2D64F.7572B570
Content-Type: text/html;
	charset="windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dwindows-1252">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2448.0">
<TITLE>Another Two Patches (Sendmail, QPopper)</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Two more patches for LogWatch today. The first one is =
for the in.qpopper script. When set to high detail, this script NOW =
reports a summary of all connections for each user showing the number =
of messages and bytes deleted from the server and the number and bytes =
in messages remaining on the server. It also summarises duplicated =
unmatched entries rather than reporting every occurrence.</FONT></P>

<P><FONT SIZE=3D2>The second is for the sendmail script and adds a =
counter for messages scanned by MIMEDefang, and suppresses most of the =
log messages generated by MIMEDefang's operations.</FONT></P>

<P><FONT FACE=3D"Arial" SIZE=3D2 COLOR=3D"#000000"></FONT><FONT =
FACE=3D"Arial" SIZE=3D2 COLOR=3D"#000000"></FONT>&nbsp;

</BODY>
</HTML>
------_=_NextPart_001_01C2D64F.7572B570--

------_=_NextPart_000_01C2D64F.7572B570
Content-Type: application/octet-stream;
	name="in.qpopper.patch030217"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="in.qpopper.patch030217"

--- in.qpopper.orig	Mon Feb 17 15:42:17 2003=0A=
+++ in.qpopper	Mon Feb 17 16:13:02 2003=0A=
@@ -20,12 +20,20 @@=0A=
     elsif ( $ThisLine =3D~ /.drac.:/ ) { =0A=
         # We don't worry about these for now=0A=
     }=0A=
-    elsif ( $ThisLine =3D~ /Stats:/ ) { =0A=
-        # We don't worry about these for now=0A=
+    ## Stats: <UserID> 0 0 0 0 <Host> <IP>=0A=
+    elsif (($UserID, $NumDeleted, $BytesDeleted, $NumLeft, $BytesLeft) =
=3D ( $ThisLine =3D~ /Stats: ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)/ =
)) { =0A=
+        $Stats{$UserID}{"Times"}++;=0A=
+        $Stats{$UserID}{"NumDel"} +=3D $NumDeleted;=0A=
+        $Stats{$UserID}{"BytesDel"} +=3D $BytesDeleted;=0A=
+        $Stats{$UserID}{"NumLeft"} =3D $NumLeft;=0A=
+        $Stats{$UserID}{"BytesLeft"} =3D $BytesLeft;=0A=
     }=0A=
     elsif ( $ThisLine =3D~ /Timing/ ) { =0A=
         # We don't worry about these for now=0A=
     }=0A=
+    elsif ( $ThisLine =3D~ /-ERR \[AUTH\]/ ) {=0A=
+        # Drop duplicated password failure lines.=0A=
+    }=0A=
     elsif ( $ThisLine =3D~ /Incorrect octet count/ ) { =0A=
         # Bogus message from LX betas prior to B20=0A=
     }=0A=
@@ -40,7 +48,8 @@=0A=
     }=0A=
     else {=0A=
         # Report any unmatched entries...=0A=
-        push @OtherList,$ThisLine;=0A=
+        chomp($ThisLine);=0A=
+        $OtherList{$ThisLine}++;        =0A=
     }=0A=
 }=0A=
 =0A=
@@ -58,9 +67,29 @@=0A=
     }=0A=
 }=0A=
 =0A=
-if ($#OtherList >=3D 0) {=0A=
-    print "\n**Unmatched Entries**\n\n";=0A=
-    print @OtherList;=0A=
+if ((keys %Stats) and ($Detail >=3D 10)) {=0A=
+    print "\nUser Statistics:\n";=0A=
+    print "                        |     Deleted    |      Kept      =
|\n";=0A=
+    print "User Name        Times  |   Num  KBytes  |   Num  KBytes  =
|\n";=0A=
+    foreach $UserID (sort =
{$Stats{$b}{"BytesDel"}<=3D>$Stats{$a}{"BytesDel"}} keys %Stats)=0A=
+    {=0A=
+        printf("%-15s  %5d  | %5d  %6d  | %5d  %6d  |\n", $UserID, =
$Stats{$UserID}{"Times"}, $Stats{$UserID}{"NumDel"}, =
$Stats{$UserID}{"BytesDel"}/1024, $Stats{$UserID}{"NumLeft"}, =
$Stats{$UserID}{"BytesLeft"}/1024);=0A=
+        $Times +=3D $Stats{$UserID}{"Times"};=0A=
+        $NumDel +=3D $Stats{$UserID}{"NumDel"};=0A=
+        $BytesDel +=3D $Stats{$UserID}{"BytesDel"};=0A=
+        $NumLeft +=3D $Stats{$UserID}{"NumLeft"};=0A=
+        $BytesLeft +=3D $Stats{$UserID}{"BytesLeft"};=0A=
+    }=0A=
+    print =
"------------------------+----------------+----------------+\n";=0A=
+    printf("TOTALS           %5d  | %5d  %6d  | %5d  %6d  |\n", =
$Times, $NumDel, $BytesDel/1024, $NumLeft, $BytesLeft/1024);=0A=
+}=0A=
+=0A=
+if (keys %OtherList) {=0A=
+   print "\n**Unmatched Entries**\n";=0A=
+   foreach $line (sort {$OtherList{$b}<=3D>$OtherList{$a} } keys =
%OtherList) =0A=
+   {=0A=
+      print "   $line: $OtherList{$line} Time(s)\n";=0A=
+   }=0A=
 }=0A=
 =0A=
 exit(0);=0A=

------_=_NextPart_000_01C2D64F.7572B570
Content-Type: application/octet-stream;
	name="sendmail.patch030214"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="sendmail.patch030214"

--- sendmail.orig	Mon Feb 17 16:33:37 2003=0A=
+++ sendmail	Tue Feb 11 16:26:25 2003=0A=
@@ -36,6 +36,11 @@=0A=
          ( $ThisLine =3D~ m/: Service unavailable$/) or =0A=
          #( $ThisLine =3D~ m/did not issue MAIL\/EXPN\/VRFY\/ETRN =
during connection/ ) or =0A=
          ( $ThisLine =3D~ m/Broken pipe|Connection (reset|timed out)/ =
) or=0A=
+         ( $ThisLine =3D~ m/X-Spam/ ) or=0A=
+         ( $ThisLine =3D~ m/Milter message: body replaced/ ) or=0A=
+         ( $ThisLine =3D~ m/Milter: data/ ) or=0A=
+         ( $ThisLine =3D~ m/Milter change: header/ ) or=0A=
+         ( $ThisLine =3D~ m/Milter delete: header/ ) or=0A=
          ( $ThisLine =3D~ m/^clone [a-zA-Z0-9]+, owner=3D/ ) ) {=0A=
       # We don't care about these=0A=
    } elsif ( ($Bytes, $NumRcpts, $RelayHost) =3D ($ThisLine =3D~ =
/^from=3D.*size=3D([0-9]+).*nrcpts=3D([0-9]+).*relay=3D(\[[0-9\.]+\]|[^ =
]* \[[0-9\.]+\]|[^ ]+).*$/) ) {=0A=
@@ -44,8 +49,10 @@=0A=
          $BytesTransferred +=3D $Bytes;=0A=
       };=0A=
       chomp($Relays{$QueueID} =3D $RelayHost);=0A=
-   } elsif ( $ThisLine =3D~ m/X-Virus-Scanned: by amavisd-milter/) =
{=0A=
+   } elsif ( $ThisLine =3D~ m/X-Virus-Scanned: by amavisd/) {=0A=
       $Amavis++;=0A=
+   } elsif ( $ThisLine =3D~ m/X-Scanned-By: MIMEDefang/) {=0A=
+      $Defang++;=0A=
    } elsif ( ($User) =3D ($ThisLine =3D~ /^<([^ ]*)>... User =
unknown$/) ) {=0A=
       $UnknownUsers{$User}{$QueueID}++;=0A=
    } elsif ( ($Host) =3D ($ThisLine =3D~ /\(Name server: ([^ ]+): host =
not found\)/)) {=0A=
@@ -143,6 +150,10 @@=0A=
    print "\n" . $Amavis . " messages scanned by Amavis";=0A=
 }=0A=
 =0A=
+if ($Defang > 0) {=0A=
+   print "\n" . $Defang . " messages scanned by MIMEDefang";=0A=
+}=0A=
+=0A=
 if ($HourReturns > 0) {=0A=
    print "\n\n" . $HourReturns . " messages returned after " . =
$NumHours . " hours";=0A=
 }=0A=

------_=_NextPart_000_01C2D64F.7572B570--