diff --git a/check_http b/check_http index 4888bbbd1ef215436cf7031b885594a6db439ae3..dbd64b1117ab02fe5bb796fed4ef3b026b024ebf 100755 --- a/check_http +++ b/check_http @@ -115,6 +115,7 @@ sLabel=$( ph.getValueWithParam "" l "$@") curlParams+=" -si -X $sMethod --connect-timeout 10" sProblems= +sInfos= sOK= if [ -z "$sUrl" ]; then @@ -136,6 +137,13 @@ else if [ -n "$sJq" ]; then _body=$( jq "$sJq" <<< "$_body" 2>/dev/null ) + if [ -z "$_body" ]; then + ph.setStatus critical + sProblems+="- jq filter [$sJq] was applied and resulted in an empty result.\n" + else + sInfos+="- jq filter [$sJq] was applied.\n" + sInfos+="${_body}" + fi fi # --- test status @@ -205,6 +213,7 @@ fi # --- output test -n "$sProblems" && sProblems="Problems:\n$sProblems\n" test -n "$sOK" && sOK="Found:\n$sOK" +test -n "$sInfos" && sInfos="\nHints:\n$sInfos" test -n "$sLabel" && ( ph.status "$sLabel" @@ -213,7 +222,7 @@ test -n "$sLabel" && ( test -n "$sLabel" || ph.status "$sMethod $sUrl ($iHttpStatus)" echo -echo -e "${sProblems}${sOK}" +echo -e "${sProblems}${sOK}${sInfos}" test -n "${sProblems}" && (echo "RESPONSE HEADER:"; echo; echo "$_header")