问题描述
jps
如何获取所有本地java
进程的信息?它是否连接到某个本地服务器进程以获取信息?
jinfo、jstat、jmap
和jstack
如何获取本地java
进程的信息?他们是否连接到某些本地服务器进程以获取信息?
jstatd
是否只用于提供对本地java
进程的远程访问,而不用于提供对本地java
进程的本地访问?p>
我正在运行 Ubuntu.我的问题来自 https://stackoverflow.com/a/55669949/156458.
jps
通过扫描/tmp/hsperfdata_
目录查找正在运行的Java 进程.每个基于 HotSpot 的 Java 进程都会在此目录中创建一个文件,其名称与进程 ID 相同.
文件 /tmp/hsperfdata_
包含 JVM 导出的各种计数器.这些计数器可以由外部进程读取.这正是 jstat
的工作原理.我在 JavaMagazine 文章中描述了 jvmstat 性能计数器一个>.
所以,jstat
总是可以读取本地 Java 进程的计数器,但是为了能够监控远程机器,jstatd
需要运行.
jmap
、jstack
和 jinfo
使用动态附加机制.这些实用程序通过 UNIX 域套接字连接到目标 JVM,并将相应的命令发送到 JVM.该命令由远程 JVM 本身执行.在此答案中查找有关动态附加的更多信息并在此演示文稿中.
How does jps
get information about all the local java
processes?
Does it connect to some local server process to fetch the information?
How do jinfo, jstat, jmap
, and jstack
get information about a local java
process? Do they connect to some local server process(es) to fetch the information?
Is jstatd
only used for providing remote access to local java
processes, but not for providing local access to local java
processes?
I am running Ubuntu. My question comes from https://stackoverflow.com/a/55669949/156458.
jps
finds running Java processes by scanning through /tmp/hsperfdata_<username>
directory. Each HotSpot-based Java process creates a file in this directory with the name equal to the process ID.
The file /tmp/hsperfdata_<username>/<pid>
contains various counters exported by the JVM. These counters can be read by an external process. This is exactly how jstat
works. I described jvmstat performance counters in the JavaMagazine article.
So, jstat
can always read counters of a local Java process, but in order to be able to monitor a remote machine, jstatd
needs to be running.
jmap
, jstack
and jinfo
use Dynamic Attach mechanism. These utilities connect to the target JVM via UNIX-domain socket and send the corresponding command to the JVM. The command is executed by the remote JVM itself. Find more about Dynamic Attach in this answer and in this presentation.
这篇关于jps、jinfo、jstat、jmap和jstack如何获取本地Java进程的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!