API issues in 5.8

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jvaira
Posts: 59
Joined: Tue Dec 22, 2015 7:40 pm

API issues in 5.8

Post by jvaira »

Hello,
We are running into some issues with API changes that were made in 5.8 and hoping to get some clarity on why these changes were made. The first change is the following one that is listed under the change log page. Fixed API endpoints config/host and config/service to make host_name and config_name values case sensitive -JO. In our custom built client portal we have been pulling data from Nagios via the API for quite a while but the hostnames in this portal do not match the hostnames in Nagios as far as case sensitivity is concerned. The second issue we are running into is that some of the API fields that we were using were either removed or renamed. A couple examples of this would be the name field that seems to have been removed and the service_id field which was changed to service_object_id.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: API issues in 5.8

Post by benjaminsmith »

Hi jvaira,

There was an issue with the case sensitivity on host_name and config_name where some API calls were case sensitive and others were not, and that was corrected in 5.8.

Regarding, the other issue the object id, can you let me know what exact endpoint you are calling? Also what version did you upgrade from and I'll look into this and get some clarification for you.

Regards,
Benjamin
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!
jvaira
Posts: 59
Joined: Tue Dec 22, 2015 7:40 pm

Re: API issues in 5.8

Post by jvaira »

Hello Ben,
When you say that the case sensitivity issue was corrected do you mean that all API's are now case sensitive or that they should all be non case sensitive? As for the object id issue the endpoint we are calling is objects/servicestatus. We have a couple instances on version 5.6.12 where the issue is not occurring and then one instance where it occurred on both 5.7.4 and 5.8.1. We also noticed that the field names changed within API documentation for 5.6.12 vs 5.8.1 ( screen shots attached )
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: API issues in 5.8

Post by benjaminsmith »

Hi,

The case the sensitive change was for the host_name ad config_name values, from the 5.8.0 changelog.
Fixed API endpoints config/host and config/service to make host_name and config_name values case sensitive -JO
The other issue you are seeing was related to a backend change to convert directly to JSON for consistent structure in
5.7.
Updated objects API to no longer convert XML to JSON for more consistent output and always returns the same structure at any result size [TPS#14740] -JO
Is it possible for you to bring up the older systems, so all the servers on the same version?

Reference:
Nagios XI Changelog

Best Regards,
Benjamin
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!
jvaira
Posts: 59
Joined: Tue Dec 22, 2015 7:40 pm

Re: API issues in 5.8

Post by jvaira »

Ben,
We can work around the case sensitivity issue because all of the hostnames in our client portal are uppercase so we will just need to go through each Nagios instance and change host names to match. What is going to be difficult is working with the changed property names. This is going to require a code change within our client portal which cannot be done until all of our Nagios instances are on the same version. Due to our QA process we cannot simply update all of them at the same time and then flip the code on the client portal so there will be a significant amount of time where data will be available for some clients and not for others. Our development team is still confused about why property names needed to be changed in order to convert XML to JSON. I am also being told that when getting graph data the legend is no longer returning any data ( example below ). Can we please get more detailed information on why the property names were changed and if we are missing something with the legend. Thank you

Getting graph data, 5.6.12 returns this:
"legend": {​​​​​​​
"entry": "5 min avg Load"
}​​​​​​​

Version 5.8.1 returns this
"legend": {​​​​​​​
"entry": {​​​​​​​}​​​​​​​
}​​​​​​​
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API issues in 5.8

Post by ssax »

The rrdexport endpoint should work the same, I do not see any difference on mine. You are referring to the rrdexport endpoint, correct? Please send the full query you are using so I can test mine with those settings.

Development changed the way they were outputting it in XI 5.7 and they changed some things, here is what they said:
service_object_id and host_object_id is generally the proper one, they are what are in the db as well, prior, the XML had changed those for whatever reason
There were multiple changes that fell under that same change log item.
jvaira
Posts: 59
Joined: Tue Dec 22, 2015 7:40 pm

Re: API issues in 5.8

Post by jvaira »

Hello Sean,
Here is the query

http://xxxx/nagiosxi/api/v1/objects/rrd ... n=Physical Memory&start=1608764987.797

And here is what is returned.

{
"meta": {
"start": "1608768000",
"step": "7200",
"end": "1608768000",
"rows": "397",
"columns": "2",
"legend": {
"entry": [
{},
{}
]
}
},
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API issues in 5.8

Post by ssax »

I think this is a bug but I'm not sure when it was introduced. My 5.6.12 show the same.

This is because the XML file that the RRD file uses doesn't have the LABEL parameter on there so it's showing as blank.

The old files used to have this:

Code: Select all

[root@xid perfdata]# grep -R LABEL *
_HOST_.xml:    <LABEL>rta</LABEL>
_HOST_.xml:    <LABEL>pl</LABEL>
_HOST_.xml:    <LABEL>rtmax</LABEL>
_HOST_.xml:    <LABEL>rtmin</LABEL>
The new ones do not have that which is why they are blank.

I've reached out to development for clarification on this (they are currently gone for the day), if you don't hear from me by midday tomorrow, please update the ticket so that it pops up on my dashboard.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API issues in 5.8

Post by ssax »

Please do this:

Code: Select all

cd /tmp
rm -rf /tmp/nagiosxi
wget https://assets.nagios.com/downloads/nagiosxi/5/xi-5.8.1.tar.gz
tar zxf xi-5.8.1.tar.gz
cd nagiosxi
./init.sh
cd subcomponents/pnp
./post-install
Then force a check on the services (or wait for them to check naturally) and then view the API again and the legend should show (it fixed mine).

EDIT: The reason you have to force the check or wait for them to come in is because the LABEL is not currently in the XML files (which is why they don't show in the legend) so a check needs to occur and then the LABEL will be put in there, then the legend will show proper.
jvaira
Posts: 59
Joined: Tue Dec 22, 2015 7:40 pm

Re: API issues in 5.8

Post by jvaira »

Hello Sean,
That did the trick, thank you. Assuming that this bug is fixed in a future version having already done this should not cause any harm right?