Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_jvm
0.5 (2014101401)
2014-10-14
- Nagios 3.x
- Nagios 4.x
GPL
49107
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
JvmInspector is standalone tool + Nagios wrapper plugin (check_jvm)
that dumps various properties from locally running JVMs.
This information includes:
* Heap & non-heap memory
* Running threads
* Loaded classes
* Running java version, paths & arguments
* Container server name (App servers only)
* Total active sessions (App servers only)
(tested & supported app servers are tomcat5+ and jboss4+)
JvmInspector doesn't need local or remote JMX network socket.
It directly attaches to JVM's PerfData, so it must be started with
the same USERid as the target JVM.
The latest version can be found at:
https://fidanov.net/c0d3/nagios-plugins/jvminspector/
Requirements:
* JDK 1.6+ (for JvmInspector)
* Bash 3+ (for check_jvm)
Includes:
* JvmInspector.jar - executable jar package
* check_jvm - Nagios plugin wrapper script
Example:
./check_jvm -n|--name -p|--property -w|--warning -c|--critical
Where: property is one of: "heap|non-heap|threads|classes|sessions"
More information in README file:
https://fidanov.net/c0d3/nagios-plugins/jvminspector/README
that dumps various properties from locally running JVMs.
This information includes:
* Heap & non-heap memory
* Running threads
* Loaded classes
* Running java version, paths & arguments
* Container server name (App servers only)
* Total active sessions (App servers only)
(tested & supported app servers are tomcat5+ and jboss4+)
JvmInspector doesn't need local or remote JMX network socket.
It directly attaches to JVM's PerfData, so it must be started with
the same USERid as the target JVM.
The latest version can be found at:
https://fidanov.net/c0d3/nagios-plugins/jvminspector/
Requirements:
* JDK 1.6+ (for JvmInspector)
* Bash 3+ (for check_jvm)
Includes:
* JvmInspector.jar - executable jar package
* check_jvm - Nagios plugin wrapper script
Example:
./check_jvm -n|--name
Where: property is one of: "heap|non-heap|threads|classes|sessions"
More information in README file:
https://fidanov.net/c0d3/nagios-plugins/jvminspector/README
Reviews (7)
bydannyw, July 21, 2022
I had to modify the script to add this line to make it work under ncpa_passive:
(( EUID != PUID )) && exec sudo -u "#$PUID" $0 -n $NAME -p $PROPERTY -w $WARNING -c $CRITICAL
You have to add it before this line:
[ "${PUID}" = "${EUID}" ] || p_unknown "JVM is running with different username, run this script with UID $PUID"
You still need to give nagios sudo access to run the plugin as per the README and add or update this line in the "[plugin directives]" section of ncpa.cfg:
run_with_sudo = check_jvm
(( EUID != PUID )) && exec sudo -u "#$PUID" $0 -n $NAME -p $PROPERTY -w $WARNING -c $CRITICAL
You have to add it before this line:
[ "${PUID}" = "${EUID}" ] || p_unknown "JVM is running with different username, run this script with UID $PUID"
You still need to give nagios sudo access to run the plugin as per the README and add or update this line in the "[plugin directives]" section of ncpa.cfg:
run_with_sudo = check_jvm
byolivierdrouin, May 31, 2021
Hello,
seems to not works with G1GC mode !? No error (exit code still 0, no output console), any idea to workaround or check ?
I've changed my process command line from :
-Xms24576m
-Xmx24576m
-XX:NewRatio=3
-XX:SurvivorRatio=4
-XX:TargetSurvivorRatio=90
-XX:MaxTenuringThreshold=8
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ConcGCThreads=4
-XX:ParallelGCThreads=4
-XX:+CMSScavengeBeforeRemark
-XX:PretenureSizeThreshold=64m
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=50
-XX:CMSMaxAbortablePrecleanTime=6000
-XX:+CMSParallelRemarkEnabled
-XX:+ParallelRefProcEnabled
-verbose:gc
-XX:+PrintHeapAtGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/var/log/cloudera-hdp-solr/solr_gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=9
-XX:GCLogFileSize=20M
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=18983
-Dcom.sun.management.jmxremote.rmi.port=18983
...
to
-server
-Xms20480m
-Xmx20480m
-XX:+UseG1GC
-XX:+PerfDisableSharedMem
-XX:+ParallelRefProcEnabled
-XX:G1HeapRegionSize=8m
-XX:MaxGCPauseMillis=250
-XX:InitiatingHeapOccupancyPercent=75
-XX:+UseLargePages
-XX:+AggressiveOpts
-verbose:gc
-XX:+PrintHeapAtGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/var/log/cloudera-hdp-solr/solr_gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=9
-XX:GCLogFileSize=20M
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=18983
-Dcom.sun.management.jmxremote.rmi.port=18983
Thanks
Olivier
seems to not works with G1GC mode !? No error (exit code still 0, no output console), any idea to workaround or check ?
I've changed my process command line from :
-Xms24576m
-Xmx24576m
-XX:NewRatio=3
-XX:SurvivorRatio=4
-XX:TargetSurvivorRatio=90
-XX:MaxTenuringThreshold=8
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ConcGCThreads=4
-XX:ParallelGCThreads=4
-XX:+CMSScavengeBeforeRemark
-XX:PretenureSizeThreshold=64m
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=50
-XX:CMSMaxAbortablePrecleanTime=6000
-XX:+CMSParallelRemarkEnabled
-XX:+ParallelRefProcEnabled
-verbose:gc
-XX:+PrintHeapAtGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/var/log/cloudera-hdp-solr/solr_gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=9
-XX:GCLogFileSize=20M
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=18983
-Dcom.sun.management.jmxremote.rmi.port=18983
...
to
-server
-Xms20480m
-Xmx20480m
-XX:+UseG1GC
-XX:+PerfDisableSharedMem
-XX:+ParallelRefProcEnabled
-XX:G1HeapRegionSize=8m
-XX:MaxGCPauseMillis=250
-XX:InitiatingHeapOccupancyPercent=75
-XX:+UseLargePages
-XX:+AggressiveOpts
-verbose:gc
-XX:+PrintHeapAtGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/var/log/cloudera-hdp-solr/solr_gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=9
-XX:GCLogFileSize=20M
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=18983
-Dcom.sun.management.jmxremote.rmi.port=18983
Thanks
Olivier
byAnt, September 14, 2020
Hello, Nice work.
But it seems that since Java 9 this plugin is no longer working, because it uses a class that was in the tools.jar library (sun.tools.attach.LinuxAttachProvider) .
And tools.jar is no longer available since Java 9.
Am I wrong ?
And has anybody got a workaround for this problem ?
Have a nice day!
A.
But it seems that since Java 9 this plugin is no longer working, because it uses a class that was in the tools.jar library (sun.tools.attach.LinuxAttachProvider) .
And tools.jar is no longer available since Java 9.
Am I wrong ?
And has anybody got a workaround for this problem ?
Have a nice day!
A.
Owner's reply
Hi Ant,
Thank you for the feedback.
Your suggestion is correct, tools.jar is no longer available since Java 9 and the API has been slightly changed.
Please, try out the new version of the JvmInspector jar:
https://fidanov.net/c0d3/nagios-plugins/jvminspector/JvmInspector-jdk11.jar
Thanks,
Dimitar Fidanov
bypmoradiya, October 2, 2017
Hi,
I am using the plugin to monitor threads and sessions as below but the Nagios core server is unable to read the output. Running these check manually (as commands) on the client host is working though.
command[check_tomcat_threads]=/usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p threads -w 105 -c 135
command[check_tomcat_conn]=/usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p sessions -w 280 -c 360
Locally running the command:
# /usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p threads -w 105 -c 135
CRITICAL 153 |threads=153;;;
Any suggestions?
Thanks.
I am using the plugin to monitor threads and sessions as below but the Nagios core server is unable to read the output. Running these check manually (as commands) on the client host is working though.
command[check_tomcat_threads]=/usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p threads -w 105 -c 135
command[check_tomcat_conn]=/usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p sessions -w 280 -c 360
Locally running the command:
# /usr/bin/sudo -u tomcat7 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p threads -w 105 -c 135
CRITICAL 153 |threads=153;;;
Any suggestions?
Thanks.
Hi,
So happy to find this check.
I add -k optional parameter to check multiple JVM on the same machine :
...
Usage: $SCRIPT_NAME -n|--name -k -p|--property -w|--warning -c|--critical
Where: is one of: "heap|non-heap|threads|classes"
Hint: You can use "jps -l" or "java -jar JvmInspector.jar all" to get the java name
Example: $SCRIPT_NAME -n org.apache.catalina.startup.Bootstrap -p heap -w 1073741824 -c 2147483648
EOF
exit 0
}
[ "$#" -eq 0 ] && usage
while [ ! -z "$1" ]; do
case $1 in
-n|--name) shift; NAME="$1";;
-k|--keyword) shift; KEYWORD="$1";;
-p|--property) shift; PROPERTY="$1";;
-w|--warning) shift; WARNING="$1";;
-c|--critical) shift; CRITICAL="$1";;
-h|--help) usage;;
esac
shift
done
[ -z "$NAME" ] && p_unknown "Missing JVM app class name, use -n "
[ -z "$PROPERTY" ] && p_unknown "Missing property, use -p "
[ -z "$WARNING" ] && p_unknown "Missing warning thresholds, use -w "
[ -z "$CRITICAL" ] && p_unknown "Missing critical thresholds, use -c "
expr ${WARNING} : '[0-9]\+$' >/dev/null || p_unknown "Invalid warning threshold"
expr ${CRITICAL} : '[0-9]\+$' >/dev/null || p_unknown "Invalid critical threshold"
[ -f "$JVMINSPECTOR" ] || p_unknown "Can't find JvmInspector.jar, please install it and set JVMINSPECTOR var in this script"
if [ -z "$KEYWORD" ]; then
PSLINE="$(ps axo pid,uid,command | grep [j]ava | grep $NAME | head -1)"
else
PSLINE="$(ps axo pid,uid,command | grep [j]ava | grep $NAME | grep $KEYWORD)"
fi
...
So, now, you can use the script like this :
./check_jvm --name org.apache.catalina.startup.Bootstrap -k confluence -p heap -w 100 -c 200
./check_jvm --name org.apache.catalina.startup.Bootstrap -k jira -p heap -w 100 -c 200
Thanks a lot
Bye
So happy to find this check.
I add -k optional parameter to check multiple JVM on the same machine :
...
Usage: $SCRIPT_NAME -n|--name -k -p|--property -w|--warning -c|--critical
Where: is one of: "heap|non-heap|threads|classes"
Hint: You can use "jps -l" or "java -jar JvmInspector.jar all" to get the java name
Example: $SCRIPT_NAME -n org.apache.catalina.startup.Bootstrap -p heap -w 1073741824 -c 2147483648
EOF
exit 0
}
[ "$#" -eq 0 ] && usage
while [ ! -z "$1" ]; do
case $1 in
-n|--name) shift; NAME="$1";;
-k|--keyword) shift; KEYWORD="$1";;
-p|--property) shift; PROPERTY="$1";;
-w|--warning) shift; WARNING="$1";;
-c|--critical) shift; CRITICAL="$1";;
-h|--help) usage;;
esac
shift
done
[ -z "$NAME" ] && p_unknown "Missing JVM app class name, use -n "
[ -z "$PROPERTY" ] && p_unknown "Missing property, use -p "
[ -z "$WARNING" ] && p_unknown "Missing warning thresholds, use -w "
[ -z "$CRITICAL" ] && p_unknown "Missing critical thresholds, use -c "
expr ${WARNING} : '[0-9]\+$' >/dev/null || p_unknown "Invalid warning threshold"
expr ${CRITICAL} : '[0-9]\+$' >/dev/null || p_unknown "Invalid critical threshold"
[ -f "$JVMINSPECTOR" ] || p_unknown "Can't find JvmInspector.jar, please install it and set JVMINSPECTOR var in this script"
if [ -z "$KEYWORD" ]; then
PSLINE="$(ps axo pid,uid,command | grep [j]ava | grep $NAME | head -1)"
else
PSLINE="$(ps axo pid,uid,command | grep [j]ava | grep $NAME | grep $KEYWORD)"
fi
...
So, now, you can use the script like this :
./check_jvm --name org.apache.catalina.startup.Bootstrap -k confluence -p heap -w 100 -c 200
./check_jvm --name org.apache.catalina.startup.Bootstrap -k jira -p heap -w 100 -c 200
Thanks a lot
Bye
Hello.
When I've JVM running as "tomcat" user, and run the script with root, I get:
UNKNOWN JVM is running with different username, run this script with UID 111
That is a problem to run with Nagios.
Thanks!
When I've JVM running as "tomcat" user, and run the script with root, I get:
UNKNOWN JVM is running with different username, run this script with UID 111
That is a problem to run with Nagios.
Thanks!
Awesome concept. How does this work on servers that host multiple JVMs running under the same uid? Do you need to specify the PID?
Owner's reply
You can pass "--name", if the name is unique. Use "jps -l" or "java -jar JvmInspector.jar all to get the names.
Thanks.