The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::Toaster::Logs

SYNOPSIS

Perl modules related to mail logging. These modules are used primarily in maillogs but may be used in toaster-watcher.pl and toaster_setup.pl as well.

METHODS

new

Create a new Mail::Toaster::Logs object.

    use Mail::Toaster::Logs;
    $logs = Mail::Toaster::Logs->new;

ReportYesterday

email a report of yesterdays email traffic.

CheckSetup

Does some checks to make sure things are set up correctly.

    $logs->CheckSetup($conf);

tests:

  logs base directory exists
  logs based owned by qmaill
  counters directory exists
  maillogs is installed

CheckForFlags

Do the appropriate things based on what argument is passed on the command line.

        $logs->CheckForFlags($conf, $prot, $debug);

$conf is a hashref of configuration values, assumed to be pulled from toaster-watcher.conf.

$prot is the protocol we're supposed to work on.

rbl_count

Count the number of connections we've blocked (via rblsmtpd) for each RBL that we use.

        $logs->rbl_count($conf, $debug);

smtp_count

        $logs->smtp_count($conf, $syslog);

Count the number of times users authenticate via SMTP-AUTH to our qmail-smtpd daemon.

send_count

        $logs->send_count($conf);

Count the number of messages we deliver, and a whole mess of stats from qmail-send.

imap_count

        $logs->imap_count($conf, $syslog);

Count the number of connections and successful authentications via IMAP and IMAP-SSL.

pop3_count

        $logs->pop3_count($conf, $syslog);

Count the number of connections and successful authentications via POP3 and POP3-SSL.

webmail_count

        $logs->webmail_count($conf, $syslog);

Count the number of webmail authentications.

spama_count

        $logs->spama_count($conf, $syslog);

Count statistics logged by SpamAssassin.

qms_count

        $logs->qms_count($conf, $syslog);

Count statistics logged by qmail scanner.

RollSendLogs

        $logs->RollSendLogs($conf, $debug);

Roll the qmail-send multilog logs. Update the maillogs counter.

RollRblLogs

        $logs->RollRblLogs($conf, $debug);

Roll the qmail-smtpd logs (without 2>&1 output generated by rblsmtpd).

RollPOP3Logs

        $logs->RollPOP3Logs($conf);

These logs will only exist if tcpserver debugging is enabled. Rolling them is not likely to be necessary but the code is here should it ever prove necessary.

CompressYesterdaysLogfile

        CompressYesterdaysLogfile($conf, $file, $debug);

You'll have to guess what this does. ;)

PurgeLastMonthLogs

        PurgeLastMonthLogs($conf, $protdir, $debug);

Keep guessing...

RotateMailLogs

        RotateMailLogs(@dirs);

Tell multilog to rotate the maillogs for the array of dirs supplied.

SetupDateVariables

        SetupDateVariables($offset);

CheckLogFiles

        CheckLogFiles(@check);

ProcessPOP3Logs

ProcessRblLogs

CountRblLine

ProcessSendLogs

CountSendLine

counter_read

        $logs->counter_read($file, $debug);

$file is the file to read from. $debug is optional, it prints out verbose messages during the process. The sub returns a hashref full of key value pairs.

counter_write

        $logs->counter_write($file, %values);

$file is the logfile to write to.

%values is a hash of value=count style pairs.

returns 1 if writable, 0 if not.

what_am_i

        $logs->what_am_i(;$debug)

Determine what the filename of this program is. This is used in maillogs, as maillogs gets renamed in order to function as a log post-processor for multilog.

syslog_locate

        $logs->syslog_locate($debug);

Determine where syslog.mail is logged to. Right now we just test based on the OS you're running on and assume you've left it in the default location. This is easy to expand later.

Design considerations

  • Counters will be polled via SNMP. Script must be able to return counts instantly, even when dealing with HUGE logs.

  • Must work with multilog and syslog logging formats

  • Outputs data in a format suitable for polling via SNMP

  • Simple configuration

  • Fail safe, errors must be noticed and reported but not fatal

AUTHOR

Matt Simerson <matt@tnpi.biz>

BUGS

None known. Report any to author.

SEE ALSO

http://www.tnpi.biz/internet/mail/toaster/

Mail::Toaster::CGI, Mail::Toaster::DNS, Mail::Toaster::Logs, Mail::Toaster::Qmail, Mail::Toaster::Setup

COPYRIGHT

Copyright (c) 2004, The Network People, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the The Network People, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.