Unable to take jstack for debian installations

Hello:

We have installed ES 6.8.3 on Ubuntu 14.04 using the debian installers. jstack commands do not work on these servers even when we run the command as elasticsearch user, like so:

$ sudo -u elasticsearch jstack -F 2087
Attaching to process ID 2087, please wait...
ERROR: ptrace(PTRACE_ATTACH, ..) failed for 2087: Operation not permitted
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 2087: Operation not permitted
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process: ptrace(PTRACE_ATTACH, ..) failed for 2087: Operation not permitted

jps and jstack commands work fine if we comment out the line PrivateTmp=true from /usr/lib/systemd/system/elasticsearch.service and restart the service

The PrivateTmp=true option was added as part of #32615.

Is there a recommended way to run jstack for debian installations?

Using nsenter to run jstack in the namespace of elasticsearch works.
Like so:

$sudo nsenter -t 2087 -m sudo -u elasticsearch jstack 2087

via: Wikitech page at Wikimedia

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.