I need to get a full list of hosts and services from Nagios, to make a decision table.
I think there is two methods, querying the Nagios CGI, and parsing the Nagios cfg files.
But... Nagios cfg files may not be standard and this could be a problem.
Anyone knows how do that?
Thanks in advance
You can scrape this out of the object cache file (the path of which can be found in nagios.cfg, typically located somewhere like
/usr/local/nagios/var/
or/var/cache/nagios3/
), or scrape it out of the HTML output from the CGI (which you can run via the command line), but why reinvent the wheel?You might want to try pynag, as it's made for exactly this purpose. If Python isn't your style, there's also the API category on Nagios Exchange that has similar add-ons to expose this info in almost any format you can imagine.
I personally prefer MK Livestatus for this. You could also use NDOUtils to put this data in a database.