script reboot se houver falha na rede.

crontab

*/5 * * * * /usr/bin/reset_net.sh

vi /usr/bin/reset_net.sh

!/bin/bash

HOSTS=”8.8.8.8″

COUNT=10

for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep ‘received’ | awk -F’,’ ‘{ print $2 }’ | awk ‘{ print $1 }’)
if [ $count -eq 0 ]; then
# 100% failed
echo “Host : $myHost is down (ping failed) at $(date)” >> /var/log/log_controle_net.log
systemctl reboot -i;
else
echo “tudo ok $(date)” >> /var/log/log_controle_net.log
fi
done

Add Comment

Required fields are marked *. Your email address will not be published.