Page 1 of 1

XI API to Create a service using blank/null values for some

Posted: Fri Sep 25, 2020 2:50 pm
by dh0125e
I am trying to use the XI API to create services that rely upon service templates to provide values for items like max check attempts, notification timesframe and other mandatory values in the API for the service definition.

I've tried not listing the items in the REST call and it's rejected for missing items. I've tried providing the None value as part of the python object definition for the paylog which python is properly interpreting to null, but Nagios refuses to apply the service and puts invalid values in the fields. I've tried just doing '' so they are sent over as blank strings. None of the above work.

How can I get Nagios to allow me to submit empty values for the following and use the values that are inherited from the service template via the use parameter which IS properly relating the new service to an existing service template? This is entirely possible via the UI and is working correctly.

'check_interval': None,
'retry_interval': None,
'max_check_attempts': None,
'check_period': None,
'contacts': None,
'notification_interval': None,
'notification_period': None,

Re: XI API to Create a service using blank/null values for s

Posted: Fri Sep 25, 2020 4:40 pm
by jdunitz
If you add force=1 to the parameters to bypass the verification, it should do what you want.

https://assets.nagios.com/downloads/nag ... gement.pdf

(search for "force=1" in the document, and you'll find it)


--Jeffrey

Re: XI API to Create a service using blank/null values for s

Posted: Mon Sep 28, 2020 7:56 am
by dh0125e
THANK YOU! I did not see a force parameter available on the online version of the help in the XI UI. I will update my python shortly and give this a whirl.

Re: XI API to Create a service using blank/null values for s

Posted: Mon Sep 28, 2020 4:48 pm
by benjaminsmith
THANK YOU! I did not see a force parameter available on the online version of the help in the XI UI. I will update my python shortly and give this a whirl.
Sounds good.

Let us know if you need anything else.