Writing customized Nagios Core reports
In this recipe, we'll explore some simple applications of the NDOUtils database by trying out some queries, and change one of them into both a simple report in Perl, and also into a PHP-based RSS feed.
Getting ready
This recipe assumes you have NDOUtils already installed, and that your Nagios Core 3.0 (or later) server is monitoring at least a few hosts and services, so that the queries we try actually return some data. You should also have some means of executing MySQL queries on the database server. The mysql
command-line client will work just fine; a tool such as phpMyAdmin might make the data a little easier to explore.
How to do it...
We can explore some queries against the NDOUtils databases as follows:
Retrieve the content and date/time of the latest ten notifications:
mysql> SELECT start_time, long_output FROM nagios_notifications ORDER BY start_time DESC LIMIT 10;
Retrieve the content and date/time of the latest ten host or service comments:
...