diff --git a/postfix-stats.sh b/postfix-stats.sh index a3436a4139daf7feee74436c95db05a2fb3300de..f6485fd2fd55bb03a9b6a5cd94e8b9bd3f6ae19e 100755 --- a/postfix-stats.sh +++ b/postfix-stats.sh @@ -38,6 +38,15 @@ mi_proxy_reject=0 mi_connects=0 mi_connects_tls=0 +mi_dmarc_pass=0 +mi_dmarc_fail=0 +mi_dmarc_none=0 + +mi_dkim_signed=0 +mi_dkim_error=0 +mo_dkim_signed=0 +mo_dkim_unsigned=0 + ### First time setup (if required) if [ ! -f "$DBFILE" ]; then @@ -94,9 +103,19 @@ mi_proxy_reject=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | gre mi_connects=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep '\/smtpd\[' | grep ': connect from' | wc -l) mi_connects_tls=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep '\/smtpd\[' | grep 'Anonymous TLS connection established from' | wc -l) +# Collect DMARC data +mi_dmarc_pass=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendmarc\[' | grep 'pass$' | wc -l) +mi_dmarc_fail=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendmarc\[' | grep 'fail$' | wc -l) +mi_dmarc_none=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendmarc\[' | grep 'none$' | wc -l) + +# Collect DKIM data +mi_dkim_signed=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendkim\[' | grep 'SSL$\|message has signatures from' | wc -l) +mi_dkim_error=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendkim\[' | grep -v 'SSL$\|message has signatures from' | wc -l) +mo_dkim_signed=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendkim\['| grep 'DKIM-Signature field added' | wc -l) +mo_dkim_unsigned=$(sed -n "$old_log_position","$new_log_position"p $LOGFILE | grep 'opendkim\['| grep 'no signing table match for' | wc -l) # Report counter results -echo "P postfixdetails sent=$mo_sent|deferred=$mo_deferred|deliverable=$mo_deliverable|undeliverable=$mo_undeliverable|bounced=$mo_bncd_total|bounced-spam=$mo_bncd_spam|bounced-reputation=$mo_bncd_reputation|accepted=$mi_accept|proxy-accepted=$mi_proxy_accept|rejected=$mi_reject|proxy-rejected=$mi_proxy_reject|connections=$mi_connects|tls-connections=$mi_connects_tls Additional metrics related to postfix" +echo "P postfixdetails sent=$mo_sent|deferred=$mo_deferred|deliverable=$mo_deliverable|undeliverable=$mo_undeliverable|bounced=$mo_bncd_total|bounced-spam=$mo_bncd_spam|bounced-reputation=$mo_bncd_reputation|accepted=$mi_accept|proxy-accepted=$mi_proxy_accept|rejected=$mi_reject|proxy-rejected=$mi_proxy_reject|connections=$mi_connects|tls-connections=$mi_connects_tls|dmarc-pass=$mi_dmarc_pass|dmarc-fail=$mi_dmarc_fail|dmarc-none=$mi_dmarc_none|dkim-signed-in=$mi_dkim_signed|dkim-error-in=$mi_dkim_error|dkim-signed-out=$mo_dkim_signed|dkim-unsigned-out=$mo_dkim_unsigned Additional metrics related to postfix" # That's it. exit 0