Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve check_jms bash script to autodetect java location #28

Open
GoogleCodeExporter opened this issue Sep 14, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

Here is an improved version of check_jmx bash script, one that will detect 
JAVA_HOME and that fails nicely when JAVA is missing.

#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
#RDIR=`dirname $0`
#java -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@

#!/bin/sh
JAVA_CMD=`which java`
if [ -z $JAVA_CMD ]; then
    if [ -x $JAVA_HOME/bin/java ]; then
<------>JAVA_CMD=$JAVA_HOME/bin/java
    else
<------>echo JMX CRITICAL - java not found.
<------>exit 2
    fi
fi

RDIR=`dirname $0`
OUTPUT=$($JAVA_CMD -jar $RDIR/jmxquery.jar $@)
EXIT_STATUS=$?
STATUS=`echo $OUTPUT`
VALUE=$(echo $OUTPUT | sed 's/.*{\(.*\)}.*/\1;/' | sed 's/;/; /g')
echo "$STATUS | $VALUE"

exit $EXIT_STATUS.

Original issue reported on code.google.com by [email protected] on 10 Dec 2013 at 11:55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant