Page 1 of 1

Adding Services to Servicegroups via API

Posted: Fri Oct 25, 2019 5:19 am
by optionstechnology
I am trying to created services and automatically make them members of service groups using the API

This is the command I use-

Code: Select all

curl -XPOST -s "https://$NAGSERVER/nagiosxi/api/v1/config/service?apikey=$NAGAPI&pretty=1" -d "host_name=$HOST&service_description=$SERVICEDESC&servicegroup_name=$SERVICEGROUP&check_command=check_dummy\!0\!\"\"&use=$TEMPLATE&force=1"
It succeeds in adding the service, but it doesn't add it to the service group

(v.5.5.4)

Re: Adding Services to Servicegroups via API

Posted: Fri Oct 25, 2019 8:20 am
by scottwilkerson
I believe what you need is this

Code: Select all

curl -XPOST -s "https://$NAGSERVER/nagiosxi/api/v1/config/service?apikey=$NAGAPI&pretty=1" -d "host_name=$HOST&service_description=$SERVICEDESC&servicegroups=$SERVICEGROUP&check_command=check_dummy\!0\!\"\"&use=$TEMPLATE&force=1"

Re: Adding Services to Servicegroups via API

Posted: Mon Dec 16, 2019 5:21 am
by optionstechnology
yes, that fixed it

Re: Adding Services to Servicegroups via API

Posted: Mon Dec 16, 2019 8:24 am
by scottwilkerson
optionstechnology wrote:yes, that fixed it
Great!

Locking thread