Plugin that will test nagios.cfg
Thomas Guyot-Sionnest
dermoth at aei.ca
Fri Jun 22 05:13:08 CEST 2007
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
More information about the Users
mailing list