API for Querying the Data

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
amitgupta19
Posts: 286
Joined: Fri Sep 08, 2017 5:53 am

API for Querying the Data

Post by amitgupta19 »

I am using the Nagios Core 4.4.3 on Cent OS 7.

I am planning to integrate the Nagios with Service Now using a Tool.
For the Integration i need the APIs to query the data.

I know that there is Backend API for the Nagios XI, can i use the same for the Nagios Core?

If No is there any other way to query the Nagios core data.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API for Querying the Data

Post by scottwilkerson »

Nagios Core has a read-only API available at the following endpoint on your Core install

Code: Select all

/nagios/jsonquery.html
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
amitgupta19
Posts: 286
Joined: Fri Sep 08, 2017 5:53 am

Re: API for Querying the Data

Post by amitgupta19 »

Thanks Scott,

I will need to give the team a URL along with the credentials to query the data from the Nagios.

Can you suggest how can i do it?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API for Querying the Data

Post by scottwilkerson »

If you go to

Code: Select all

http://YOUR_HOST/nagios/jsonquery.html
make selections

run the query, then it will display the url for the specific query you want to run.

As for credentials, this will be credentials for a user with access to the nagios interface.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
amitgupta19
Posts: 286
Joined: Fri Sep 08, 2017 5:53 am

Re: API for Querying the Data

Post by amitgupta19 »

Thanks Scott

My requirement is to get the list of the services whose status is Critical along with their current Values.

When used the URL and selected the options as follows:
CGI: Status Jason CGI
Query: Servicelist
Show Details: true
Service Status: Critical

It is giving the following URL:
http://xxx.xxx.xxx.xxx/nagios/cgi-bin/s ... tails=true

Also in the result it is giving the status of all the services weather it is critical or not. From the URl also it is also clear that it is giving the result/status of all the services.

Due to this it is taking long time to complete.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API for Querying the Data

Post by scottwilkerson »

You can add the following to the URL

Code: Select all

&servicestatus=critical
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked