I run various sendmail log file processing scripts nightly to process the day's maillog file. At midnight, the maillog file in /var/log is rotated to /var/log/maillog.1. The log file processing scripts then analyze maillog.1 and produce reports based on its contents to allow me to track what is happening on the mail server. I added a Perl script, smlogstats, to the daily email log processing scripts.
The original smlogstats script is available from http://www.salug.org/~wcb/smlogstats.pl.txt. That script used a hardcoded output file. Since I want to maintain an archive of sendmail reports, I modified the script slightly to optionally allow the output file to be specified. The modified smlogstats.pl script has the following usage:
usage: smlogstats.pl [ -d ] [ -l logfile ] [ -o htmlfile] [ -t n ] -d print detail -l full path name to logfile (default /var/log/maillog) -o full path to the html output file (default stats.html) -t print top n addresses (default 10)
I use another script,
to produce a log file when it is run by cron every night at midnight.
The script puts its output in
/home/logfiles1/www/support/internal/logs/mail/smlogstats/$(date --date=yesterday +%Y)/$(date --date=yesterday +%m%d%y).html.
The directory path includes a directory with the year specified, i.e.
date --date=yesterday +%Y, followed by the file name, which is
yesterdays date in mmddyy format followed by an extension of html.