Adding Services to Servicegroups via API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
optionstechnology
Posts: 234
Joined: Thu Nov 17, 2016 11:26 am

Adding Services to Servicegroups via API

Post 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)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Adding Services to Servicegroups via API

Post 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"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
optionstechnology
Posts: 234
Joined: Thu Nov 17, 2016 11:26 am

Re: Adding Services to Servicegroups via API

Post by optionstechnology »

yes, that fixed it
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Adding Services to Servicegroups via API

Post by scottwilkerson »

optionstechnology wrote:yes, that fixed it
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked