What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

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

Your Vote:

Up

Down

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 by  paddingtonpd (0) 1



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

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 by  Juergen Jaritsch (50) 1



7 Replies

Votes:

0

Your Vote:

Up

Down

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] (10,984) 3 5



Accepted Answer

Votes:

0

Your Vote:

Up

Down

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 by  Juergen Jaritsch (50) 1



Votes:

0

Your Vote:

Up

Down

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

Created on Jan 25, 2013 7:30:00 AM by  Babul Mukherjee (0) 1



Votes:

0

Your Vote:

Up

Down

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 by  Mishlen (0) 1



Votes:

0

Your Vote:

Up

Down

sorry, all right

Created on Feb 19, 2015 10:49:51 AM by  Mishlen (0) 1



Votes:

0

Your Vote:

Up

Down

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 by  meyerj (0)



Votes:

0

Your Vote:

Up

Down

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 by  deelowndes (0)



Please log in or register to enter your reply.


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.