Checkout: It stops the VPS once it crosses the maxload (which is 10 in this case), you can change the vzctl stop command to vzctl restart as well
#! /bin/bash
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
maxload="10"; # put here the max loadavg permitted
cat /dev/null > loads.txt;
vzlist -o ctid,laverage > loads.txt;
cat loads.txt | while read line; do
vm=$(echo ${line:0:5});
load=$(echo ${line} | cut -d'/' -f3);
load2=$(echo ${load} | cut -d'.' -f1);
if [ $load2 -gt $maxload ]
then
echo "stopping $vm - $load";
vzctl stop $vm;
echo "$vm - $load" | mail -s "$vm stopped for overload" your@email.com
fi
done