How to check when connection to server is down.

Posted on 28 lutego 2014

Sometimes small scripts can help with describing a problem.

I had issues with connection to one of my servers and I had it only from time to time for a short moments.

while true
  if ! ping -c 1 -i 5 "$1" &>/dev/null ; then 
    echo "Server '$1' is down"
    echo $(date +'%F %H:%M:%S')
    mtr --report "$1"
  sleep 5

This small script told me when my server was going down and I could show my ISP what is going wrong.