Mar
22nd
Mon
22nd
Fugly bash script to monitor remote Web server
I bet this can be done better. If you feel the same way, please feel free to edit the following Gist:
#!/bin/bash
if test -z "$1"; then
echo "Usage: curl.sh hostname"
exit
fi
RESULT=`curl -sI ${1}|head -n 1|awk '{ print $2 }'`
if [ ${RESULT} -eq "200" ]; then
# All is well
exit
else
echo "OH NO SOMETHING IS BROKEN -- curl returned HTTP status ${RESULT} when fetching ${1}"
fi