Page 1 of 1

add servicegroup to service when creating service via rest

Posted: Fri Nov 09, 2018 9:57 am
by lukesullivan
I'm using the python requests package to post url calls to nagiosxi to create services. I would like to add the service to an existing service group when I create it. I cant figure out the parameter I need to specify in order to add a service to a servicegroup. Is that something I should be able to do when creating the service?

example code is:

payload = {'host_name' : devname,
'service_description': 'cisco stack status',
'service_groups' : 'cisco stack status',
'use' : 'cisco_stack',
'force' : 1
}

r = requests.post('https://' + nagioshost + '/nagiosxi/api/v1/config/service?apikey=' + nagiosapikey + '&pretty=1
&applyconfig', data=payload, verify=verify)

I've tried:

'service_groups' : 'cisco stack status',
'service_group' : 'cisco stack status',
'servicegroup' : 'cisco stack status',

the service group does exist:

{
"@attributes": {
"id": "36183"
},
"instance_id": "1",
"servicegroup_name": "cisco stack status",
"is_active": "1",
"config_type": "1",
"alias": "cisco stack status"
},

Re: add servicegroup to service when creating service via re

Posted: Fri Nov 09, 2018 12:53 pm
by ssax
It's servicegroups, you can use the object definitions page to look them up:

https://assets.nagios.com/downloads/nag ... ml#service