CentOS安裝郵件紀錄分析軟體-SendmailAnalyzer

SendmailAnalyzer是老牌軟體了, 分析 maillog 製作成網站, 方便分析 , 軟體還在持續維護中呢

  • 安裝perl套件
yum install perl-CGI perl-CPAN perl-MIME-tools perl-GD*
  • github下載最新版後,安裝,設開機自動啟用
tar xzf sendmailanalyzer-x.x.tar.gz
cd sendmailanalyzer-x.x/
perl Makefile.PL LOGFILE=/var/log/maillog
make && make install
cp start_scripts/sendmailanalyzer.service /lib/systemd/system
  • 設定開機執行
systemctl enable sendmailanalyzer
systemctl start sendmailanalyzer
  • 網站設定
Alias /sareport /usr/local/sendmailanalyzer/www
<Directory /usr/local/sendmailanalyzer/www>
  Options ExecCGI
  AddHandler cgi-script .cgi
  DirectoryIndex sa_report.cgi
  #-- Apache 2.2
  #Order deny,allow
  #Deny from all
  #Allow from 192.168.1.0/24
  #-- Apache 2.4
  Require all denied
  Require ip 192.168.1.0/24
</Directory>
  • 設定cron 定期做快取 cache
    # 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
  • 因應logrotate會更換新的maillog, 加上更換maillog之後,重啟 SendmailAnalyzer
vi /etc/logrotate.d/syslog

################
systemctl restart sendmailanalyzer > /dev/null 2>&1 || true
################

這樣就可以透過瀏覽器查看狀態 http(s)://x.x.x.x/sareport/

發表迴響