2013年6月23日星期日

设置openvz高载后自动重启

#!/bin/bash
LOGS="/var/log/openvzRestart.log"
VZIDLOAD=`/usr/sbin/vzlist -o ctid,laverage,ip | grep "/" | awk -F'/' '$2>18{print $1,$2}' | awk '{print $1}'`

#echo $VZIDLOAD > $LOGS
for VZID in $VZIDLOAD
do
usr/sbin/vzctl restart $VZID >/dev/null 2>&1
STOPDATE=`date -d today +"%Y-%m-%d %H:%M"`
echo "$STOPDATE - $VZID has been restarted by causing high load" >> $LOGS
done