#!/bin/bash # # Plugin to monitor incoming Policy-SPF # # Parameters understood: # # config (required) # autoconf (optional) # #set -o xtrace mktempfile () { mktemp -t } MAIL_LOG=${logfile:-/var/log/mail.info} STATEFILE=/var/lib/munin/plugin-state/spf.offset LOGTAIL=${logtail:-`which logtail`} if [ "$1" = "autoconf" ]; then if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then echo yes exit 0 else echo no exit 1 fi fi if [ "$1" = "config" ]; then echo 'graph_title Sender Policy Freamwork' echo 'graph_order Fail Netural NeturalByDefault None Pass PermError SoftFail TempError' echo 'graph_category mail' echo 'graph_vlabel Count' echo 'graph_scale no' echo 'Fail.label Fail' echo 'Netural.label Netural' echo 'NeturalByDefault.label NeturalByDefault' echo 'None.label None' echo 'Pass.label Pass' echo 'PermError.label PermError' echo 'SoftFail.label SoftFail' echo 'TempError.label TempError' echo 'Fail.draw AREA' echo 'Netural.draw STACK' echo 'NeturalByDefault.draw STACK' echo 'None.draw STACK' echo 'Pass.draw STACK' echo 'PermError.draw STACK' echo 'SoftFail.draw STACK' echo 'TempError.draw STACK' exit 0 fi ARGS=0 `$LOGTAIL /etc/hosts 2>/dev/null >/dev/null` if [ $? = 66 ]; then if [ ! -n "$logtail" ]; then ARGS=1 fi fi TEMP_FILE=`mktempfile munin-spf.XXXXXX` if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ] then if [ $ARGS != 0 ]; then $LOGTAIL ${MAIL_LOG} $STATEFILE | grep 'policy-spf' > ${TEMP_FILE} else $LOGTAIL ${MAIL_LOG} $STATEFILE | grep 'policy-spf' > ${TEMP_FILE} fi #for i in ${KEY}; do # ${i}=`grep 'SPF ${i}' ${TEMP_FILE} | wc -l` #done Fail=`grep 'SPF Fail' ${TEMP_FILE} | wc -l` Netural=`grep 'SPF Netural' ${TEMP_FILE} | wc -l` NeturalByDefault=`grep 'SPF NeturalByDefault' ${TEMP_FILE} | wc -l` None=`grep 'SPF None' ${TEMP_FILE} | wc -l` Pass=`grep 'SPF Pass' ${TEMP_FILE} | wc -l` PermError=`grep 'SPF PermError' ${TEMP_FILE} | wc -l` SoftFail=`grep 'SPF SoftFail' ${TEMP_FILE} | wc -l` TempError=`grep 'SPF TempError' ${TEMP_FILE} | wc -l` /bin/rm -f $TEMP_FILE fi echo "Fail.value ${Fail}" echo "Netural.value ${Netural}" echo "NeturalByDefault.value ${NeturalByDefault}" echo "None.value ${None}" echo "Pass.value ${Pass}" echo "PermError.value ${PermError}" echo "SoftFail.value ${SoftFail}" echo "TempError.value ${TempError}"