How To: Monitoring e-mail queue on postfix with PRTG

Unfortunately Postfix doesn’t store any statistics on its own so all that data must be collected while processed. You can do this via a script triggered by PRTG.

Collecting data from mail queue

You can monitor the queues with a simple bashscript:

#!/bin/bash
# 20.06.2011 - JJaritsch @ ANEXIA Internetdienstleistungs GmbH
# jj@anexia.at

queuelength=$( /usr/sbin/postqueue -p | tail -n1 | awk '{print $5}' )
queuecount=$( echo $queuelength | grep "[0-9]" )

if [ "$queuecount" == "" ]; then
        echo 0;
else
        echo ${queuelength};
fi
exit 35

Save this script and make it executable (0755 is enough) for the snmpd user. The next step is to add the following line to your snmpd.conf:

exec postqueue /path/to/your/snmp_monitor_postqueue.sh

If you want to use sudo, you can add this line:

exec postqueue /usr/bin/sudo /path/to/your/snmp_monitor_postqueue.sh

In case of sudo you also have to add the following to your sudoers file (so there is no auth required to execute this script):

snmp ALL=(ALL) NOPASSWD: /path/to/your/snmp_monitor_postqueue.sh

Reload your snmpd - you will find the count-result in .1.3.6.1.4.1.2021.8.1.101.* (for example in .1.3.6.1.4.1.2021.8.1.101.1 if you have no other additional lines in the snmpd.conf).


Quelle: https://kb.paessler.com/en/topic/21223-monitoring-e-mail-queue-on-postfix

Mastodon