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 #52070 is a reply to message #52069] Fri, 29 May 2015 16:39 Go to previous messageGo to previous message
fabioganga is currently offline  fabioganga
Messages: 3
Registered: May 2015
Location: Tenerife
Junior Member
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!
 
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: Wed Sep 04 03:36:28 GMT 2024

Total time taken to generate the page: 0.05134 seconds