Restart the server if yahoo.com cannot be pinged
#!/bin/bash
ping -c 5 yahoo.com > /dev/null || (echo `date` >> /root/test/log; iptbables -L -xn >> /root/test/log; traceroute 4.2.2.4 >> /root/test/log; free -m >> /root/test/log; ps auxwf >> /root/test/log; reboot )
This is another basic bash script which restarts the whole server if yahoo.com cannot be pinged. Before that it logs a bunch of things in /root/test/log, possibly useful for debugging later.
You can try setting it as a cron provided the cron daemon will work at the time yahoo.com cannot be pinged