Event Handlers, start a java program, nohup issues.
David Rosenstrauch
darose at darose.net
Thu Jul 2 16:00:38 CEST 2009
Perhaps instead of using a java daemon to do JMX queries, you could use
the check_jmx nagios plugin. (Available at the monitoring exchange
site.) I've been using it in our Nagios system, and it's been working
nicely (after some enhancements).
I'm in the process of adopting and enhancing the code (neither of the
previous 2 authors wanted to maintain it) and setting up a proper home
for it on sourceforge (http://sourceforge.net/projects/nagioscheckjmx/).
(Don't download it yet until I get the 1.0 release uploaded.)
HTH,
DR
Marco Tirado wrote:
> Hello Users:
>
> I have a problem with an event handler of mine. The handler starts a java
> daemon-like program which loops forever waiting for connections and performs
> JMX queries against our java applications.
>
> The problem is that the handler times out when it is run by nagios. This is
> what I see in the logs:
>
> [01-07-2009 18:45:36] SERVICE EVENT HANDLER:
> bj-mon-01;JMX_Server_Running;(null);(null);(null);start_jmx_server
> [01-07-2009 18:46:07] Warning: Service event handler command
> '/usr/local/nagios/libexec/eventhandlers/start_jmx_server CRITICAL SOFT 1'
> timed out after 30 seconds
>
> The event handler should start my JMXServer both in hard and soft states. I
> have run the command from the console as the "nagios" user and it works, so
> the problem has nothing to do with user rights for nagios.
>
> The problem is that the handler hangs when I run "nohup" followed by my
> command for starting the server (see the red text below).
>
> My event handler looks like this:
>
> ###########################
> # PROPERTIES
> ###########################
>
> PORT="4444"
> ECHO_CMD="/bin/echo"
> JAVA_CMD="/usr/bin/java"
> CLASSPATH="MyClasspath"
> JVM_OPTIONS="MyOptions"
>
> ###########################
>
> # What state is the JMXServer in?
> case "$1" in
>
> OK)
> ;;
>
> WARNING)
> ;;
>
> UNKNOWN)
> ;;
>
> CRITICAL)
>
> case "$2" in
>
> SOFT)
>
> `$ECHO_CMD "TRYING restart" >> /tmp/test`
> nohup $JAVA_CMD -cp $CLASSPATH $JVM_OPTIONS JMXServer $PORT
> </dev/null 2>&1 >> $LOG_FILE&
> `$ECHO_CMD "TRYING restart" >> /tmp/test`
>
> ;;
>
> HARD)
>
> `$ECHO_CMD "TRYING restart" >> /tmp/test`
> nohup $JAVA_CMD -cp $CLASSPATH $JVM_OPTIONS JMXServer $PORT
> </dev/null 2>&1 >> $LOG_FILE&
> `$ECHO_CMD "FINISHED trying" >> /tmp/test`
>
> ;;
>
> esac
>
> ;;
>
> esac
>
> exit 0
>
>
>
> Any help, hint or recommendation is deeply appreciated.
>
> //Marco
------------------------------------------------------------------------------
_______________________________________________
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