#! /usr/bin/env bash set -euo pipefail IFS=$'\n\t' set +e postfix_received=$(journalctl --since "0:00" _EXE=/usr/lib/postfix/bin/smtpd|grep "proxy-accept"| wc -l) rbl_dropped=$(journalctl --since "0:00" -u postfix |grep "Service unavailable"|wc -l) spampd_clean=$(journalctl --since "0:00" -u spampd| grep "clean message"| wc -l) spampd_spam=$(journalctl --since "0:00" -u spampd| grep "identified spam"| wc -l) sieve_spam=$(journalctl --since "0:00" _EXE=/usr/lib/dovecot/dovecot-lda| grep "Spam"| wc -l) postfix_sent=$(journalctl --since "0:00" _EXE=/usr/lib/postfix/bin/smtp |grep "sent"| wc -l) date=$(date -I) set -e echo "Mail statistics for $(hostname) on $date" echo "Received total: $postfix_received" echo "RBL dropped: $rbl_dropped" echo "Spampd clean: $spampd_clean" echo "Spampd spam: $spampd_spam" echo "Sieve spam: $spampd_spam" echo "Sent: $postfix_sent"