Exploring the New JSON CGIs in Nagios Core 4.0.7! (Part 1)

The JSON CGIs, from the JSON branch of core, have been officially released with Nagios Core 4.0.7!

The original design goals were:

  1. To provide all information available in current CGIs in JSON format.
  2. Place the presentation responsibility on the client to minimize network traffic and server load.
  3. Perform operations on the server side that are significantly more easily done there.
  4. Spark community developers to create new Nagios Core UI’s from the easy to work with JSON from the CGIs.

The CGIs provide an API to query object, status, and historical information through GET requests.  They use the same authentication as other CGIs.  Once queried, they return valid JSON that can be parsed into JavaScript objects for client side models and processing.  The API is very robust, providing multiple ways to limit queries – name/descriptions, host/service groups,  update/changes times, among many others.

The three new CGIs are:

  1. objectjson.cgi  (object configuration)
  2. statusjson.cgi  (status information)
  3. archivejson.cgi  (historical logs)

Additionally, a new web app is included – jsonquery.html & jsonquery.js.  This is a small UI for crafting GET requests, it can be used to trial specific parameters for GET requests, or to just explore the api.  It is also the easiest way to get acquainted with the new CGIs.

Installing the JSON CGIs:

You can run the "./configure" command with extra configuration options  as needed.

Post install, you should find the 3 new CGIs in /usr/local/nagios/sbin, and the jsonquery html and js files in /usr/local/nagios/share.

To get started using the CGIs: Browse to the jsonquery.html url in your web browser:

http://<nagios server>/nagios/jsonquery.html

You should see a small UI just waiting to be explored:

json-query-generator

  1. Choose Status JSON CGI from the CGI dropdown
  2. Select hostlist for the query dropdown
  3. Click the Send Query button
  4. The right hand pane should now display a prettified JavaScript object
  5. You can then save the url, parametrize it, etc for use in ajax calls and/or integration into custom front-ends.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The query above was fairly basic.  Let’s query some more specific information:

  1. Choose Status JSON CGI from the CGI dropdown
  2. Select host for the query dropdown
  3. Select a hostname from the Host Name dropdown
  4. Click the Send Query button
  5. You should now see detailed information for the specific host returned in the JSON

Feel free to play around with the numerous options.  The CGIs are highly versatile and work well with ajax loops for custom front-ends and client-side models.  This is version 1 of the CGIs, so if you find any bugs, please report them to http://tracker.nagios.org.  More features are planned, so stay tuned!

If you utilize the new feature to create a new addon for Nagios, please share it back with the community by posting it on the Nagios Exchange.

In part 2 (coming soon) I will cover some use cases for the new CGIs and provide a short walk-through covering the creation of a (small) custom front-end.

Remember, Nagios World Conference 2014 is coming up in October. Register here for 10% off your conference pass. Act now, because this offer won’t last long!

Come see Andy Brist present at Nagios World Conference 2014

 

3 Responses to “Exploring the New JSON CGIs in Nagios Core 4.0.7! (Part 1)”


Comments are currently closed.