Skip to content
Snippets Groups Projects

update jq filtering

Merged Hahn Axel (hahn) requested to merge add-systemdunit into master
1 file
+ 9
3
Compare changes
  • Side-by-side
  • Inline
+ 9
3
@@ -135,14 +135,20 @@ else
@@ -135,14 +135,20 @@ else
_header=$(echo "$out" | sed -n "1,${iHeaderEnd}p")
_header=$(echo "$out" | sed -n "1,${iHeaderEnd}p")
_body=$( echo "$out" | sed -n "${iHeaderEnd},\$p")
_body=$( echo "$out" | sed -n "${iHeaderEnd},\$p")
 
# --- jq filter
if [ -n "$sJq" ]; then
if [ -n "$sJq" ]; then
_body=$( jq "$sJq" <<< "$_body" 2>/dev/null )
_body=$( jq "$sJq" <<< "$_body" 2>/dev/null )
if [ -z "$_body" ]; then
if [ -z "$_body" ]; then
ph.setStatus critical
ph.setStatus critical
sProblems+="- jq filter [$sJq] was applied and resulted in an empty result.\n"
sProblems+="- jq filter [$sJq] was applied and resulted in an empty result. The reponse from url was no JSON.\n"
else
else
sInfos+="- jq filter [$sJq] was applied.\n"
if [ "$_body" = "null" ]; then
sInfos+="${_body}"
ph.setStatus critical
 
sProblems+="- jq filter [$sJq] does not match on responded JSON.\n"
 
else
 
sOK+="- jq filter [$sJq] matches.\n"
 
sInfos+="Content aufter jq filter: ${_body}"
 
fi
fi
fi
fi
fi
Loading