API on service update

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

API on service update

Post by mon-team »

Dear all,
i'm using the Nagios XI API on a Nagios XI 5.5.1.
I'm focusing on services creation and update: i've noticed that using the "config/service" endpoint i cannot specify an optional Service Template.
I've workarounded this limitation using the raw import ("config/import").

However now i've a problem: if i want to change the service's Service Template i can't do it: the "config/import" doesn't allow me to update this field, and if i use the raw import Nagios creates a second services (with the service template updated).

What would you suggest?
Why the ""config/service" endpoint doesn't allow to specify such a fundamental object like the service template?
Do you know if, in the future releases, this will be allowed?

Regards
Francesco
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: API on service update

Post by mbellerue »

You can use the PUT commands to update parameters using the API. For example,

Code: Select all

curl -XPUT "http://<MyXIAddress>/nagiosxi/api/v1/config/service/localhost/PING?apikey=<MyAPIKey>&pretty=1&use=<NewServiceTemplate>&display_name=PINGTEST&applyconfig=1""
The name use doesn't make a lot of sense from a pure API standpoint. But the reason that parameter is named that way is because use is the field in the configuration files to define templates, for hosts and services.

You can also specify use when creating your services and hosts with POST.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

Re: API on service update

Post by mon-team »

Thanks for the reply,
you are right.. i read again the 'Help' section about API, and it's written exactly this...even if in a very small font :(

All normal service directives are able to be used like normal core config definition files.

I'm now able to create services with a service template!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API on service update

Post by scottwilkerson »

mon-team wrote:Thanks for the reply,
you are right.. i read again the 'Help' section about API, and it's written exactly this...even if in a very small font :(

All normal service directives are able to be used like normal core config definition files.

I'm now able to create services with a service template!
Great!

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