A script to monitor sendmail.... (I'm still using it)
Make sure your /etc/zabbix/zabbix_agentd.conf contains at least the proper hostname
If you have questions, just ask in this thread.
create the items:
/usr/local/sbin/zabbix-sendmail
create a cronjob, preferably with a symbolic link
ln -s /usr/local/sbin/zabbix-sendmail /etc/cron.min/zabbix-sendmail
Make sure your /etc/zabbix/zabbix_agentd.conf contains at least the proper hostname
If you have questions, just ask in this thread.
create the items:
Code:
stat_data_format_error maxfixed stat_localconfigurationerror reject4 reject5 domain stat_sent stat_service_unavailable stat_user_unknown
Code:
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
NAME=`echo "$(basename $(readlink -f $0))" | tr ' +=-' '_' | tr '[A-Z]' '[a-z]' | tr -cd [a-z_]`
OFFSETFILE=/tmp/${NAME}.offset
MAILLOG=/var/log/maillog
if [ -z "`which logtail`" ] ; then
echo "logtail is not installed, install with: apt-get install logtail" >&2
exit 1
fi
sender=`which zabbix_sender` 2>/dev/null
[ -z "${sender}" ] && sender=/usr/bin/zabbix_sender
if [ ! -x "${sender}" ] ; then
echo "zabbix_sender is not installed, install with: apt-get install zabbix-sender" >&2
exit 1
fi
ZABBIX_CONF=/etc/zabbix/zabbix_agentd.conf
DEBUG=0
function zsend {
key="$2"
[ -z "$key" ] && key="`echo "$1" | sed 's/^ *//' | tr ' +=-' '_' | tr '[A-Z]' '[a-z]' | tr -cd [a-z_]`"
value=`grep -c "$1" ${LOGSNIPPET}`
if [ ${DEBUG} -eq 0 ] ; then
${sender} -c $ZABBIX_CONF -k "${key}" -o "${value}" 2>&1 >/dev/null
else
echo "Send key \"${key}\" with value \"${value}\"" >&2
${sender} -c $ZABBIX_CONF -vv -k "${key}" -o "${value}"
fi
}
LOGSNIPPET=`mktemp`
LOG=/var/log/maillog
logtail -f ${LOG} -o ${OFFSETFILE} >${LOGSNIPPET}
zsend ' stat=Data format error'
zsend ' stat=Deferred'
zsend ' stat=Host unknown'
zsend ' stat=Local.configuration.error'
zsend ' stat=maillog Message exceeds maximum fixed size' "maxfixed"
zsend ' stat=Sent'
zsend ' stat=Service unavailable'
zsend ' stat=User unknown'
zsend ' Domain of sender address .* does not exist' 'domain'
zsend ' reject=4' 'reject4'
zsend ' reject=5' 'reject5'
rm -f ${LOGSNIPPET}
ln -s /usr/local/sbin/zabbix-sendmail /etc/cron.min/zabbix-sendmail

Comment