-
Notifications
You must be signed in to change notification settings - Fork 2
/
check-jbossjmx
executable file
·54 lines (49 loc) · 1.48 KB
/
check-jbossjmx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
## JBoss Nagios Plugin
##
export JBOSS_SERVER=$1
export JBOSS_MBEAN=$2
export JMX_ATTR=$3
export WARN=$4
export CRITICAL=$5
export JBOSS_HOME=`ls -1d /opt/jboss*|head -n 1`
if [ "x$JAVA_HOME" = "x" ]; then
export JAVA_HOME=`ls -1d /usr/java/jdk*|head -n 1`
fi
if [[ $1 = "--help" || $1 = "--h" || $1 = "-help" || $1 = "-h" ]]; then
echo check_jbossjmx Usage
echo "jbossJMX_plugin <JBoss Instance Name> <JBoss MBean Object Name> <JBoss MBean Attribute> <Warn Threshhold> <Critical Threshhold>"
exit 3
fi
export READING=`$JBOSS_HOME/bin/twiddle.sh -s $JBOSS_SERVER get $JBOSS_MBEAN $JMX_ATTR | awk '{split($1,names,"="); print names[2]; }' `
if [ -z $READING ]; then
echo "JMX CRITICAL - No Response"
exit 2
fi
if [ $CRITICAL -ge $WARN ]; then
if [ $READING -ge $CRITICAL ]; then
echo "JMX ATTRIBUTE CRITICAL" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 2
else
if [ $READING -ge $WARN ]; then
echo "JMX ATTRIBUTE WARNING" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 1
else
echo "JMX ATTRIBUTE OK" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 0
fi
fi
else
if [ $READING -le $CRITICAL ]; then
echo "JMX ATTRIBUTE CRITICAL" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 2
else
if [ $READING -le $WARN ]; then
echo "JMX ATTRIBUTE WARNING" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 1
else
echo "JMX ATTRIBUTE OK" - $JBOSS_MBEAN-$JMX_ATTR:$READING
exit 0
fi
fi
fi