Search This Blog

Friday, January 22, 2016

Quick and Dirty jstatd Setup on Linux

What is jstatd?


"The jstatd tool is an RMI server application that monitors for the creation and termination of instrumented HotSpot Java virtual machines (JVMs) and provides a interface to allow remote monitoring tools to attach to JVMs running on the local host." [source]

NOTE: jstatd is not required for JMX connections;

How to setup jstatd on a Linux server?

A) login as root (told you - it's dirty)

B) create the jstatd.all.policy file in the home folder (/root) with the following content: 

   grant codebase "file:/opt/jdk1.8.0_45/lib/tools.jar" {

     NOTE: don't forget to change the path of the JDK

C) run jstatd:

   ./jstatd -p 1099

      -p                                         listen port for jstat daemon             policy file to use (created above)     use IPv4 (optional if IPv6 not used)
      java.rmi.server.hostname    listen on this interface (optional)

      NOTE: add & to run jstatd in background 

D) now you should be able to monitor this server using VisualVM.