企业邮件服务器上线后,问题是如何查看其性能指标:员工收发邮件数量、员工邮件活跃度评分、流量指标,以及反邮件的有效性。垃圾邮件规则,包括阻止的原因。 所有这些数据都可以在 postfix 服务日志文件中获取。
为了分析日志文件,我们将安装该实用程序:
apt install pflogsumm
cp /usr/sbin/pflogsumm /usr/local/bin
让我们通过指定后缀日志文件的路径来检查脚本:
cat /var/log/mail.log | pflogsumm | more
输出将包含大量按类型分组的数据:
Grand Totals
------------
messages
51 received
50 delivered
0 forwarded
0 deferred
0 bounced
472 rejected (90%)
0 reject warnings
0 held
0 discarded (0%)
151710 bytes received
151710 bytes delivered
4 senders
4 sending hosts/domains
11 recipients
7 recipient hosts/domains
Per-Day Traffic Summary
date received delivered deferred bounced rejected
--------------------------------------------------------------------
May 14 2023 0 0 0 0 1
May 19 2023 45 44 0 0 31
May 20 2023 6 6 0 0 140
--More--
如有必要,您可以创建一个脚本,通过邮件发送报告以及 PDF 附件,以便进一步转发。 要生成 pdf 报告并发送信件,请安装必要的软件包:
apt install mailutils a2ps
让我们创建一个包含以下内容的脚本:
nano /usr/local/bin/report_pdf.sh
#!/usr/bin/env bash
rm /var/log/report.txt
rm /var/log/report.ps
rm /var/log/report.pdf
cat /var/log/mail.log | pflogsumm | more >> /var/log/report.txt
a2ps -b --header=mail.domain.tld --rows 1 --columns 1 /var/log/report.txt -o /var/log/report.ps
ps2pdf -s1 /var/log/report.ps /var/log/report.pdf
mail -s 'Mail Server Report' -a From:Mail-Server -A /var/log/report.pdf < /var/log/report.txt
分配执行权:
chmod +x /usr/local/bin/report_pdf.sh
让我们向 cron 添加一个任务,以便报告每周出现一次,因为日志每周更新一次,例如,周五 15:00:
crontab -e
0 15 * * 5 /usr/local/bin/report_pdf.sh