Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't jcmd, jps or jstat cassandra process within the docker container

Tags:

linux

jvm

jstat

    $ jcmd -l 
    418 sun.tools.jcmd.JCmd -l

    $ jstat -gcutil -t 10 250ms 1
    10 not found

I am aware of the bug in jdk related to attaching jstat as root to a process running as a different user.

Here, this docker container has one user root and as can be seen below from the ps command, cassandra is running under root.

 $ whoami
 root

I have tried to do the following: $ sudo -u root jcmd -l

Any help is appreciated.

Docker container is debian:jessie running java version: openjdk version "1.8.0_66-internal"

Here's the output of ps -ef:

UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 17:40 ?        00:00:00 /bin/bash /run.sh
root        10     1 11 17:40 ?        00:02:25 java -ea -javaagent:/usr/share/c
root       375     0  0 17:49 ?        00:00:00 bash
root       451   375  0 18:00 ?        00:00:00 ps -ef

Aside: jstack successfully dumps out the stack traces of the threads.

like image 666
hs20400 Avatar asked Dec 01 '15 18:12

hs20400


1 Answers

I know at least two possible reasons why this can happen.

  1. Java is run with -XX:+PerfDisableSharedMem option. This option helps sometimes to reduce JVM safepoint pauses, but it also makes JVM invisible to jps and jstat. This is a very likely case, because you are running Cassandra, and recent Cassandra has this option ON by default.
  2. Java process has a different mount namespace, so that /tmp of Java process is not physically the same directory as /tmp of your shell. The directory /tmp/hsperfdata_root must be accessible in order to use jps or jstat. This is also a plausible reason since you are using docker containers.
like image 60
apangin Avatar answered Oct 31 '22 17:10

apangin