Skip to content

Instantly share code, notes, and snippets.

@benzado
Created April 15, 2015 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benzado/49fe708734e42b2be9a9 to your computer and use it in GitHub Desktop.
Save benzado/49fe708734e42b2be9a9 to your computer and use it in GitHub Desktop.
httping.sh
#!/bin/bash
# "ping" a server by making a HTTP request once every 1-2 seconds. It waits
# for the server to stop responding, then prints the current time, then waits
# for the server to respond again, then prints the time and quits.
# I wrote this to measure downtime during a reboot against a server that did
# could not respond to ICMP (ping) messages.
URL=$1
CURL_OPTS="--silent --max-time 1 --output /dev/null --fail --head"
echo "Up"
while curl $CURL_OPTS $URL; do
echo -n .
sleep 1
done
echo "Down!"
date
while ! curl $CURL_OPTS $URL; do
echo -n .
sleep 1
done
echo "Back Up!"
date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment