Page 2 of 2

Re: Nagios Global Event Handler

Posted: Wed Feb 22, 2012 1:41 am
by selvi
I have run the following command, the shell file has permissions and got executed,
su nagios -c '/opt/SomClient/bin/somClient.sh

Nagios monitor the server machine and updates the "Service Status" but the Event Handler is not executing somClient.sh file.

Re: Nagios Global Event Handler

Posted: Wed Feb 22, 2012 8:29 am
by scottwilkerson
On the previous screen you had a different file path.

Change

Code: Select all

./root/SomClient/bin/somClient.shh
to

Code: Select all

/opt/SomClient/bin/somClient.sh

Re: Nagios Global Event Handler

Posted: Wed Feb 22, 2012 8:39 am
by selvi
Yes i have change the file from '/root/SomClient/bin/somClient.sh' to '/opt/SomClient/bin/somClient.sh'

Re: Nagios Global Event Handler

Posted: Wed Feb 22, 2012 10:17 am
by scottwilkerson
At this point it really depends on what is in the shell script. does it use environment variables?

Can you place something like the following as the first item of the script to verify it is opening

Code: Select all

touch /tmp/it_works
then after a state change you can test to see if the file /tmp/it_works exists...

Re: Nagios Global Event Handler

Posted: Fri Mar 02, 2012 2:34 am
by selvi
I have tried the touch command (touch /opt/test.txt) inside my shell script (/opt/SomClient/bin/somClient.sh), the command was got executed and the file got created but at the same time the "java command" which is inside that same shell file was not executed
Example:
"java -cp ${SOM_HOME}/lib/somClient.jar:${SOM_HOME}/lib/jbossall-client.jar:${SOM_HOME}/lib/ojdbc14.jar:${SOM_HOME}/lib/log4j.jar:${SOM_HOME}/lib/mailapi.jar:${SOM_HOME}/lib/activation.jar::${SOM_HOME}/lib/bsh.jar:${SOM_HOME}/lib/jbossall-client.jar:${SOM_HOME}/lib/smtp.jar:${SOM_HOME}/lib/snmp.jar:${SOM_HOME}/lib/mail.jar: -Dsom.home=${SOM_HOME} com.firstis.telaweb.somClient.SomClientAdapter -d selvi -m TestMessage"

Is there any way to execute the java command inside the nagios ?

Re: Nagios Global Event Handler

Posted: Fri Mar 02, 2012 9:39 am
by scottwilkerson
you might need to enter the full path to java.

Also, when nagios executes the event handler it does not load the profile so if ${SOM_HOME} is an environment variable it will not have access to it unless you place it in /home/nagios/.bashrc

Re: Nagios Global Event Handler

Posted: Tue Mar 06, 2012 6:05 am
by selvi
Hi scottwilkerson

Thanks for support. we have tried by updating environment variable in .bashrc file, but it had no effect in the Nagios Event Handler. We had given the path in the shell file(somClient.sh) directly and it worked.

Re: Nagios Global Event Handler

Posted: Tue Mar 06, 2012 11:53 am
by lmiltchev
Thanks for the feedback! We really appreciate it!