Mail::Toaster::Logs
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.
Create a new Mail::Toaster::Logs object.
use Mail::Toaster::Logs; $logs = Mail::Toaster::Logs->new;
email a report of yesterdays email traffic.
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
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.
Count the number of connections we've blocked (via rblsmtpd) for each RBL that we use.
$logs->rbl_count($conf, $debug);
$logs->smtp_auth_count($conf, $syslog);
Count the number of times users authenticate via SMTP-AUTH to our qmail-smtpd daemon.
$logs->send_count($conf);
Count the number of messages we deliver, and a whole mess of stats from qmail-send.
$logs->imap_count($conf, $syslog);
Count the number of connections and successful authentications via IMAP and IMAP-SSL.
$logs->pop3_count($conf, $syslog);
Count the number of connections and successful authentications via POP3 and POP3-SSL.
$logs->webmail_count($conf, $syslog);
Count the number of webmail authentications.
$logs->spama_count($conf, $syslog);
Count statistics logged by SpamAssassin.
$logs->qms_count($conf, $syslog);
Count statistics logged by qmail scanner.
$logs->RollSendLogs($conf, $debug);
Roll the qmail-send multilog logs. Update the maillogs counter.
$logs->RollRblLogs($conf, $debug);
Roll the qmail-smtpd logs (without 2>&1 output generated by rblsmtpd).
$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($conf, $file, $debug);
You'll have to guess what this does. ;)
PurgeLastMonthLogs($conf, $protdir, $debug);
Keep guessing...
RotateMailLogs(@dirs);
Tell multilog to rotate the maillogs for the array of dirs supplied.
SetupDateVariables($offset);
CheckLogFiles(@check);
$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.
$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.
$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.
$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.
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
Matt Simerson <matt@tnpi.biz>
None known. Report any to author.
The following are all man/perldoc pages:
Mail::Toaster Mail::Toaster::Conf toaster.conf toaster-watcher.conf http://matt.simerson.net/computing/mail/toaster/
Copyright (c) 2004-2005, 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.
To install Mail::Toaster, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Toaster
CPAN shell
perl -MCPAN -e shell install Mail::Toaster
For more information on module installation, please visit the detailed CPAN module installation guide.