June 22, 2018

BASH :: check the Postfix mail queues for Nagios

(Last Updated On: 16th September 2016)

Here is a tiny bash script that will check your Postfix mail queue and exit the code dependant on the result.  Often mail relays sit in the background not really ever breaking and therefore never being monitored.  I wrote this little check so the IT team would be the first to know if mail started backing up.

It can be added into your nrpe.cfg file if you are using nrpe as a monitoring agent by adding a line such as:

command[check_MxQ]=/filePath/fileName

#!/bin/bash
Result=$(postqueue -p | grep "Mail queue is empty");
if [[ ! $Result ]];
then echo "Mail in the Queue!";exit 1;
else echo "No Mail in the Queue!"; exit 0;
fi;

Previous «
Next »

Simon is a sysadmin for Local Government in North Yorkshire with a real passion for security and coding.

1 Comment

  1. Pingback: PowerShell :: check the Exchange 2010 queues for Nagios – Synack

Leave a Reply

Subscribe to SYNACK via Email

%d bloggers like this: