This is a cache of https://support.nagios.com/kb/article/api-changes-in-nagios-xi-5-7-894.html. It is a snapshot of the page at 2025-05-14T00:08:53.507+0000.
API changes in Nagios <strong>xi</strong> 5.7
Home » Categories » Products » Nagios xi » Troubleshooting » Common Problems

API changes in Nagios xi 5.7

In Nagios xi versions prior to 5.7, there was an API issue as described below:

The JSON returned from the API returns inconsistent types depending on whether single or multiple results are returned.

As an example, requesting the status of a single host returns an object but requesting the status of multiple hosts returns an array of objects.

Single result (no array) 

{
   "recordcount": "1",
   "hoststatus": {
      "@attributes": {
         "id": "737359"
      },
      "instance_id": "1",
      "host_id": "5154",
      "name": "hosta"
   }
}

Multiple results are within an array

{
  "recordcount": "2",
  "hoststatus": [
    {
      "@attributes": {
        "id": "737359"
      },
      "instance_id": "1",
      "host_id": "5154",
      "name": "hosta"
    },
    {
      "@attributes": {
        "id": "737358"
      },
      "instance_id": "1",
      "host_id": "5153",
      "name": "hostb"
    }
  ]
}

This was due to the fact that the original results were being given in XML and converted to JSON for our API. The decision was made that the output should stay as an array no matter how many of the objects are returned.

The solution in Nagios xi 5.7+

Updated all data to be sent out as JSON and no longer gets turned into XML and then converted to JSON like it had before. This extra step was CPU intensive so this may actually improve the speed of the API on large systems.

When a single object is returned it will now return as an array of objects with just one object in it.

To Consider

Keep in mind that returned single objects will now be in an array. Also, there were some name changes in the API:

Changed the service_id to service_object_id in the API objects/servicestatus and host__id to host_object_id in the objects/hoststatus endpoint.



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

4 (1)
Article Rating (1 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Nagios xi - SourceGuardian Errors 2009R1.2C
Viewed 4782 times since Tue, Feb 2, 2016
Nagios xi - Reset Upgrade Status In Web Interface
Viewed 11692 times since Tue, May 7, 2019
Nagios xi - HTTP 500 Error / White Screen After Login
Viewed 6775 times since Mon, Feb 29, 2016
Nagios xi - Problems Using Nagios xi With Proxies
Viewed 14589 times since Mon, Jan 25, 2016
Installation errors on customized corporate builds of CentOS or RHEL
Viewed 13356 times since Tue, Jan 26, 2016
Nagios xi - Disabling Database UTF8 Connectivity
Viewed 5521 times since Thu, Mar 8, 2018
Nagios xi - Some BPI Checks Show "Unknown BPI Group Index" After Upgrade
Viewed 4585 times since Wed, Sep 18, 2019
Nagios xi - ERROR: unable to open include file: /etc/mrtg/conf.d/xxxxxxx.cfg
Viewed 8467 times since Wed, Jun 1, 2016
Nagios xi - Apply Configuration Fails - Backend login to the Core Configuration failed
Viewed 25767 times since Tue, Aug 2, 2016
ERROR: Please add the ’Optional’ channel to your Red Hat systems subscriptions
Viewed 27209 times since Tue, Jan 26, 2016