JVM Monitoring

NetXMS can monitor Java Virtual Machine (JVM) instances through JMX (Java Management Extensions). This enables monitoring of Java applications including heap usage, thread counts, class loading, and application-specific MBeans.

Overview

JVM monitoring provides visibility into:

  • Heap and non-heap memory usage

  • Thread count and state

  • Class loading statistics

  • Application-specific metrics exposed via JMX MBeans

Garbage collector statistics have no dedicated metrics; they can be read through the generic JMX.ObjectAttribute(…​) metric against the java.lang:type=GarbageCollector,name=…​ MBeans.

Agent Configuration

The NetXMS agent uses a two-layer architecture for JMX monitoring: the Java subagent (java.nsm) loads a JVM and bridges Java plugins into the agent, and the JMX plugin (jmx.jar) provides the actual JMX monitoring capability.

SubAgent = java.nsm

[JAVA]
JVM = /usr/lib/jvm/java-17/lib/server/libjvm.so
Plugin = jmx.jar

[JMX]
Server = myapp:service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
Server = tomcat:monitor/secret@service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi

Java subagent configuration ([JAVA] section):

Parameter Description

JVM

Path to the JVM shared library (libjvm.so on Linux, jvm.dll on Windows). Auto-detected if not set.

JVMOptions

Additional option for the JVM (e.g. -Xmx128M). Can appear multiple times.

ClassPath

Extra classpath entries. Can appear multiple times.

Plugin

Plugin to load, as a JAR file path or a class name. Can appear multiple times. Use jmx.jar for JMX monitoring. Relative paths resolve from the agent’s lib/java/ directory.

JMX plugin configuration ([JMX] section):

Server entry format: name:url, name:login@url, or name:login/password@url

At least one Server entry must be defined; without it the JMX plugin fails to load with the error "JMX servers not defined".

Component Description

name

Unique identifier for this JVM (used in metric names as the first argument)

url

JMX service URL (e.g. service:jmx:rmi:///jndi/rmi://host:port/jmxrmi)

login

JMX authentication user (optional, placed before @)

password

JMX authentication password (optional, separated from login by /)

Enabling JMX on Java Applications

The target Java application must have JMX enabled. Add these JVM options:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

For production with authentication:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=true
-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.password.file=/path/to/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=/path/to/jmxremote.access

JVM Metrics

Memory

Parameter Description

JMX.Memory.Heap.Current(name)

Current heap memory usage in bytes

JMX.Memory.Heap.Committed(name)

Committed heap memory in bytes

JMX.Memory.Heap.Init(name)

Initial heap memory in bytes

JMX.Memory.Heap.Max(name)

Maximum heap memory in bytes

JMX.Memory.NonHeap.Current(name)

Non-heap memory usage in bytes

JMX.Memory.NonHeap.Committed(name)

Committed non-heap memory in bytes

JMX.Memory.NonHeap.Init(name)

Initial non-heap memory in bytes

JMX.Memory.NonHeap.Max(name)

Maximum non-heap memory in bytes

JMX.Memory.ObjectsPendingFinalization(name)

Number of objects pending finalization

Memory metrics are absolute values in bytes. To monitor heap usage as a percentage, compute it from JMX.Memory.Heap.Current and JMX.Memory.Heap.Max in a DCI transformation script.

Threads

Parameter Description

JMX.Threads.Count(name)

Current thread count

JMX.Threads.DaemonCount(name)

Current daemon thread count

JMX.Threads.PeakCount(name)

Peak thread count since JVM start

JMX.Threads.TotalStarted(name)

Total threads started since JVM start

VM Information

Parameter Description

JMX.VM.Uptime(name)

JVM uptime in milliseconds

JMX.VM.Name(name)

JVM implementation name

JMX.VM.Version(name)

JVM version

JMX.VM.Vendor(name)

JVM vendor

JMX.VM.SpecVersion(name)

JVM specification version

JMX.VM.BootClassPath(name)

Boot class path

JMX.VM.ClassPath(name)

Class path

JMX.VM.LoadedClassCount(name)

Currently loaded class count

JMX.VM.TotalLoadedClassCount(name)

Total classes loaded since JVM start

JMX.VM.UnloadedClassCount(name)

Total classes unloaded

Discovery Lists

List Description

JMX.Domains(name)

All available MBean domains on the JVM

JMX.Objects(name[,domain])

MBean object names. Optional second argument filters by domain.

JMX.ObjectAttributes(name,object)

Attribute names of a specific MBean. Second argument is the fully-qualified MBean object name.

Custom MBean Monitoring

Any MBean exposed by the Java application can be queried:

JMX.ObjectAttribute(name,objectName,attributeName[,item])

The optional item argument is used when the attribute is a CompositeData type (e.g. HeapMemoryUsage has items committed, used, init, max).

Example — monitoring Tomcat thread pool:

JMX.ObjectAttribute(tomcat,'Catalina:type=ThreadPool,name="http-nio-8080"',currentThreadCount)

Example — monitoring ActiveMQ queue depth:

JMX.ObjectAttribute(activemq,'org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=myQueue',QueueSize)
JMX ObjectNames contain commas, so the ObjectName must be enclosed in quotes to be treated as a single argument.

Application servers such as Tomcat, WildFly/JBoss, or ActiveMQ expose their operational statistics as MBeans that can be read the same way.

Troubleshooting

JMX Connection Refused

  1. Verify JMX is enabled on the target JVM

  2. Check the JMX port is accessible from the agent host

  3. Verify firewall rules

  4. If using RMI, the JVM may require -Djava.rmi.server.hostname=<ip> to bind to the correct interface

Authentication Failures

  1. Verify the JMX password file permissions (must be readable only by the JVM user)

  2. Check username and password in the agent configuration

  3. Verify the access file grants the monitoring user read access