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.
Nagios Global Event Handler
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios Global Event Handler
On the previous screen you had a different file path.
Change
to
Change
Code: Select all
./root/SomClient/bin/somClient.shhCode: Select all
/opt/SomClient/bin/somClient.shRe: Nagios Global Event Handler
Yes i have change the file from '/root/SomClient/bin/somClient.sh' to '/opt/SomClient/bin/somClient.sh'
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios Global Event Handler
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
then after a state change you can test to see if the file /tmp/it_works exists...
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_worksRe: Nagios Global Event Handler
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 ?
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 ?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios Global Event Handler
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
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
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.
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
Thanks for the feedback! We really appreciate it!
Be sure to check out our Knowledgebase for helpful articles and solutions!