This is quite complicated title for a very simple bash script.
My problem was the following. I heavily use Puppet and its Naginator module for writting my Nagios configuration. When I create a new host on Foreman, Puppet write dynamicaly the Nagios configuration with all necessary checks depending puppet classes associated to that new host (system monitoring, application monitoring, …). After puppet has written all changes, it notifies nagios daemon for a reload of configuration.
However, as my nagios module puppet was not perfect, in case of human error I can have an invalid nagios configuration created. We have the chance that nagios always checks its configuration before restarting, so I don’t loose the monitoring service. However the configuration is not reloaded and stop being updated.
That’s the reason why I wrote a 3 lines bash script wich just check nagios configuration. I basicaly use nagios binary with ‘-v’ option. You can find this script on Github.
That’s with this simple solution that I am always sure that I have a valid nagios configuration and that this configuration always match my production.