Hi all! I wanted to share a little script I wrote for monitoring the length of an Exim mail queue on a Linux-based server using PRTG:
Step 1 Create a new bash script (named "exim.sh") containing the following:
#!/bin/bash echo "[`/usr/sbin/exim -bpc`]" > "/public_html/eximqueue.txt"
This simple script queries the current number of messages in the Exim mail queue (exim -bpc), and writes this number to a text file on your web server - in the above example, "/public_html/eximqueue.txt" (Change this location to suite your particular server, but make sure it's a location that's accessible via your web browser)
Step 2 Save/Upload your exim.sh file to your server (i.e. to /var/prtg/scripts) and make sure its executable (CHMOD 755)
Step 3 Create a scheduled task (CRON job) to execute the .sh script at a recurring interval:
29,59 * * * * /var/prtg/scripts/exim.sh
Adding the above line to /var/spool/cron/root will execute the exim.sh script at 29 and 59 minutes past the hour (i.e. every 30 mins) - you can adjust the interval based on how much Exim activity you expect on your server.
Step 4 In your PRTG installation, create a new HTTP Content Sensor named "Exim Queue" with the following settings:
- Make the "Script URL" the corresponding URL to the path you specified in the bash script in Step 1 - i.e http://yourdomain/eximqueue.txt
- Set "Value Type" to Integer
- Set "Number of Channels" to 1
- Set the "Scanning Interval" to be the same as the interval you specified in your CRON job in Step 3 (there's no point in scanning at a shorter interval than the CRON job on your server is set to run)
- Once the sensor has been created, you may wish to name the single channel "Queue Length" (or similar)
That's it! - You can now monitor the current status of your server's Exim queue in PRTG!