mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-30 15:33:59 +00:00
Add file descriptor info.
This commit is contained in:
3 files changed
+45
-5
No files matched your search
@@ -14,6 +14,7 @@ import com.taobao.text.ui.TableElement;
|
|||||||
import com.taobao.text.util.RenderUtil;
|
import com.taobao.text.util.RenderUtil;
|
||||||
|
|
||||||
import java.lang.management.*;
|
import java.lang.management.*;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -74,12 +75,27 @@ public class JvmCommand extends AnnotatedCommand {
|
|||||||
table.row("", "");
|
table.row("", "");
|
||||||
table.row(true, label("THREAD").style(Decoration.bold.bold()));
|
table.row(true, label("THREAD").style(Decoration.bold.bold()));
|
||||||
drawThreadTable(table);
|
drawThreadTable(table);
|
||||||
|
table.row("", "");
|
||||||
|
table.row(true, label("FILE-DESCRIPTOR").style(Decoration.bold.bold()));
|
||||||
|
drawFileDescriptorTable(table);
|
||||||
process.write(RenderUtil.render(table, process.width()));
|
process.write(RenderUtil.render(table, process.width()));
|
||||||
process.write(affect.toString()).write("\n");
|
process.write(affect.toString()).write("\n");
|
||||||
process.end();
|
process.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawFileDescriptorTable(TableElement table) {
|
||||||
|
table.row("MAX-FILE-DESCRIPTOR-COUNT", "" + invokeFileDescriptor(operatingSystemMXBean, "getMaxFileDescriptorCount"))
|
||||||
|
.row("OPEN-FILE-DESCRIPTOR-COUNT", "" + invokeFileDescriptor(operatingSystemMXBean, "getOpenFileDescriptorCount"));
|
||||||
|
}
|
||||||
|
private long invokeFileDescriptor(OperatingSystemMXBean os, String name) {
|
||||||
|
try {
|
||||||
|
final Method method = os.getClass().getDeclaredMethod(name);
|
||||||
|
method.setAccessible(true);
|
||||||
|
return (Long) method.invoke(os);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
private String toCol(Collection<String> strings) {
|
private String toCol(Collection<String> strings) {
|
||||||
final StringBuilder colSB = new StringBuilder();
|
final StringBuilder colSB = new StringBuilder();
|
||||||
if (strings.isEmpty()) {
|
if (strings.isEmpty()) {
|
||||||
|
|||||||
@@ -84,8 +84,14 @@ $ jvm
|
|||||||
|
|
||||||
THREAD COUNT 16
|
THREAD COUNT 16
|
||||||
DAEMON-COUNT 10
|
DAEMON-COUNT 10
|
||||||
LIVE-COUNT 18
|
PEAK-COUNT 18
|
||||||
STARTED-COUNT 19
|
STARTED-COUNT 19
|
||||||
|
DEADLOCK-COUNT 0
|
||||||
|
|
||||||
|
FILE-DESCRIPTOR
|
||||||
|
|
||||||
|
MAX-FILE-DESCRIPTOR-COUNT 10240
|
||||||
|
OPEN-FILE-DESCRIPTOR-COUNT 648
|
||||||
Affect cost in 2 ms.
|
Affect cost in 2 ms.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -93,5 +99,12 @@ Affect cost in 2 ms.
|
|||||||
|
|
||||||
* COUNT: the count of active threads
|
* COUNT: the count of active threads
|
||||||
* DAEMON-COUNT: the count of active daemon threads
|
* DAEMON-COUNT: the count of active daemon threads
|
||||||
* LIVE-COUNT: the maximum count of the live threads since JVM starts
|
* PEAK-COUNT: the maximum count of the live threads since JVM starts
|
||||||
* STARTED-COUNT: the total count of the created threads since JVM starts
|
* STARTED-COUNT: the total count of the created threads since JVM starts
|
||||||
|
* DEADLOCK-COUNT: the count of deadlock threads
|
||||||
|
|
||||||
|
|
||||||
|
### fileDescriptor-related
|
||||||
|
|
||||||
|
* MAX-FILE-DESCRIPTOR-COUNT:the count of max file descriptor JVM process can open
|
||||||
|
* OPEN-FILE-DESCRIPTOR-COUNT:the current count of file descriptor JVM process open
|
||||||
@@ -88,6 +88,11 @@ $ jvm
|
|||||||
STARTED-COUNT 19
|
STARTED-COUNT 19
|
||||||
DEADLOCK-COUNT 0
|
DEADLOCK-COUNT 0
|
||||||
|
|
||||||
|
FILE-DESCRIPTOR
|
||||||
|
|
||||||
|
MAX-FILE-DESCRIPTOR-COUNT 10240
|
||||||
|
OPEN-FILE-DESCRIPTOR-COUNT 648
|
||||||
|
|
||||||
Affect cost in 2 ms.
|
Affect cost in 2 ms.
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -95,5 +100,11 @@ Affect cost in 2 ms.
|
|||||||
|
|
||||||
* COUNT: JVM当前活跃的线程数
|
* COUNT: JVM当前活跃的线程数
|
||||||
* DAEMON-COUNT: JVM当前活跃的守护线程数
|
* DAEMON-COUNT: JVM当前活跃的守护线程数
|
||||||
* LIVE-COUNT: 从JVM启动开始曾经活着的最大线程数
|
* PEAK-COUNT: 从JVM启动开始曾经活着的最大线程数
|
||||||
* STARTED-COUNT: 从jvm启动开始总共启动过的线程次数
|
* STARTED-COUNT: 从JVM启动开始总共启动过的线程次数
|
||||||
|
* DEADLOCK-COUNT: JVM当前死锁的线程数
|
||||||
|
|
||||||
|
### 文件描述符相关
|
||||||
|
|
||||||
|
* MAX-FILE-DESCRIPTOR-COUNT:JVM进程最大可以打开的文件描述符数
|
||||||
|
* OPEN-FILE-DESCRIPTOR-COUNT:JVM当前打开的文件描述符数
|
||||||
Reference in new issue
Block a user