Page 1 of 1

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

Posted: Fri Oct 18, 2013 10:08 am
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!

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

Posted: Fri Oct 18, 2013 10:48 am
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.

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

Posted: Mon Oct 28, 2013 2:27 pm
by txwomansu
Thanks for the information.