I recently looked at the JVM support for monitoring. Apart from the common JMX, there are also SNMP, which is a bit interesting. There are a lot of Network Management Protocol adaptation places, so let's test it first.
First, find a Java applet that can run continuously in the background, such as the bio socket server at hand.
Configuration of SNMP on JVM
Starting SNMP requires two changes, (http://docs.oracle.com/javase/7/docs/technotes/guides/management/snmp.html)
Com. Sun. Management. SNMP. Port = port_number. port_number indicates the SNMP port monitored by the JVM. The standard value is 161.
- You also need to copy the ACL template file fromJre_home/lib/management/snmp. ACL. TemplateToJre_home/lib/management/snmp. ACL.
Modify the original template file, comment out some comments, and change it to the following format:
acl = { { communities = public, private access = read-only managers = localhost } } trap = { { trap-community = public hosts = localhost } }
Then the operating system to change, so that the ACL file has only one owner, is to start the Java User Name, how to change the reference this article http://docs.oracle.com/javase/6/docs/technotes/guides/management/security-windows.html
If this step is not performed, an error will be reported during startup.
Error: Password File Read access must be restricted: C: \ Program Files \ Java \ jre7 \
Lib \ management \ SNMP. ACL
I am too troublesome. Set the startup parameter to not check (COM. Sun. Management. SNMP. ACL = false), so that this check can be skipped.
java -Dcom.sun.management.snmp.port=161 -Dcom.sun.management.snmp.acl=false com.tool.server.MyBIOServer
The configuration on the JVM side is OK.
SNMP Management Terminal Configuration
First to this address of the jvm snmp mib file: http://java.sun.com/j2se/1.5.0/docs/guide/management/JVM-MANAGEMENT-MIB.mib
Find an SNMP client. I use ireasoning MIB browser and load the MIB file.
Enter localhost in the address, and use the 161 port we set earlier to directly walk all exposed properties of the JVM on the Management end.
We can see that all kinds of JVM internal information are available, such as jvmclassessloadedcount. It also supports trap and low memory warning, which is good.