How to pull service/host uptime stats directly from MySQL DB

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
txwomansu
Posts: 36
Joined: Mon Oct 10, 2011 9:05 am

How to pull service/host uptime stats directly from MySQL DB

Post by txwomansu »

How to pull service/host uptime and downtime stats directly from MySQL databases that NagiosXI runs on?

I know there are 2 mysql databases: nagios and nagiosql. Please let me know what tables/columns provide the uptime/downtime stats. In other words, I would like to be able to run sql queries to pull up the % of downtime from the total period of time that some service/host was monitored, and I want to do that directly from the database and not the web GUI of NagiosXI.

Also, is there an API for nagiosql component of NagiosXI? I want to be able to manipulate hosts/services with my own code and update the database accordingly.

Thanks!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to pull service/host uptime stats directly from MySQ

Post by abrist »

txwomansu wrote:How to pull service/host uptime and downtime stats directly from MySQL databases that NagiosXI runs on?
There is no tables that directly report that. You will need to query the right table and do the math in your logic. The tables of interest:

Code: Select all

Database: 
nagios

Tables:
nagios_hoststatus
nagios_servicestatus
nagios_statehistory
nagios_logentries
txwomansu wrote: I would like to be able to run sql queries to pull up the % of downtime from the total period of time that some service/host was monitored
See my above comment.
txwomansu wrote:Also, is there an API for nagiosql component of NagiosXI? I want to be able to manipulate hosts/services with my own code and update the database accordingly.
No. The backend api is mostly read only. QL object configuration is mostly done by internal php functions. You could pick apart the CCM code or build your own queries. Be careful here as inserting incorrectly can really have adverse affects on the databases and XI.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
txwomansu
Posts: 36
Joined: Mon Oct 10, 2011 9:05 am

Re: How to pull service/host uptime stats directly from MySQ

Post by txwomansu »

Thanks for the information.
Locked