Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Hari Sekhon
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@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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Arno Lehmann
Hi,

21.06.2007 23:20,, 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.

Well, I've seen Nagios crash on a broken config. Even if this is a bug 
which should (and perhaps is) fixed, I would not rely on that 
behaviour if I can easily avoid that.

Thus my recommendation...

Arno

-
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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Hari Sekhon
did you see my last email regarding this and reload vs restart?

also, something I forgot to add, here is a very basic shell test that I 
run through cron to check nagios is up and email me if not:


$PLUGIN_DIR/check_nagios -F $NAGIOS_STATUS_LOG -e 5 -C $NAGIOS_BINARY  $LOG

if [ $? != 0 ]; then
/bin/mail -s Nagios may not be running! $RECIPIENT  $LOG  
/dev/null
fi


obviously you need to set the $VARIABLES to the paths of your nagios 
binary, log file, plugin directory where the check_nagios plugin is located.

Hope that helps.

-h

Hari Sekhon



Arno Lehmann wrote:
 Hi,

 21.06.2007 23:20,, 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.
 

 Well, I've seen Nagios crash on a broken config. Even if this is a bug 
 which should (and perhaps is) fixed, I would not rely on that 
 behaviour if I can easily avoid that.

 Thus my recommendation...

 Arno

 -
 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@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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Thomas Guyot-Sionnest
On 22/06/07 05:14 AM, Hari Sekhon wrote:
 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.

One everyone uses init scripts. Nagios can also be restarted via
signals, web interface and directly trough the command pipe. Any of
these methods won't do any sanity checking.

The init script does pretty much what I put in my bash example (and even
more sanity checking)... BTW it checks the config on restarts too, so
maybe you're running an old version...

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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Marc Powell


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:nagios-users-
 [EMAIL PROTECTED] On Behalf Of Hari Sekhon
 Sent: Friday, June 22, 2007 9:24 AM
 To: Thomas Guyot-Sionnest
 Cc: nagios-users@lists.sourceforge.net
 Subject: Re: [Nagios-users] Plugin that will test nagios.cfg
 
 
 
  One everyone uses init scripts. Nagios can also be restarted via
  signals, web interface and directly trough the command pipe. Any of
  these methods won't do any sanity checking.
 
 
 Do you mean Not everyone uses init script?
 
  The init script does pretty much what I put in my bash example (and
even
  more sanity checking)... BTW it checks the config on restarts too,
so
  maybe you're running an old version...
 
 
 nagios 2.5 as I mentioned. not too old I think.
 
 It does check on restart, but the difference is that nagios is stopped
 so it can't start with the broken config, therefore it is no longer
 running, whereas if I do a reload instead then nagios is still running
 and I get the error checking but nagios is still up with the old
config
 until I fix the new config and do another reload. Nagios basically
stays
 up and keeps it's existing config if the new config doesn't pass the
 pre-flight check.

I'd say you're using a broken init script then. It's very clear that
nagios verifies the config and only stops and starts if verification is
OK.

restart)
printf Running configuration check...
$NagiosBin -v $NagiosCfgFile  /dev/null 21;
if [ $? -eq 0 ]; then
echo done
$0 stop
$0 start
else
#$NagiosBin -v $NagiosCfgFile
echo  FAILED!  Restart aborted.  Check your
Nagios configuration.
exit 1
fi
;;

--
Marc


-
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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Hari Sekhon


 One everyone uses init scripts. Nagios can also be restarted via
 signals, web interface and directly trough the command pipe. Any of
 these methods won't do any sanity checking.

   
Do you mean Not everyone uses init script?

 The init script does pretty much what I put in my bash example (and even
 more sanity checking)... BTW it checks the config on restarts too, so
 maybe you're running an old version...

   
nagios 2.5 as I mentioned. not too old I think.

It does check on restart, but the difference is that nagios is stopped 
so it can't start with the broken config, therefore it is no longer 
running, whereas if I do a reload instead then nagios is still running 
and I get the error checking but nagios is still up with the old config 
until I fix the new config and do another reload. Nagios basically stays 
up and keeps it's existing config if the new config doesn't pass the 
pre-flight check.

-h




-
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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Hugo van der Kooij
On Thu, 21 Jun 2007, Marc Powell wrote:

 If you can reliably reproduce this with a '/etc/init.d/nagios reload' or
 'restart' then you should report it as a bug. Nagios is meant to not
 crash or bail a running copy if the new config is bad.

If nagios can not start due to a broken config then a restart WILL die. A 
restart is nothing short of a stop and start of the program.

Wether or not an attempt to reload a broken config should result in a 
program failure is not clear to me. But I would consider as-is and would 
not considere it a bug if it would die on a reload of a broken config.

As the admin it is my job to give nagios a sane config. If I fail to 
provide nagios one then I understand nagios is getting rather 
disappointed.

Hugo.

-- 
[EMAIL PROTECTED]   http://hugo.vanderkooij.org/
This message is using 100% recycled electrons.

Some men see computers as they are and say Windows
I use computers with Linux and say Why Windows?
(Thanks JFK, for the insight.)

-
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@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


Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-22 Thread Marc Powell


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:nagios-users-
 [EMAIL PROTECTED] On Behalf Of Hugo van der Kooij
 Sent: Friday, June 22, 2007 3:30 PM
 To: Nagios Users mailinglist
 Subject: Re: [Nagios-users] Plugin that will test nagios.cfg
 
 On Thu, 21 Jun 2007, Marc Powell wrote:
 
  If you can reliably reproduce this with a '/etc/init.d/nagios
reload' or
  'restart' then you should report it as a bug. Nagios is meant to not
  crash or bail a running copy if the new config is bad.
 
 If nagios can not start due to a broken config then a restart WILL
die. A
 restart is nothing short of a stop and start of the program.

Then you are not using the distribution init script and you must include
that logic yourself. Read it or read back in this thread. The only
possible way it should die is if nagios -v didn't detect a fatal error.
That would be a bug.
 
If a person doesn't use the distribution init script then they are
responsible for ensuring that the config is good before restart.

--
Marc


-
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@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


[Nagios-users] Plugin that will test nagios.cfg

2007-06-21 Thread chiel
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?

I want this because I reload the nagios config every 15 minutes through a 
cronjob. And I want to be notified if there is a error in the config.
The reason of using a cronjob is that custom programs populate/change my .cfg 
files

-
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@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

Re: [Nagios-users] Plugin that will test nagios.cfg

2007-06-21 Thread Thomas Guyot-Sionnest
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@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