OpenVZ Forum


Home » General » Support » Setting up a load cap for a container: is this possible?
Re: Setting up a load cap for a container: is this possible? [message #52071 is a reply to message #52070] Fri, 29 May 2015 17:46 Go to previous messageGo to previous message
speedbus is currently offline  speedbus
Messages: 4
Registered: May 2015
Junior Member
fabioganga wrote on Fri, 29 May 2015 16:39
speedbus wrote on Fri, 29 May 2015 14:04
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


Thanks ever so much, you're a star!!!

Will this script apply globally to the entire node?

How often would you recommend it is run by cron job?

Thanks!


>>Thanks ever so much, you're a star!!!
You're welcome Smile

>> Will this script apply globally to the entire node?
Yup, it'll apply to the whole node, each and every VPS on the node.

>> How often would you recommend it is run by cron job?
Run it every 5 minutes
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: yum update fails
Next Topic: How to boot in openVZ kernel while having multiboot OS
Goto Forum:
  


Current Time: Thu May 09 05:19:55 GMT 2024

Total time taken to generate the page: 0.01579 seconds