API Call for number of services

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dh0125e
Posts: 40
Joined: Tue Aug 04, 2020 9:30 am

API Call for number of services

Post by dh0125e »

Is there an API call that returns just the number of services similar to value you see in the UI when you go to View / Status Detail where it shows the total number of services that are being managed. The statusdetail command as I'm reading the documentation right now is trying to return all of the details about the services from the API which chokes and takes quite a while for a system as large as ours. I'm looking just to get the total record count but I can't find it anywhere in the webservice API.

I'm looking to create a health check to compare that value to the number of services which have been checked in the last 15 minutes. When these two values have a large delta it's an indicator of issues with the infrastructure that require investigation.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API Call for number of services

Post by scottwilkerson »

You can get this in the system/statusdetail API
in
nagioscore -> activeservicechecks -> val15

This is the number of checks performed in the last 15 minutes
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dh0125e
Posts: 40
Joined: Tue Aug 04, 2020 9:30 am

Re: API Call for number of services

Post by dh0125e »

That's the number performed, not the number of checks that SHOULD be performed. Comparing that value you've pointed out to the value I'm looking for would allow us to validate the environment is not having issues. I'm looking for the equiv of select count(*) from nagios_servicestatus on the XI database.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API Call for number of services

Post by scottwilkerson »

You can call the objects/servicestatus or objects/hoststatus and see the recordcount field

If you do not want to return the whole API calls you can add the following to the URL

Code: Select all

&totals=1
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API Call for number of services

Post by scottwilkerson »

Worth noting that this will include all records unless you add other qualifiers to make sure you are only counting things that should be scheduled

Code: Select all

&should_be_scheduled=1
there is still going be some grey area depending on frequency of each of the checks, timeperiods, etc
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dh0125e
Posts: 40
Joined: Tue Aug 04, 2020 9:30 am

Re: API Call for number of services

Post by dh0125e »

What does should_be_scheduled indicate? When I run a check on totals on our super heavily loaded load testing system I get the same answer from totals=1 and total=1&should_be_scheduled=1.

Thanks,
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: API Call for number of services

Post by scottwilkerson »

It means that active checks haven't been disabled
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked