TT#46784 Check several servers to get network status

In some cases ICMP is blocked on a gateway.
To get connectivity status (if the server is online) ping several
servers:
1) gateway
2) deb.sipwise.com
3) dns server or 1.1.1.1

Based on the pull request
https://github.com/sipwise/deployment-iso/pull/1/

Thanks: Isaac McDonald for the PR.

Change-Id: Iebb31de8105e3b329bd0b8fc068abc9b55326ed8
changes/83/24583/4
Mykola Malkov 8 years ago
parent 2084d1d6c8
commit f7db085697

@ -15,8 +15,12 @@ EXIT_CODE=1
GW="$(route -n | awk '/^0\.0\.0\.0/{print $2}')"
GWDEV="$(route -n | awk '/^0\.0\.0\.0/{print $NF}')"
SIPWISE_DEB='deb.sipwise.com'
DNS_SERVER="$( awk '/^nameserver/ {print $2; exit}' /etc/resolv.conf || true )"
if ping -c 3 "${GW}" >/dev/null ; then
if ping -c 3 "${GW}" >/dev/null \
|| ping -c 3 "${SIPWISE_DEB}" >/dev/null \
|| ping -c 3 "${DNS_SERVER:-1.1.1.1}" >/dev/null ; then
STATUS="Online (${GWDEV})"
EXIT_CODE=0
fi

Loading…
Cancel
Save