external notification commands

Marc Powell marc at ena.com
Tue Jan 23 20:08:45 CET 2007



> -----Original Message-----
> From: nagios-users-bounces at lists.sourceforge.net [mailto:nagios-users-
> bounces at lists.sourceforge.net] On Behalf Of Brian Loe
> Sent: Tuesday, January 23, 2007 12:45 PM
> To: Nagios Users mailinglist
> Subject: [Nagios-users] external notification commands
> 
> I have a notification configured to run an app and pass it Nagios
> parameters. For what ever reason I can watch the log and see a device
> go critical, but it never runs the notification command, or, if it
> does, it doesn't work.
> 
> Any way to see deeper into this process?

Make sure you have log_notifications=1 in nagios.cfg. Then you'll be
able to see in nagios.log whether your notification is being called. If
it is not then it's a simple configuration issue (notifications not
enabled globally, not enabled specifically for that host or service or
for that specific contact).

If the notification is being called but you don't see what you expect in
your notification script, echo the command that nagios is running to a
file to see if it's what you think it's supposed to be --

define command {
    command_name                   my_special_notification
    command_line                   echo "$USER1$/my-notification-script
$SOMEMACRO$ $SOMEOTHERMACRO$" >> /tmp/nagios-runs-me
    }

After nagios calls 'my_special_notification', the file
/tmp/nagios-runs-me will contain the full command line that nagios
_would_ have executed if it had really run the command.

If the notification is being called, modify your notification script to
output interesting information to a log file. In all my event handlers
the first thing it does is log the parameters it was called with ala --

LOGFILE=/usr/local/nagios/var/eventhandler.log; export LOGFILE

echo -n `date` . " " >> $LOGFILE 2>&1
echo "winbind service check ($1) ($2) ($3) ($4)... " >> $LOGFILE 2>&1

Whenever there's something interesting happening, I log that --

echo -n `date` . " " >> $LOGFILE 2>&1
echo -n "Restarting winbind service (2nd soft critical state) on $4... "
>> $LOGFILE 2>&1
# Call the init script to restart the winbind server
/usr/bin/ssh $4 'sudo /etc/init.d/winbind restart' >>$LOGFILE 2>&1

I also log if I don't do anything. I log errors from the scripts that I
call from my event handler or anything else that might be interesting. I
presume there's no reason you couldn't do this in your expanded
notification script and you have no real limitations on how verbose you
make the process.

--
Marc

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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