How to enable SNMP with a JVM

This is useful to do when you are wishing to monitor the Memory allocation with in your java application.

HowTo

  1. Add the following to JVM_OPTS

       -Dcom.sun.management.config.file=/export/home/pcanham/jvmsnmp/management.properties
       

  2. Contents of management.properties is

       com.sun.management.snmp.interface=0.0.0.0
       com.sun.management.snmp.port=1161
       com.sun.management.snmp.trap=1162
       com.sun.management.snmp.acl=false
       

  3. If wishing ACL create a file called snmp.acl and the change ‘com.sun.management.snmp.acl=false’ to ‘com.sun.management.snmp.acl=snmp.acl’

  4. Make sure only owner has read and write access nobody and group are not allowed any access

       -rw-------   1 pcanham    other        356 Aug  8 16:01 snmp.acl
       

  5. Contents of snmp.acl

       acl = {
       {
       communities = public, private
       access = read-only
       managers = localhost
       }
       }
       
       # Traps are sent to localhost only
       
       trap = {
       {
       trap-community = public
       hosts = localhost
       }
       }
       

MIB

Useful MIBs

jvmMemoryHeapUsed

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.11

jvmMemoryHeapCommitted

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.12

jvmMemoryHeapMaxSize

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.13

jvmMemoryNonHeapUsed

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.21

jvmMemoryNonHeapCommited

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.22

jvmMemoryNonHeapMaxSize

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.23

jvmThreadCount

#.1.3.6.1.4.1.42.2.145.3.163.1.1.3.1

jvmMemPoolName

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.2

jvmMemPoolUsed

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.11

jvmMemPoolCommitted

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.12

jvmMemPoolMaxSize

.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.13

Share