Historical service-status perfdata, where stored in DB?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
danbettles
Posts: 4
Joined: Fri Jul 13, 2012 5:11 am

Historical service-status perfdata, where stored in DB?

Post by danbettles »

I'm new to Nagios and I'm really struggling to find useful documentation, so please excuse what may be dull questions.

I have a test instance of Nagios XI running on a Centos virtual machine and everything's working fine. I want to access historical status data stored in Nagios' MySQL database in an external script so I can generate my own graphs, or whatnot. I've done a little digging and have found the tables I'm after. So far, so good.

What I'm trying to find out is where the perfdata you see in the "servicestatus" table goes after a service's current status is updated by the next check; I don't see it in the statehistory table. Is it stored in another table, or is it simply discarded? Are there any config options that affect whether this information is stored or not?

I've been looking through the docs (http://nagios.sourceforge.net/docs/3_0/ ... mance_data), but haven't seen any configuration that explains what I'm seeing.

I want this historical data because it's in a machine-friendly format - using regexps to extract the data from the human readable status would be worryingly flaky, and it doesn't contain all the data I'm after anyways.

I'll be very grateful for any help you could offer. Many thanks.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Historical service-status perfdata, where stored in DB?

Post by mguthrie »

Performance data is not actually stored in mysql, but it's in an rrd file (round robin database) stored in /usr/local/nagios/share/perfdata. Data can be retrieved from the command line by something like the following:

Code: Select all

rrdtool fetch /usr/local/nagios/share/perfdata/myhost/myservice.rrd AVERAGE -s <starttime> -e <endtime>

There's also a graph image API in Nagios XI that can be accessed directly from the web. However it requires an active XI session.

[url]http://<yourserver>/nagiosxi/includes/components/perfdata/graphApi.php?host=192.168.5.11&service=&source=1&view=3&start=&end=[/url]

You could access an image like this externally by using backend credentials from the Backed API URL component.
http://library.nagios.com/library/produ ... ackend-api
danbettles
Posts: 4
Joined: Fri Jul 13, 2012 5:11 am

Re: Historical service-status perfdata, where stored in DB?

Post by danbettles »

Thanks for replying, mguthrie; that's very helpful.

I've just done a little more digging and am wondering if you know the answer to another very quick database-related question:

Am I correct in thinking that "servicechecks" contains historical service statuses - a kind of historical version of "servicestatus", which contains only current statuses? It looks as if "servicechecks" is truncated at some point by Nagios: what triggers this, and how do I control that, please?

Many thanks.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Historical service-status perfdata, where stored in DB?

Post by mguthrie »

I believe it's the mysql->nagios.nagios_statehistory table that you're after. This table is used for the state history report in XI, and is meant for historical purposes.

The table trimming thresholds can be adjusted from the Admin->Performance Settings->Database(tab).
danbettles
Posts: 4
Joined: Fri Jul 13, 2012 5:11 am

Re: Historical service-status perfdata, where stored in DB?

Post by danbettles »

Thanks again, but I'm a little confused now. (Hopefully these will be my last questions.)

Originally, I set "max_servicechecks_age=0" in ndo2db.cfg, which appeared to have no effect: the servicechecks table was still being truncated periodically.

I just set "Max service checks age" to "0" under Admin / System Config / Performance Settings / Databases. Details of service checks are being stored, so clearly "0" doesn't prevent checks being persisted. However, the table is still being truncated periodically.

* What do I have to do to stop this? I want to keep service checks indefinitely.
* I need to be sure that service checks will be kept if I ask them to be, so are there any conditions under which they're removed?
* Was I right to update the ndo2db config? Is there anything else I need to configure?

Many thanks.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Historical service-status perfdata, where stored in DB?

Post by mguthrie »

I would recommend increasing the storage time for the state history table, not the service checks table. There is a LOT more information in the service checks table and most of it isn't needed for historical purposes.

As far as setting the max service checks age to 0 in the XI admin menu, my guess is that it may have rolled back to the default. ndoutils has the DB pruning settings in the ndo2db.cfg file, but to my knowledge XI handles the DB maintenance for ndoutils now. XI's default settings are located in /usr/local/nagiosxi/html/config.inc.php, and the user defined settings are stored in the DB and can be adjusted from the Admin->Performance settings page.