I am using QMail with Plesk 10 on an Apache server.
Occasionally the mail queue stops processing emails - this most recently happenend when an email account got hacked and started sending hundreds of emails.
We did not find out about this until a client of ours contacted to say that their emails were not being recieved, so we checked the mail queue and lo and behold the service had stopped.
In future I would like to be notified when the mailqueue stops.
How can I set something up so the server will run a command whenever the mailqueue stops?
Get a server or systems monitoring tool like Nagios to watch the service. If it stops it can take corrective action or send an email, message, etc.
Monit is a monitoring tools easy to setup, with this tool you should quickly and easily setup (far more than Nagios) a good monitoring for your mail service.
I also came across http://www.splunk.com/ when I was trying to answer this question myself.
It is pretty fully featured and although it does not (appear) to monitor services directly, you can tie it into the output of logs and have it alert when a certain string is provided in the logs.