#!/bin/bash
# This script checks the load average for the vps and reboot it if any of the vps load average goes higher than 7 load=`/usr/sbin/vzlist -o veid,laverage | /bin/sort -nrk 2 | awk '{ print $2 }' | cut -d / -f 1 | /usr/bin/head -1 | awk '{ print $1 }' | cut -d . -f 1` if [ "$load" -gt "7" ] then line=`/usr/sbin/vzlist -o veid,laverage | /bin/sort -nrk 2 | /usr/bin/head -1 | awk '{ print $1 }'` /usr/sbin/vzctl restart $line 2>/dev/null 1>&2 mail -s "The VPS $line has been rebooted due to the high load on the server $HOSTNAME" alert@domain.com fi
This article is very inspired me I have a hope everyone will find useful information here if you want to more details then go throw the link openvz vps
ReplyDelete