Query Nagios status programmatically

monitoringnagiosscripting

I recently acquired a nice 7×11 LED display, and I want (among other stuff) display my nagios status on it. For that I need to query the status of my Nagios installation.

What is the appropriate way to get a status summary (e.g. number of non-OK services) from a remote Nagios server from, say, a perl script?

Best Answer

I maintain an extremely large nagios installation, and can say the absolute best method to do this is via the "livestatus" event broker:

http://mathias-kettner.de/checkmk_livestatus.html

Livestatus provides instant access to nagios status via a local or tcp socket and introduces almost zero additional CPU load on your monitoring server (but does have a memory footprint, of course). Simple integration with xinetd/unixcat allows it to be queried via the network. Output is in one of three formats: CSV, JSON and Python. Numerous configuration options are available, and it is stable enough for Production usage. The documentation is very good.

Additionally, livestatus enables other nagios add-ons, such as "MK Multisite", which aggregates the results from multiple nagios installations into a single GUI without the use of NSCA or passive service checks results, which require nagios configurations to be maintained on both worker and master servers.