>From: [email protected] [mailto:[email protected]]
>On Behalf Of Kaleb Hosie
>Sent: 16 October 2012 13:50
>To: [email protected]
>Subject: Alert of unusually large queue
>
>We host a mail server which runs Postfix and there has been a few times where
>one of our clients computers becomes infected with malware and the password is
>compromised.
>
>How this has come to my attention is because every once in a while, I will
>login to the mail server and see an unusually large mail queue which is all
>being sent to one domain.
>
>Is it possible to monitor the queue automatically and have it send me an alert
>if the postfix queue reaches over a certain threshold?
>
>Thanks everyone
I use the following to do just that. I'm sure there is a better way but I
fudged this together myself
Script 1:
#!/bin/bash
/usr/bin/mailq | /usr/bin/tail -n1 | /usr/bin/gawk '{print $5}' >
/etc/postfix/mailq_count
Script 2:
#!/bin/bash
mailq_count="/bin/cat /etc/postfix/mailq_count"
if [ `$mailq_count` -gt 50 ]; then echo "Mail count on Server is"
`$mailq_count`|/usr/sbin/sendmail -f [email protected] [email protected] ; fi
These run as cron jobs every few minutes.
Hope that helps.
Kind regards,
James Day
(IT Engineer)