check_curl

This commit is contained in:
Cyberes 2023-04-21 23:54:19 -06:00
parent ecfa98e531
commit cb12e17261
1 changed files with 39 additions and 4 deletions

View File

@ -86,10 +86,45 @@ fi
RESPONSE=$(curl --output "$TMP_RESPONSE" -w "%{http_code}\n%{time_total}" $(echo "${HEADER_ARGS[@]}" | tr -s ' ') $FOLLOW_REDIRECTS $INSECURE $RESOLVE $URL 2>"$TMP_ERROR_LOG")
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "CRITICAL: curl failed!"
echo "Error log:"
cat "$TMP_ERROR_LOG"
status=$?
if [ $status -ne 0 ]; then
case $status in
1)
msg="CRITICAL: Unsupported protocol"
;;
3)
msg="CRITICAL: Malformed URL"
;;
# 5)
# msg="CRITICAL: Couldn't resolve proxy $proxy"
# ;;
6)
msg="CRITICAL: Couldn't resolve host"
;;
# 7)
# msg="CRITICAL: Couldn't connect to proxy $proxy"
# ;;
22)
msg="CRITICAL: Server returned http code >= 400"
;;
52)
msg="CRITICAL: Server returned empty response (52)"
;;
56)
msg="CRITICAL: Failure recieving network data (56)"
;;
60)
msg="CRITICAL: SSL/TLS connection problem (60)"
;;
*)
echo "UNKNOWN: $status - $URL"
exit 3
;;
esac
echo -e "$msg"
# echo "Error log:"
# cat "$TMP_ERROR_LOG"
rm -rf "$TMP_ERROR_LOG"
exit 2
fi