THIS KNOWLEDGE BASE HAS BEEN ARCHIVED AND IS NO LONGER BEING UPDATED
Please visit library.nagios.com/docs for the latest and most up-to-date documentation.
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!

1.6 (5)
Article Rating (5 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 - Crashed Database Tables
Viewed 70258 times since Tue, Jan 27, 2015
Nagios XI - Event Data Is Stale
Viewed 8028 times since Wed, Jan 27, 2016
Nagios XI - ICMP and Ping Checks Stopped Graphing
Viewed 17493 times since Mon, Jan 25, 2016
Nagios XI - 2014 Upgrade Issue - CONFIG ERROR
Viewed 8058 times since Mon, Jan 25, 2016
Nagios XI - MSSQL Wizards - Adaptive Server connection failed
Viewed 14566 times since Thu, Aug 3, 2017
XI 5.4 monitoring engine not running
Viewed 14262 times since Mon, Feb 6, 2017
Nagios XI - Can’t Log Into The Web Interface
Viewed 69862 times since Tue, Jan 27, 2015
Nagios XI - Core 4 Load Spikes on 1.75 and 7 Hour Intervals
Viewed 6681 times since Mon, Jan 25, 2016
Nagios XI - Display All Scheduled Reports
Viewed 7178 times since Wed, Oct 12, 2016
Nagios XI - Status Information Cut Off At 256 Characters
Viewed 10566 times since Thu, Feb 25, 2016