JVM introspection
v0.1.19JVM diagnostics via jcmd/jstack/jmap/jstat/JFR. Requires runner uid and gid to match the JVM process owner — actions return a permission error cleanly when the identity doesn't match.
jcmd
jmap
jstack
jstat
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below — the exact bytes this page was rendered against, so a tampered copy is
rejected — before copying it into the runner's packs dir. The command reloads a
running daemon itself; no manual restart.
sudo emisar pack install java-jvm --hash sha256:a8eacb2f1978bdadf7121e5869bee29bd0a461d3f36d50f241d64a2cfbdae03e
Setup
Attaches to local JVM processes on the runner host with the JDK tools (jcmd/jstack/jmap/jstat/JFR) — no credentials needed; the target JVM's pid is passed as an argument.
Notes
- The attach API requires the runner to run as the same uid as the target JVM; root and CAP_SYS_PTRACE do not replace HotSpot's effective-user and group check. Install a dedicated runner as the target JVM owner.
Verify it works
Runs jvm.vm_uptime, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify java-jvm
Install and configure a pack walks through the whole sequence on a host.
Actions 17 total
View on GitHub-
jvm.classloader_stats exec low Low — read-only or trivially reversible
jcmd VM.classloader_stats
Show per-classloader statistics — instance count, loaded classes, and chunk/block bytes. Use to spot a class-loader leak. Uses the attach API, so it works on JVMs running -XX:+PerfDisableSharedMem (the Cassandra default) where jvm.jstat_class fails.
View source on GitHub -
jvm.heap_dump exec critical Critical — data loss or irreversible
jmap -dump:live (heap dump)
Trigger a full GC, then dump the live heap to /tmp/<pid>-heap.hprof. Can be many GB. Causes a long STW pause (seconds). Use only when you have analyst capacity to load the .hprof and disk space to hold it.
View source on GitHub -
jvm.heap_summary exec low Low — read-only or trivially reversible
jcmd GC.heap_info
Show heap geometry — used/committed per generation (Eden, Survivor, Old, Metaspace) via the attach API. Works on JDK 9+ where `jmap -heap` was removed, and on JVMs running -XX:+PerfDisableSharedMem (e.g. Cassandra).
View source on GitHub -
jvm.jcmd_gc_run exec medium Medium — changes state, easily reversible
jcmd <pid> GC.run
Trigger a full GC. Use to compare heap usage before/after, or to force collection ahead of a heap dump for cleaner output. Causes a pause whose length depends on heap size + collector tuning.
View source on GitHub -
jvm.jfr_dump exec medium Medium — changes state, easily reversible
Dump active JFR recording
Dump the active "emisar" recording to its current file. Use mid-flight to grab a snapshot without stopping the recording.
View source on GitHub -
jvm.jfr_start exec medium Medium — changes state, easily reversible
Start a Java Flight Recording
Start a 60-second Java Flight Recording named "emisar". JFR is low-overhead (~1%). Pair with `jvm.jfr_dump` to retrieve the recording, then `jvm.jfr_stop` to end it.
View source on GitHub -
jvm.jfr_stop exec medium Medium — changes state, easily reversible
Stop active JFR recording
Stop the "emisar" recording and finalize the .jfr file.
View source on GitHub -
jvm.jmap_histo_live exec medium Medium — changes state, easily reversible
jmap -histo:live (top 50)
List top classes by retained-heap size after a forced full GC. Use to find the leak candidate.
View source on GitHub -
jvm.jstack exec low Low — read-only or trivially reversible
jstack -l (thread dump)
Dump full thread state with lock info. The canonical "what are all my threads doing?" diagnostic.
View source on GitHub -
jvm.jstack_blocked exec low Low — read-only or trivially reversible
jstack filtered to BLOCKED threads
Run jstack and filter output to threads in BLOCKED state plus their lock owners. Use to find deadlocks fast.
View source on GitHub -
jvm.jstat_class exec low Low — read-only or trivially reversible
jstat -class
Show class-loader stats — loaded class count and bytes. Use to spot a class-loading leak. Needs jvmstat perf data: fails with "<pid> not found" on JVMs running -XX:+PerfDisableSharedMem (the Cassandra default) — there use jvm.jmap_histo_live (live-object histogram) or JFR instead.
View source on GitHub -
jvm.jstat_gc exec low Low — read-only or trivially reversible
jstat -gc (10 samples)
Show ten 1-second samples of GC stats. Surfaces young + old GC time, survivor sizes, metaspace usage. Use to spot a GC storm. Needs jvmstat perf data: fails with "<pid> not found" on JVMs running -XX:+PerfDisableSharedMem (the Cassandra default) — there use jvm.heap_summary for heap state, or JFR (jvm.jfr_start / jvm.jfr_dump) for GC behavior over time.
View source on GitHub -
jvm.perfdata exec low Low — read-only or trivially reversible
jcmd PerfCounter.print
Show JVM performance counters — class loading, JIT, GC. Cheaper than jstat for one-shot. Reads the same jvmstat perf data as jstat: fails on JVMs running -XX:+PerfDisableSharedMem (the Cassandra default) — there use the attach-based reads (jvm.heap_summary, jvm.vm_flags, jvm.jstack) or JFR.
View source on GitHub -
jvm.thread_count exec low Low — read-only or trivially reversible
OS thread count for a JVM
Count /proc/<pid>/task entries — fastest way to spot "do we have an unbounded thread pool?"
View source on GitHub -
jvm.vm_flags exec low Low — read-only or trivially reversible
jcmd VM.flags
Return the JVM command-line and tuning flags. Use to confirm "is -Xmx set to what we expect?"
View source on GitHub -
jvm.vm_system_properties exec high High — service-affecting
jcmd VM.system_properties
Dump every -Dkey=value system property the JVM was started with (jcmd VM.system_properties = System.getProperties()). Use to confirm config overrides took effect — but note this deliberately surfaces every launch -D property, which routinely carries secrets (spring.datasource.password, javax.net.ssl.keyStorePassword, JDBC / cloud credentials). Scope it by policy. The runner's redaction is a fail-closed backstop, not a guarantee — it is pattern-bound and can miss a bespoke secret whose name and value match no rule.
View source on GitHub -
jvm.vm_uptime exec low Low — read-only or trivially reversible
jcmd VM.uptime
Show how long this JVM has been running.
View source on GitHub