Quantcast
Channel: Script to test staging server statuses - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by DopeGhoti for Script to test staging server statuses

$
0
0

It's probably better to test a specific service rather than to use an ICMP ping request. Presuming you accept this advice, here is an example that will test the secure shell daemon:

hostlist=(host1.example.com host2.example.com)
for host in "${hostlist[@]}"; do
    if nc -w 2 -z $host 22; then
        echo "INFO: ssh on $host responding"
    else
        echo "ERROR: ssh on $host not responding"
    fi
done

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>