Discussion:
[Nagios-users] Event Handlers
Gürkan Aslan
2008-10-15 09:18:16 UTC
Permalink
Hi,

I'm trying to define an event handler for nagios. Actually it will work
same as event handler example
(http://nagios.sourceforge.net/docs/3_0/eventhandlers.html#example) but
it doesn't work... i'm trying to create a file in /tmp folder to test,
but nothing in return. event_handler_enabled = 1 in service definition
and nagios.cfg.

with nagios user, i can create a file under /tmp folder
(touch /tmp/foo). Actually i'm trying to restart a service. I defined a
sudo command for nagios like this (in /etc/sudoers file)

nagios LOCAL=NOPASSWD:/etc/init.d/myservice restart

sudo /etc/init.d/myservice restart command is properly running as nagios
user (I'm switching user by: su - nagios).

But i cannot run both of them via an event handler. As i feel that
nagios couldn't trigger the event file...

Any suggestion?

Best regards
--
Gürkan Aslan
Senior Developer
Komturk Iletisim Ltd. Sti
Phone: +90 212 275 88 99 ext 125
Francis Dube
2008-10-15 14:51:51 UTC
Permalink
Hi,
I'm trying to define an event handler for nagios. Actually it will =
work
same as event handler example
(http://nagios.sourceforge.net/docs/3_0/eventhandlers.html#example)=
but
it doesn't work... i'm trying to create a file in /tmp folder to te=
st,
but nothing in return. event_handler_enabled =3D 1 in service defin=
ition
and nagios.cfg.
with nagios user, i can create a file under /tmp folder
(touch /tmp/foo). Actually i'm trying to restart a service. I defin=
ed a
sudo command for nagios like this (in /etc/sudoers file)
nagios LOCAL=3DNOPASSWD:/etc/init.d/myservice restart
sudo /etc/init.d/myservice restart command is properly running as n=
agios
user (I'm switching user by: su - nagios).
But i cannot run both of them via an event handler. As i feel that
nagios couldn't trigger the event file...
Any suggestion?
Best regards
=20
Is your event handler script correctly assigned to your service ?=
=20
(event_handler your-event-handler)

Can you give me your command definition for you event handler, someth=
ing=20
like :

define command{
=09command_name=09your-event-handler
=09command_line=09/usr/local/nagios/libexec/eventhandlers/your-event-=
handler $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $ANY_OTHE=
R_VARIABLE_YOU_MAY_NEED$
=09}


Francis Dube
R&D - Optik Securite
www.optiksecurite.com
Gürkan Aslan
2008-10-15 15:18:24 UTC
Permalink
Hi Francis,

Thanks for your answer but i solved the problem.

My Mistakes:
* I must use full path in my bash script.
* Event Handler is triggering the event only for the first state
change.

Best regards
Post by Francis Dube
Post by Gürkan Aslan
Hi,
I'm trying to define an event handler for nagios. Actually it will work
same as event handler example
(http://nagios.sourceforge.net/docs/3_0/eventhandlers.html#example) but
it doesn't work... i'm trying to create a file in /tmp folder to test,
but nothing in return. event_handler_enabled = 1 in service definition
and nagios.cfg.
with nagios user, i can create a file under /tmp folder
(touch /tmp/foo). Actually i'm trying to restart a service. I defined a
sudo command for nagios like this (in /etc/sudoers file)
nagios LOCAL=NOPASSWD:/etc/init.d/myservice restart
sudo /etc/init.d/myservice restart command is properly running as nagios
user (I'm switching user by: su - nagios).
But i cannot run both of them via an event handler. As i feel that
nagios couldn't trigger the event file...
Any suggestion?
Best regards
Is your event handler script correctly assigned to your service ?
(event_handler your-event-handler)
Can you give me your command definition for you event handler, something
define command{
command_name your-event-handler
command_line /usr/local/nagios/libexec/eventhandlers/your-event-handler $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $ANY_OTHER_VARIABLE_YOU_MAY_NEED$
}
Francis Dube
R&D - Optik Securite
www.optiksecurite.com
--
Gürkan Aslan
Senior Developer
Komturk Iletisim Ltd. Sti
Phone: +90 212 275 88 99 ext 125
Continue reading on narkive:
Loading...