What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Monitoring e-mail queue on postfix

Votes:

0

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

postfix prtg snmp

Created on Jun 13, 2011 6:52:58 AM



Best Answer

Accepted Answer

Votes:

0

You can monitor the queues with a simple bashscript:

#!/bin/bash
# 20.06.2011 - JJaritsch @ ANEXIA Internetdienstleistungs GmbH
# [email protected]

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).

Created on Sep 16, 2011 8:40:29 AM



7 Replies

Votes:

0

There is not built-in function of PRTG to do this. It may be possible to create a custom sensor using some programming language and this information, but this will not come too soon from Paessler: http://stackoverflow.com/questions/226699/how-to-monitor-postfix-mta-status

Created on Jun 14, 2011 7:52:55 AM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6



Accepted Answer

Votes:

0

You can monitor the queues with a simple bashscript:

#!/bin/bash
# 20.06.2011 - JJaritsch @ ANEXIA Internetdienstleistungs GmbH
# [email protected]

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).

Created on Sep 16, 2011 8:40:29 AM



Votes:

0

Juergen - your solution works perfectly! Thanks so much for the writeup.

Created on Jan 25, 2013 7:30:00 AM



Votes:

0

Juergen, Thank you for your script! But after adding the sensor "SNMP Custom" I have error "No such instance (SNMP error # 223)".

But when tested in the SNMP Tester are no problems!!! The number of messages in the queue is displayed correctly. How to be in this case? Thank U.

Created on Feb 18, 2015 8:21:47 AM



Votes:

0

sorry, all right

Created on Feb 19, 2015 10:49:51 AM



Votes:

0

Thanks for the script. It works fine.

After update to Ubuntu version 18.04 sudo did not work to start the script. exec postqueue /usr/bin/sudo /path/to/your/snmp_monitor_postqueue.sh Error: no tty present and no askpass program specified

My solution: exec postqueue /path/to/your/snmp_monitor_postqueue.sh

Created on Sep 21, 2018 6:14:18 AM



Votes:

0

This appears to require SELinux to be disabled/permissive to work.

Without sudo you get postqueue: fatal: open /etc/postfix/main.cf: Permission denied

With sudo you get sudo: PAM account management error: System error

Using sudo and with SELinux disabled/permissive gets around the issue but does anyone have a solution that keeps SELinux in play?

Created on Apr 9, 2021 7:07:59 AM




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.