Monitoring Glassfish/Java with SNMP
By AkH, 2 years, 7 months ago, modified Dec. 24, 2007
Java provide some tools for monitoring that use JMX (an API dedicated to JVM monitoring, but only exists in Java with a JVM), the most known is JConsole.
This are great tools but integration with other monitoring software like Nagios is a pain.
Why ?
Cause your Nagios need to run this tool all 1mn or 5mn, it means run a JVM (with all the cpu and memory usage ...) each time you want the measure, Sun should create a JMX API for Python, Ruby ...
So the solution is activate the JVM SNMP.
For glassfish it means add 3 parameters to the JVM options:
<jvm-options>-Dcom.sun.management.snmp.port=1161</jvm-options>
<jvm-options>-Dcom.sun.management.snmp.acl.file=/etc/snmp/conf/jvm-appserv.acl</jvm-options>
<jvm-options>-Dcom.sun.management.snmp.interface=192.168.45.48</jvm-options>
This apply to all java programs cause this is provided by the JVM itself not glassfish.
The port you want to listen to
The ACL file see below
And the interface IP you want to listen to
The ACL file must contain the read or write rules you want to give to a host for example:
acl = {
{
communities = mypubkey
access = read-only
managers = monitoring.mydomain.com
}
}
Time to browse your jvm oids:
snmpwalk -m all -v2c -c mypubkey 192.168.45.48:1161 1.3.6.1.4.1.42.2.145.3.163.1.1.4 | less JVM-MANAGEMENT-MIB::jvmRTName.0 = STRING: 7022@tructruc.domain.com JVM-MANAGEMENT-MIB::jvmRTVMName.0 = STRING: Java HotSpot(TM) Server VM JVM-MANAGEMENT-MIB::jvmRTVMVendor.0 = STRING: Sun Microsystems Inc. JVM-MANAGEMENT-MIB::jvmRTVMVersion.0 = STRING: 1.6.0_03-b05 JVM-MANAGEMENT-MIB::jvmRTSpecName.0 = STRING: Java Virtual Machine Specification JVM-MANAGEMENT-MIB::jvmRTSpecVendor.0 = STRING: Sun Microsystems Inc. JVM-MANAGEMENT-MIB::jvmRTSpecVersion.0 = STRING: 1.0 JVM-MANAGEMENT-MIB::jvmRTManagementSpecVersion.0 = STRING: 1.1 JVM-MANAGEMENT-MIB::jvmRTBootClassPathSupport.0 = INTEGER: supported(2) JVM-MANAGEMENT-MIB::jvmRTInputArgsCount.0 = INTEGER: 67 JVM-MANAGEMENT-MIB::jvmRTUptimeMs.0 = Counter64: 694139 milliseconds JVM-MANAGEMENT-MIB::jvmRTStartTimeMs.0 = Counter64: 1198507874598 milliseconds


Comments
This are great tools but integration with other monitoring software like Nagios is a pain.
Why ?
I loved the editorial.It is very interesting.Thank you for the information.
I am always searching online for articles that can help me get further ahead. Thanks a million!
Thanks for this! I’ve been looking all over the internet for it.
Great thanks for sharing this article post.
It's so lucky for me to find your blog <a href="http://www.chinadesignerwholesale.com/">cheap china wholesale</a>! So shocking and great<a href="http://www.giantsupplier.com/">Cheap MBT Shoes</a>! Just one suggestion: It will be better <a href="http://www.giantsupplier.com/">Cheap Men's Brand Clothing</a> and easier to follow if your blog can offer rrs subscription service.