SendmailAnalyzer as is name suggest is a free Sendmail/Postfix log analyzer. It process maillog files and generate dynamic statistics in HTML and graphical output. The reports are generated in real time so that it let you know at any moment what is going on your mail servers. It use time (hour, day, month and year views) and cross-linked navigation for easy use.
Project Page: http://sendmailanalyzer.darold.net/
SendmailAnalyzer Installation
2.1 Download resource and make install
root@ubuntu:~# wget "http://downloads.sourceforge.net/project/sa-report/sa-report/9.2/sendmailanalyzer-9.2.tar.gz" root@ubuntu:~# tar xvzf sendmailanalyzer-9.2.tar.gz root@ubuntu:~# perl Makefile.PL root@ubuntu:~# make && make install
End of output:
----------------------------------------------------------------------------- 1. Start SendmailAnalyzer daemon with: /usr/local/sendmailanalyzer/sendmailanalyzer -f or use one of the starters script provided in the start_scripts/ directory. 2. Modify your httpd.conf to allow access to CGI scripts like follow: Alias /sareport /usr/local/sendmailanalyzer/www <Directory /usr/local/sendmailanalyzer/www> Options ExecCGI AddHandler cgi-script .cgi DirectoryIndex sa_report.cgi Order deny,allow Deny from all Allow from 192.168.1.0/24 </Directory> If necessary, give additional host access to SendmailAnalyzer in httpd.conf. Restart and ensure that httpd is running. 3. Browse to http://mta.host.dom/sareport/ to ensure that things are working properly. 4. Setup a cronjob to run sa_cache and restart SendmailAnalyzer daemon after maillog logrotate as follow: # SendmailAnalyzer log reporting daily cache 0 1 * * * /usr/local/sendmailanalyzer/sa_cache > /dev/null 2>&1 # On huge MTA you may want to have five minutes caching #*/5 * * * * /usr/local/sendmailanalyzer/sa_cache -a > /dev/null 2>&1 5. Add an entry in /etc/logrotate.d/syslog to restart SendmailAnalyzer when maillog is rotated or create a cron job. For more information, see /usr/local/sendmailanalyzer/doc/README file. -----------------------------------------------------------------------------
2.2 Configure Sendmailanalyzer:
root@ubuntu:~# cd /usr/local/sendmailanalyzer/ root@ubuntu:~# vi sendmailanalyzer.conf ----------------------------------------------------------------------------- # Path to the maillog file to analyse. # Can be overwritten with --log or -l LOG_FILE /var/log/mail.log ----------------------------------------------------------------------------- root@ubuntu:~# ./sendmailanalyzer -f root@ubuntu:~# cp -p sendmailanalyzer /etc/init.d/sendmailanalyzer root@ubuntu:~# service sendmailanalyzer restart
2.3 Configure Apache2:
root@ubuntu:~# vi /etc/apache2/sites-available/sendmailanalyzer.conf ----------------------------------------------------------------------------- Alias /sareport /usr/local/sendmailanalyzer/www <Directory /usr/local/sendmailanalyzer/www> Options ExecCGI AddHandler cgi-script .cgi DirectoryIndex sa_report.cgi AllowOverride all Require all granted #Order deny,allow #Deny from all Allow from all </Directory> ----------------------------------------------------------------------------- root@ubuntu:~# a2ensites sendmailanalyzer.conf root@ubuntu:~# service apache2 reload
2.3 Addition step – Enable Apache CGI:
root@ubuntu:~# a2enmod cgi root@ubuntu:~# service apache2 restart
2.4 Access Sendmailanalyzer via web-base:
- ie: http://yourdomain.tld/sareport/
2.5 Setup Crontab
- See the #4 of Output console on the step 2.1.
3. Troubleshooting with SendMailAnalyzer
1. Parsing old/missed log files – all log from scratch.
At the first time running SendMailAnalyzer, I got an little issue when view report for the past month/year,
root@localhost:~# service sendmailanalyzer stop root@localhost:~# killall -e sendmailanalyzer root@localhost:~# rm /usr/local/sendmailanalyzer/data/LAST_PARSED root@localhost:~# rm /usr/local/sendmailanalyzer/data/* -R root@localhost:~# for log in `ls -tr /var/log/mail*`; do /usr/local/sendmailanalyzer/sendmailanalyzer -bfl $log; done root@localhost:~# service sendmailanalyzer start
2. No cache file found /usr/local/sendmailanalyzer/data/…/cache.pm
No cache file found (/usr/local/sendmailanalyzer/data/example/2018/04/cache.pm) , please run sa_cache as explain in the documentation (See Caching).
root@localhost:~# for month in 01 02 03 04 05 06 07 08 09 10 11 12 ; do /usr/local/sendmailanalyzer/sa_cache -s "example" -d "2018/$month"; done