Today I combined some of my Reactor scripts, so that I can call an event chain with a host or with a hostgroup. The script detects if the target parameter is a host or a hostgroup and will then perform soem actions on the host or the hostgroup members.
To query the hostgroup members I was using the backend api in the past. As I really like the json way of doing things, and as I need json anyway to check if the hostgroup exists, I would like to transfrom the part of my scripts that query the hostgroup members from using the backend api component to json.
I seem to experience some issue though.
When I execute this query in a browser, I get a result:
Code: Select all
http://<nagiosserver>/nagios/cgi-bin/objectjson.cgi?query=hostgroup&hostgroup=hg_naf_reactor_win_autoupdate_prio5When I do this query in Bash however I get a result with message
"message": "Hostgroup information requested, but no hostgroup name specified."
Other queries do work in Bash, for example
Code: Select all
HostList=$(curl -s $NagReadOnlyUser:$NagReadOnlyPw@$NagiosXiServer/nagios/cgi-bin/objectjson.cgi?query=hostlist)Code: Select all
HostMemberList=$(curl -s $NagReadOnlyUser:$NagReadOnlyPw@$NagiosXiServer/nagios/cgi-bin/objectjson.cgi?query=hostgroup&hostgroup=$Target)Willem