API config/service on services using templates

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 config/service on services using templates

Post by mon-team »

Hello all,
i'm using the config/service API to retrieve information about configured services.
I've noticed that, if a service inherits some properties ( 'check_interval' or 'check_max_attempts' for instance), this properties are not retrieved by the API call. This gets back only what is directly configured into the service (and it's not inherited).
This is a strong limitation.. am i doing some mistakes? Or the API behave in this manner?

Regards
Francesco
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: API config/service on services using templates

Post by tgriep »

Are the API calls you are doing using the Config Reference calls or the Objects Reference calls?

The Object Reference calls should have all of the inherited information in them and should show the 'check_interval' or 'check_max_attempts' in the returned data.

The Config Reference calls show the same data as the Core Config Manager which does not build out the inheritance.
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 config/service on services using templates

Post by mon-team »

Hello,
yes, i was using the Config Reference call...using the Objects Reference call also inherited parameters are recovered.

Just a suggestion: i found documentation very useful and well done, but this was not reported...and i think it's a very important point because could led to really serious and dangerous issue!

Thanks for your support,
Francesco
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: API config/service on services using templates

Post by tgriep »

When using the Objects Reference calls, are you seeing the configuration data you are looking for?

Can you provide more details on what you mean by this?
Just a suggestion: i found documentation very useful and well done, but this was not reported...and i think it's a very important point because could led to really serious and dangerous issue!
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 config/service on services using templates

Post by mon-team »

Hello Tom,
yes, using the Objects Reference call i see the complete configuration, also with parameters inherited from the Service Templates. This probably because information are taken from the nagios database.

Instead, when i use the Config Reference call (this: https://nagios.lan/nagiosxi/api/[b]v1/config/service[/b]), i get back an uncomplete configuration: for instance, if i set the max_check_attempts or the polling frequency only inside a Service Template, and i let the service inherits these parameters, i cannot see these parameters inside the API response.

What i was trying to say is that i consider this difference very important: i'm using the API to automate various tasks on Nagios and integrate it with other tools, if i get back a partial service configuration this could be a problem.

regards
Francesco
mon-team
Posts: 171
Joined: Thu Jun 28, 2012 9:22 am

Re: API config/service on services using templates

Post by mon-team »

By the way,
using the Objects call i can recover all the inherited parameters... but not the name of the Service Templare or Service Groups the service is using.
For instance, this is the configuration of a service using several service Templates and service groups:
{
"recordcount": "1",
"service": {
"@attributes": {
"id": "15394"
},
"instance_id": "1",
"host_name": "localhost",
"service_description": "Current Users",
"is_active": "1",
"config_type": "1",
"display_name": "Current Users",
"check_interval": "5",
"retry_interval": "1",
"max_check_attempts": "2",
"first_notification_delay": "0",
"notification_interval": "1440",
"passive_checks_enabled": "1",
"active_checks_enabled": "1",
"notifications_enabled": "1",
"notes": {

},
"notes_url": {

},
"action_url": {

},
"icon_image": {

},
"icon_image_alt": {

}
}
}


Parameters like check_interval": "5", "retry_interval": "1", "max_check_attempts": 2 are defined inside a Service Template, and i'm glad to be able to recover them... but i cannot see information about ST and SG.
To retrieve the complete configuration i have to do two API call and merge the information.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: API config/service on services using templates

Post by tgriep »

When using the config API call, it is used to retrieve the settings from the Core Config Manager and those configs do not have all in the inheritance's built out so what you are seeing is normal.

If you view the Objects in the CCM, they will display the same data.

Doing multiple API calls to gather the data is the only way to get the data using the config API call.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked