I believe the -o i option is now global to all currently selectable options
This commit is contained in:
@@ -234,8 +234,22 @@ if [ -n "$mySave" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Helper functions for creating our jqString
|
||||
# First, we need to know if our tests should be case-sensitive or not
|
||||
jq_check_case() {
|
||||
thing="$*"
|
||||
if [ -n "$thing" ]; then
|
||||
val=" | test(\"$thing\""
|
||||
[[ "$cmdOptions" =~ "i," ]] && val+="; \"i\""
|
||||
echo "$val)"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Do we need to add host limits to the query?
|
||||
jq_add_host() {
|
||||
[ -n "$myHost" ] && jqString="$jqString | select(.host_name | test(\"$myHost\"))"
|
||||
[ -n "$myHost" ] && jqString="$jqString | select(.host_name $(jq_check_case $myHost))"
|
||||
}
|
||||
|
||||
# Otherwise, let's parse the JSON data here
|
||||
@@ -245,8 +259,8 @@ jqString=${APIinfo[$myAPI/$myAPIep]}
|
||||
case "$myAPIep" in
|
||||
servicestatus)
|
||||
jq_add_host
|
||||
[ -n "$myService" ] && jqString="$jqString | select(.service_description | test(\"$myService\"))"
|
||||
[ -n "$myCommand" ] && jqString="$jqString | select(.check_command | test(\"$myCommand\"))"
|
||||
[ -n "$myService" ] && jqString="$jqString | select(.service_description $(jq_check_case $myService))"
|
||||
[ -n "$myCommand" ] && jqString="$jqString | select(.check_command $(jq_check_case $mycommand))"
|
||||
[ -n "$myHG" ] && jqString="$jqString | select(.hostgroup_name==\"$myHG\")"
|
||||
[ -n "$mySG" ] && jqString="$jqString | select(.servicegroup_name==\"$mySG\")"
|
||||
;;
|
||||
@@ -259,22 +273,22 @@ case "$myAPIep" in
|
||||
;;
|
||||
service)
|
||||
jq_add_host
|
||||
[ -n "$myService" ] && jqString="$jqString | select(.service_description | test(\"$myService\"))"
|
||||
[ -n "$myConfigName" ] && jqString="$jqString | select(.check_command | test(\"$myConfigName\"))"
|
||||
[ -n "$myCommand" ] && jqString="$jqString | select(.check_command | test(\"$myCommand\"))"
|
||||
[ -n "$myService" ] && jqString="$jqString | select(.service_description $(jq_check_case $myService))"
|
||||
[ -n "$myConfigName" ] && jqString="$jqString | select(.check_command $(jq_check_case $myConfigName))"
|
||||
[ -n "$myCommand" ] && jqString="$jqString | select(.check_command $(jq_check_case $myCommand))"
|
||||
;;
|
||||
hostgroupmembers)
|
||||
jq_add_host
|
||||
[ -n "$myHG" ] && jqString="$jqString | select(.hostgroup_name | test(\"$myHG\"))"
|
||||
[ -n "$myHG" ] && jqString="$jqString | select(.hostgroup_name $(jq_check_case $myHG))"
|
||||
[[ $cmdOptions =~ "h," ]] && jqString="$jqString | .members[] | .[] | .host_name"
|
||||
[[ $cmdOptions =~ "o," ]] && jqString="$jqString | .members[] | .[] | .host_object_id"
|
||||
;;
|
||||
servicegroup)
|
||||
jq_add_host
|
||||
[ -n "$mySG" ] && jqString="$jqString | select(.servicegroup_name==\"$mySG\")"
|
||||
[ -n "$mySG" ] && jqString="$jqString | select(.servicegroup_name $(jq_check_case $mySG))"
|
||||
;;
|
||||
contactgroup)
|
||||
[ -n "$myCG" ] && jqString="$jqString | select(.contactgroup_name==\"$myCG\")"
|
||||
[ -n "$myCG" ] && jqString="$jqString | select(.contactgroup_name $(jq_check_case $myCG))"
|
||||
;;
|
||||
esac
|
||||
[ -n "$myFields" ] && jqString="$jqString | $myFields"
|
||||
|
||||
Reference in New Issue
Block a user