Last active
October 14, 2019 20:40
-
-
Save xyntrix/f53f1e5beabf453038a9cd387516adc1 to your computer and use it in GitHub Desktop.
cli http/https status checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## How many seconds to wait for poll | |
POLLTIME=10 | |
## How many seconds to wait between polls | |
SLEEPTIME=3 | |
## Ignore invalid tls negotiation such as invalid/expired certs | |
INSECURE="-k" | |
if [ -z "${1}" ]; then | |
URL="https://www.google.com" | |
else | |
URL="${1}" | |
fi | |
CURLCMD="curl -m ${POLLTIME} ${INSECURE} -s -o /dev/null -w "%{http_code},%{redirect_url}" ${URL}" | |
while [ 1 ]; do | |
echo "## $(date -u), checking: ${URL}" | |
HTTPCODE=$(${CURLCMD}) | |
echo "ts: $(date -u +%s), http_code: ${HTTPCODE}" | |
case "${HTTPCODE}" in | |
200*) | |
echo "## $(date -u), online: ${URL}" | |
break | |
;; | |
301*) | |
echo "## $(date -u), online(redirect): ${URL}" | |
break | |
;; | |
esac | |
echo "##" | |
sleep ${SLEEPTIME} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
give execute perms and drop in your path somewhere.. usage: is_it_up https://something.ltd.. bails if 200/301