This commit is contained in:
Xingyu Wang 2021-10-07 10:32:10 +08:00
parent be3b47c87b
commit ee82ce9853
2 changed files with 104 additions and 122 deletions

View File

@ -1,122 +0,0 @@
[#]: subject: "Monitor your Java on Linux with jconsole"
[#]: via: "https://opensource.com/article/21/10/monitor-java-linux-jconsole"
[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss"
[#]: collector: "lujun9972"
[#]: translator: "wxy"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Monitor your Java on Linux with jconsole
======
How to use the Java monitoring and management console included in the
Java Development Kit.
![Puzzle pieces coming together to form a computer screen][1]
The Java Development Kit (JDK) provides binaries, tools, and compilers for the development of Java applications. One helpful tool included is jconsole.
To demonstrate, I will use the WildFly J2EE application server, which is part of the JBOSS open source application server project. First, I start up a standalone instance.
```
~/wildfly/24.0.1/bin$ ./standalone.sh
=========================================================================
  JBoss Bootstrap Environment
  JBOSS_HOME: /home/alan/wildfly/24.0.1
  JAVA: /usr/lib/jvm/java-11-openjdk-11.0.11.0.9-5.fc34.x86_64/bin/java
```
Now, in another terminal, I type `jconsole`.
```
$ jconsole
```
Upon launching, jconsole lists local instances. Select Local Process, then select the name of the process and click Connect. That is all it takes to connect and begin using jconsole with a running Java Virtual Machine (JVM).
![jconsole new connection screen with local processes][2]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
### Overview
The Java Monitoring and Management Console shows the process identifier (PID) at the top of the dashboard. The Overview tab has four graphs to show the vitals for Heap Memory Usage, Threads, Classes, and CPU Usage.
![jconsole dashboard showing heap memory usage, threads, classes, and CPU usage][4]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
The tabs along the top provide more detailed views of each area.
### Memory
The Memory tab displays graphs of various aspects of the memory being used by the JVM. The amount of the server system memory allocated to the JVM is called the heap. This screen also provides details about usage by the internal components of the heap, such as the Eden Space, Old Gen, and the Survivor Space. You can manually request a garbage collection action as well.
![jconsole memory tab][5]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
### Threads
The Threads tab shows how many threads are running. You can also manually check for deadlocks.
![jconsole thread dashboard showing number of threads over time and a scrolling list of threads][6]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
### Classes
The classes tab tells you how many classes are loaded and how many have been unloaded.
![jconsole classes tab showing number of loaded classes over time][7]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
### VM Summary
The VM Summary tab provides many details about the application and the host system. You can learn which operating system and architecture you are on, the total amount of system memory, the number of CPUs, and even swap space.
![jconsole VMsummary tab ][8]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
Further details about the JVM shown in the summary include current and maximum heap size and information about the garbage collectors in use. The bottom pane lists all of the arguments passed to the JVM.
### MBeans
The last tab, MBeans, lets you drill down through all of the MBeans to view attributes and values for each.
![MBeans tab][9]
(Alan Formy-Duvall, [CC BY-SA 4.0][3])
### Conclusion
Java has been around a long time, and it continues to power millions of systems worldwide. Plenty of development environments and monitoring systems are available, but having a tool like jconsole included in the base kit can be highly valuable.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/10/monitor-java-linux-jconsole
作者:[Alan Formy-Duval][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/alanfdoss
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://opensource.com/sites/default/files/uploads/jconsole_new_connection_local.png (new connection)
[3]: https://creativecommons.org/licenses/by-sa/4.0/deed.ast
[4]: https://opensource.com/sites/default/files/uploads/jconsole_tab_overview.png (tab overview)
[5]: https://opensource.com/sites/default/files/uploads/jconsole_tab_memory.png (memory tab)
[6]: https://opensource.com/sites/default/files/uploads/jconsole_tab_threads.png (threads tab)
[7]: https://opensource.com/sites/default/files/uploads/jconsole_tab_classes.png (classes tab)
[8]: https://opensource.com/sites/default/files/uploads/jconsole_tab_vm-summary.png (VMsummary tab )
[9]: https://opensource.com/sites/default/files/uploads/jconsole_tab_mbeans.png (MBeans tab)

View File

@ -0,0 +1,104 @@
[#]: subject: "Monitor your Java on Linux with jconsole"
[#]: via: "https://opensource.com/article/21/10/monitor-java-linux-jconsole"
[#]: author: "Alan Formy-Duval https://opensource.com/users/alanfdoss"
[#]: collector: "lujun9972"
[#]: translator: "wxy"
[#]: reviewer: "wxy"
[#]: publisher: " "
[#]: url: " "
用 jconsole 在 Linux 上监控你的 Java
======
> 如何使用 Java 开发工具包中的 Java 监控和管理控制台。
![拼图拼成的电脑屏幕][1]
Java 开发工具包JDK提供了开发 Java 应用程序的二进制文件、工具和编译器。其中一个有用的工具是 `jconsole`
为了演示,我将使用 WildFly J2EE 应用服务器,它是 JBOSS 开源应用服务器项目的一部分。首先,我启动了一个独立的实例。
```
~/wildfly/24.0.1/bin$ ./standalone.sh
=========================================================================
  JBoss Bootstrap Environment
  JBOSS_HOME: /home/alan/wildfly/24.0.1
  JAVA: /usr/lib/jvm/java-11-openjdk-11.0.11.0.9-5.fc34.x86_64/bin/java
```
现在,在另一个终端,我输入 `jconsole`
```
$ jconsole
```
启动后jconsole 会列出本地实例。选择“<ruby>本地进程<rt>Local Process</rt></ruby>”,然后选择进程的名称并点击“<ruby>连接<rt>Connect</rt></ruby>”。这就是连接并开始使用运行中的 Java 虚拟机JVM的 jconsole 的全部过程。
![jconsole 与本地进程的新连接屏幕][2]
### 概述
这个 Java 监控和管理控制台在仪表板的顶部显示进程标识符PID。“<ruby>概述<rt>Overview</rt></ruby>”标签有四个图表,显示“<ruby>堆内存使用情况<rt>Heap Memory Usage</rt></ruby>”、“<ruby>线程<rt>Threads</rt></ruby>”、“<ruby><rt>Classes</rt></ruby>”和“<ruby>CPU 使用情况<rt>CPU Usage</rt></ruby>”的重要信息。
![jconsole 仪表板显示堆内存使用量、线程、类和 CPU 使用量][4]
沿着顶部的标签提供每个区域的更详细的视图。
### 内存
<ruby>内存<rt>Memory</rt></ruby>”标签显示 JVM 所使用的内存的各个方面的图表。分配给 JVM 的服务器系统内存的数量被称为“<ruby><rt>Heap</rt></ruby>”。这个屏幕还提供了关于堆的内部组件使用情况的详细信息,例如 Eden Space、Old Gen 和 Survivor Space。你也可以手动请求一个垃圾收集动作。
![jconsole 内存标签][5]
### 线程
<ruby>线程<rt>Threads</rt></ruby>”标签显示有多少线程在运行。你也可以手动检查是否存在死锁。
![jconsole 线程仪表板显示了随时间变化的线程数量和滚动的线程列表][6]
### 类
<ruby><rt>Classes</rt></ruby>”标签告诉你有多少类被加载,有多少被卸载。
![jconsole 类标签显示随着时间推移加载的类数量][7]
### 虚拟机摘要
<ruby>虚拟机摘要<rt>VM Summary</rt></ruby>”标签提供了许多关于应用程序和主机系统的细节。你可以了解你所处的操作系统和架构、系统内存总量、CPU 数量,甚至交换空间。
![jconsole 虚拟机摘要标签][8]
摘要中显示的关于 JVM 的进一步细节,包括当前和最大的堆大小以及正在使用的垃圾收集器的信息。底部的窗格列出了传递给 JVM 的所有参数。
### MBeans
最后一个标签MBeans让你通过所有的 MBeans 向下钻取,以查看每个 MBeans 的属性和值。
![MBeans 标签][9]
### 总结
Java 已经存在了很长时间,它将继续为全球数百万的系统提供动力。有很多开发环境和监控系统可以使用,但在基本工具包中包含像 `jconsole` 这样的工具会非常有价值。
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/10/monitor-java-linux-jconsole
作者:[Alan Formy-Duval][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/alanfdoss
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://opensource.com/sites/default/files/uploads/jconsole_new_connection_local.png (new connection)
[3]: https://creativecommons.org/licenses/by-sa/4.0/deed.ast
[4]: https://opensource.com/sites/default/files/uploads/jconsole_tab_overview.png (tab overview)
[5]: https://opensource.com/sites/default/files/uploads/jconsole_tab_memory.png (memory tab)
[6]: https://opensource.com/sites/default/files/uploads/jconsole_tab_threads.png (threads tab)
[7]: https://opensource.com/sites/default/files/uploads/jconsole_tab_classes.png (classes tab)
[8]: https://opensource.com/sites/default/files/uploads/jconsole_tab_vm-summary.png (VMsummary tab )
[9]: https://opensource.com/sites/default/files/uploads/jconsole_tab_mbeans.png (MBeans tab)