Is it possible to monitor Postfix e-mail queue on an e-mail server running Ubuntu 8.04 LTS? I would like notification when the queue is 250 e-mails


You can monitor the queues with a simple bash script:

#!/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).


Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.