-
Notifications
You must be signed in to change notification settings - Fork 0
nagaevkirill edited this page Apr 3, 2025
·
2 revisions
sudo apt update sudo apt install ufw -y sudo apt install softether-vpnserver -y systemctl status softether-vpnserver ufw allow ssh ufw allow https ufw allow 500/udp ufw allow 4500/udp ufw enable reboot
crontab -e # min hour dom month dow command 0 4 * * * /sbin/shutdown -r now
touch /home/cpu_check.sh chmod +x /home/cpu_check.sh crontab -e * * * * * /home/cpu_check.sh >> /var/log/cpu_check.log 2>&1 nano /home/cpu_check.sh
script
#!/bin/bash
# Установим порог для загрузки CPU (95%)
THRESHOLD=95
# Получаем среднюю загрузку за последнюю минуту
CPU_LOAD=$(uptime | awk '{ print $(NF-2) }' | sed 's/,//')
# Преобразуем в целое число
CPU_LOAD_INT=$(echo "$CPU_LOAD * 100" | bc | awk '{print int($1)}')
# Проверяем, превышает ли загрузка порог
if [ "$CPU_LOAD_INT" -gt $THRESHOLD ]; then
echo "CPU Load ($CPU_LOAD%) exceeded threshold ($THRESHOLD%). Restarting softether-vpnserver."
sudo systemctl restart softether-vpnserver
fi