Tag Archives: coding

Postfix Mail Queue statistics via SNMP

This post documents a small shell script designed to provide basic mail queue statistics via SNMP for Postfix.



The code can be downloaded here.

To install, place the script anywhere in your system and edit it to provide the correct path to the “qshape” perl script that comes with Postfix.

Note: Under openSUSE qshape.pl is part of the postfix-docs package and is not installed by default.

To configure net-snmp, edit your snmpd.conf line and add a line as follows:

pass [oid-of-choice] /bin/snmpqshape.sh [oid-of-choice]

For example, due to a quirk in a paticular SNMP monitoring package I use, I had to use an OID belonging to Motorola:

pass . /bin/snmpqshape.sh .

Net-SNMP will return 3 OIDs on query:

.0 :: Incoming
.1 :: Active
.2 :: Deferred


Since the setup of monitoring / statistics tools such as MRTG or RRDTool is site-specific, no provisions are made on this page to provide a complete usage example. A minimal example for RRDTool:
#! /bin/sh
STR="`snmpwalk -OvQ -r 10 -t 5 -v 2c -c publicommunity hostname.site.com \
. | perl -ne 's/^/:/;s/\n//;print'`"
rrdtool update /path/to/rr-database.rrd -t incoming:active:deferred N${STR}

This code is free to use and distribute, and the author offers no liability or warranty for it’s misuse.