[Logwatch-Devel] how to match milter logs?

Greg Matthews gmatt at nerc.ac.uk
Wed Dec 7 03:52:06 MST 2005


On Tue, 2005-12-06 at 09:50 -0800, Bjorn L. wrote:
> 
> Greg Matthews wrote:
> 
> > can I define my own variables here? ie if I want to log these as
> > $MilterAheadReject{$User} Do I declare them inside the
> > $Sendmail_MatchFilter variable? Then presumably include them in
> > $Sendmail_ReportFilter too.
> 
> That should work...  Let me know if it doesn't.

Not quite. The variable needs to be global so that it can be seen in
$Sendmail_ReportFilter as well. Therefore I have to customise the
executable script to add in this hash - . The following will then work
(usual line wrapping warnings...):

# Note that "global" variables need to be defined in the main script
# Therefore copy /usr/share/logwatch/scripts/services/sendmail
#+to /etc/logwatch/scripts/services/ and add %MilterAheadReject
$Sendmail_MatchFilter = "                                           \
if ( ($User) = ($ThisLine =~ /Milter: to=<(\S+)>, reject=.+/ ) ) {  \
       $MilterAheadReject{$User}++;                                 \
       undef $ThisLine;                                             \
    }                                                               \
"
$Sendmail_ReportFilter = "                                          \
my $count = 0;                                                      \
   if (keys %MilterAheadReject) {                                   \
      print "\n\nRejected by milter-ahead:";                        \
      foreach $User ( keys %MilterAheadReject) {                    \
         print "\n    $User: $MilterAheadReject{$User} time(s)" if
($Detail >= 5); \
         $count += $MilterAheadReject{$User} if ($Detail >= 3);     \
      }                                                             \
   print "\n\tTotal: $count";                                       \
   }                                                                \
"

Also, even with the undef line, I'm still seeing it counted as an
unmatched entry:

 Rejected by milter-ahead:
        Total: 968

 **Unmatched Entries**
    Milter (milter-ahead): init success to negotiate: 1542 Time(s)
    : 968 Time(s)


> _______________________________________________
> Logwatch-Devel mailing list
> Logwatch-Devel at logwatch.org
> http://www2.list.logwatch.org:8080/lists/listinfo/logwatch-devel
-- 
Greg Matthews           01491 692445
Head of UNIX/Linux, iTSS Wallingford



More information about the Logwatch-Devel mailing list