Did you ever want to check the mail queues on all containers on a single VPS hardware node without having to login to each server to check? If all of the containers are running cPanel on them, then run the following command on the hardware node.
for i in $(vzlist | grep running | awk '{print $1}' ); do vzctl exec $i 'hostname; exim -bpc | grep -v "0"';done
This will execute exim -bpc on all the containers on the node, and return a result like this:
Server1.somedomain.com
2
Server2.somedomain.com
7
Server3.somedomain.com
3
Server4.somedomain.com
13465
So, in this case, server1 has 2 email in their mail queue, server4 has 13465 email in their queue. So it looks like server4 is likely sending out spam, and you need to act on this.
Setting up a cron to run a few times a day and then send the results to you via email would be useful in helping to keep spammers out of the VPS servers. It allows you to quickly eyeball which servers are likely to have spammers on them, and to help track trends.
A simple way to cron this would be like this:
In /root on the hardware node create a script. Call it check_mail_queues.sh
Set the permissions to 755 (rwxr-xr-x) (chmod 755 /root/check_mail_queues.sh)
In this file, but the following 4 lines:
#!/bin/bash
cd /root
for i in $(/usr/sbin/vzlist |grep running| awk '{print $1}'); do /usr/sbin/vzctl exec $i 'hostname; exim -bpc';done > /root/mail_queue_report
mail -s 'Mail Queue report' [email protected] < /root/mail_queue_report
Then setup a cron like this:
0 * * * * /root/check_queues.sh
This will run the script every hour, and send an email to [email protected] with the results.
This is confirmed working on both SolusVM and HyperVM. Both were running OpenVZ on them.