Plugin that will test nagios.cfg

Hari Sekhon hpsekhon at googlemail.com
Fri Jun 22 11:14:11 CEST 2007


On my installation I noticed that it does crash when you do 
/etc/init.d/nagios restart, but not if you do /etc/init.d/nagios reload 
which I think is what you should be doing.

When deploying, I use reload instead of restart, that way you get the 
error message from the pre-flight check but nagios still stays up and 
using the older configuration which gives you the change to fix it and 
reload nagios again until it works, without taking nagios down or have 
it crash.

You must be doing /etc/init.d/nagios restart where you should be doing 
/etc/init.d/nagios reload.

BTW I am using nagios 2.5 at the moment.

I think the other guys have the right idea of calling the pre-flight 
check with nagios -v and only trying to reload/restart if that is 
successful. Although on my deploy script, doing a reload does this 
anyway, so I haven't implemented it in my deploy, but a very good 
suggestion that I may use just to be double sure and not rely on the 
reload argument to the init script doing the right thing.

-h

Hari Sekhon



Thomas Guyot-Sionnest wrote:
> On 21/06/07 05:20 PM, Patrick Morris wrote:
>   
>> Arno Lehmann schrieb am Donnerstag, den 21. Juni 2007:
>>
>>     
>>> Hi,
>>>
>>> chiel schrieb:
>>>       
>>>> I'm looking for a plugin that will check if the nagios.cfg is ok.
>>>> So besecauly run this command: "/usr/local/nagios/bin/nagios -v 
>>>> /usr/local/nagios/etc/nagios.cfg". Is there a plugin for this?
>>>>         
>>> Wouldn't it be better to check this in the cron job itself? Nagios 
>>> won't help you much if it crashes because of a broken config.
>>>
>>> The cron job could, naturally, report problems as passive results to 
>>> Nagios...
>>>       
>> Nagios will never crash because of a broken config if it's running; 
>> it just won't load that config.  Checking from a cron job works, too,
>> but there's no reason Nagios can't also check to see if the on-disk
>> config is valid.
>>     
>
> Not true. I noticed more than once that nagios would bail out on
> restarts with broken configs (with versions ranging between 2.0 beta to
> 2.4) and I just verified with v2.7.
>
> About the other problem, why not have the scripts restart nagios
> themselves after checking that the config isn't broken? As it was
> mentioned in another thread just use the return status:
>
> #!/bin/bash
> if nagios -v nagios.cfg; then
>   killall -HUP nagios
> else
>   echo "Nagios config is broken!"
>   exit 1
> fi
>
>
> #!/usr/bin/perl
> `nagios -v nagios.cfg`;
> if ($?) {
>   die("Nagios config is broken!");
> }
> killall -HUP nagios
>
>
>
> If you have different scripts running you can also write a standalone
> script that does the job. It could also send back the result to Nagios.
>
> Thomas
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
>
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list