Pequeno aprimoramento da resposta do pQd:
#!/bin/bash
URL=$1
RESPONSE_CODE=${2:-200}
TIMEOUT=${3:-10}
case $RESPONSE_CODE in
401)
EXPECTED_RETURN_CODE=6
;;
200)
EXPECTED_RETURN_CODE=0
;;
*)
EXPECTED_RETURN_CODE=0
;;
esac
start='date +%s'
wget -t 1 --timeout ${TIMEOUT} -O /dev/null -o /dev/null -e http_proxy=PUTYOURPROXYHERE:8080 ${URL}
WGET_RETURN_CODE=$?
end='date +%s'
PERFDATA="time=$(expr ${end} - ${start})s"
if [ ${WGET_RETURN_CODE} -eq ${EXPECTED_RETURN_CODE} ] ; then
echo "HTTP OK: HTTP/1.1 ${RESPONSE_CODE} OK for ${URL}|${PERFDATA}"
exit 0
else
echo "HTTP CRITICAL: Did not receive HTTP/1.1 ${RESPONSE_CODE} for ${URL}|${PERFDATA}"
exit 2
fi
Altere o servidor proxy e chame-o assim:
$ bash check_http_proxy.sh https://stackoverflow.com/ 200 3
HTTP OK: HTTP/1.1 200 OK for https://stackoverflow.com/|time=1s
or
$ bash check_http_proxy.sh http://www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx 401 10
HTTP OK: HTTP/1.1 401 OK for http://www.httpwatch.com/httpgallery/authentication/authenticatedimage/default.aspx|time=0s