问题描述
jps
如何获取有关所有本地java
进程的信息?它是否连接到某些本地服务器进程以获取信息?
How does jps
get information about all the local java
processes?Does it connect to some local server process to fetch the information?
jinfo, jstat, jmap
和jstack
如何获取有关本地java
进程的信息?他们是否连接到某些本地服务器进程以获取信息?
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?
jstatd
仅用于提供对本地java
进程的远程访问,而不用于提供对本地java
进程的本地访问吗?
Is jstatd
only used for providing remote access to local java
processes, but not for providing local access to local java
processes?
我正在运行Ubuntu.我的问题来自 https://stackoverflow.com/a/55669949/156458 .
I am running Ubuntu. My question comes from https://stackoverflow.com/a/55669949/156458.
推荐答案
jps
通过扫描/tmp/hsperfdata_<username>
目录查找正在运行的Java进程.每个基于HotSpot的Java进程都会在该目录中创建一个名称与该进程ID相同的文件.
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.
文件/tmp/hsperfdata_<username>/<pid>
包含JVM导出的各种计数器.这些计数器可以由外部进程读取.这正是jstat
的工作方式.我在 JavaMagazine文章中介绍了jvmstat性能计数器a>.
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.
因此,jstat
始终可以读取本地Java进程的计数器,但是为了能够监视远程计算机,必须运行jstatd
.
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
和jinfo
使用动态附加机制.这些实用程序通过UNIX域套接字连接到目标JVM,并将相应的命令发送到JVM.该命令由远程JVM本身执行.在此答案中找到有关动态附加的更多信息.并在此演示文稿中.
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进程的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!