check_curl: show when using substring

This commit is contained in:
Cyberes 2023-06-22 13:11:38 -06:00
parent e792c43c09
commit b291fd1a3f
1 changed files with 4 additions and 1 deletions

View File

@ -395,15 +395,18 @@ elif [ $(echo "$RESPONSE_TIME_MS > $WARN_TIME" | bc) -eq 1 ]; then
fi
# Check critical string
BODY_CONTAINS=" "
if [ -n "$CRIT_STRING" ]; then
BODY=$(curl -s $FOLLOW_REDIRECTS $INSECURE $HEADERS $RESOLVE $TIMEOUT $URL)
if ! [[ $BODY =~ "$CRIT_STRING" ]]; then
# if ! echo "$BODY" | grep -q "$CRIT_STRING"; then
echo "CRITICAL - response body does not contain '$CRIT_STRING': $BODY"
exit 2
else
BODY_CONTAINS=" and contained substring "
fi
fi
# All checks passed
echo "OK - response time was $RESPONSE_TIME seconds -> $URL | response_time=${RESPONSE_TIME_MS}ms;$WARN_TIME;$CRIT_TIME;0;;"
echo "OK - response time was $RESPONSE_TIME seconds${BODY_CONTAINS}-> $URL | response_time=${RESPONSE_TIME_MS}ms;$WARN_TIME;$CRIT_TIME;0;;"
exit 0