标签:des clu agent 状态 ber sheet cmd option 情况下
root @ master ? ~ kubectl top pod -n irm-server
NAME CPU(cores) MEMORY(bytes)
test-ecd-server-56b77d9fbb-zfctt 1m 1529Mi
test-flow-server-b477756f-2s5bc 1m 3006Mi
test-huishi-api-86dcfdb7c5-jtcpt 0m 1829Mi
test-huishi-message-5d4b456b88-n8xl5 241m 344Mi
test-huishi-schedule-bc5f5d4d5-z22gq 3m 510Mi
test-huishi-server-6f875487d7-9rzpd 44m 1483Mi
test-irm-bd9444948-rwtgn 1m 1270Mi
test-irm-task-89f65f5bd-zht2x 0m 1282Mi
test-order-server-5fcc5575bd-67c4r 32m 1066Mi
test-payment-6df4459864-5d8xl 1m 634Mi
test-urule-54f4b8f84f-l5xbm 1m 2382Mi
查看具体某一个pod
root @ master ? ~ kubectl top pod test-huishi-server-6f875487d7-9rzpd -n irm-server
NAME CPU(cores) MEMORY(bytes)
test-huishi-server-6f875487d7-9rzpd 36m 1489Mi
root @ master ? ~ kubectl top nodes -n irm-server
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master 225m 9% 2853Mi 25%
node1 219m 3% 18990Mi 65%
node11 61m 6% 4236Mi 31%
node12 2344m 36% 27839Mi 101%
node2 76m 7% 7950Mi 59%
node4 106m 10% 8151Mi 61%
node5 123m 12% 4877Mi 92%
node6 129m 12% 5614Mi 42%
node7 58m 5% 3738Mi 28%
node8 132m 6% 9098Mi 57%
node9 60m 6% 3017Mi 22%
查看具体某一个node
root @ master ? ~ kubectl top nodes node1 -n irm-server
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
node1 222m 3% 19009Mi 65%
上面使用nodes,node都可以
root @ master ? ~ kubectl exec test-huishi-server-6f875487d7-9rzpd -it sh -n irm-server
/home # jps 1
sh: jps: not found
/home # jstack 1
sh: jstack: not found
/home # exit
command terminated with exit code 127
docker容器内部没有jstack
命令
找到具体pod所在的节点,进入使用docker命令查看具体的信息
[root@node1 ~]# docker ps -a |grep huishi-server
73c1189ddd0e 18.16.200.191:5000/test/huishi-server "/bin/sh -c 'java $J…" 20 hours ago Up 20 hours k8s_test-huishi-server_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0
ed1a36493259 gcr.io/google_containers/pause-amd64:3.0 "/pause" 20 hours ago Up 20 hours k8s_POD_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0
[root@node1 ~]# docker top 73c1189ddd0e
UID PID PPID C STIME TTY TIME CMD
root 3439 3416 0 Dec18 ? 00:11:41 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -Xms1024M -Duser.timezone=GMT+08 -Dfile.encoding=UTF-8 -javaagent:/data/jacocoagent.jar=includes=*,output=file,append=true,destfile=/data/log/huishi-server/jacoco.exec -jar /home/huishi-server.jar
docker stats 命令用来返回运行中的容器的实时数据流,
默认情况下,stats 使用参数-a或者--all,命令会每隔 1 秒钟刷新一次输出的内容直到你按下 ctrl + c。
[root@node1 ~]# docker stats -a
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
1ad181f01c76 k8s_POD_test-capital-schedule-6468f8774f-2s6dd_common-server_78d133b9-21f7-11ea-932e-525400506c6a_0 0.00% 1.766MiB / 30.89GiB 0.01% 0B / 0B 0B / 0B 1
73c1189ddd0e k8s_test-huishi-server_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 0.04% 1.178GiB / 2GiB 58.88% 0B / 0B 0B / 254kB 68
ed1a36493259 k8s_POD_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 0.00% 1.25MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
05c08624b3d7 k8s_POD_test-p2p-bms-7db78b7c46-9vvnt_common-server_759c4604-1c7e-11ea-932e-525400506c6a_0 0.00% 1.543MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
9013e1d0a243 k8s_POD_test-institution-6569774458-t8sk9_institution-server_f35e22c0-1a2e-11ea-932e-525400506c6a_0 0.00% 1.578MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
输出内容:
[CONTAINER]:以短格式显示容器的 ID。
[CPU %]:CPU 的使用情况。
[MEM USAGE / LIMIT]:当前使用的内存和最大可以使用的内存。
[MEM %]:以百分比的形式显示内存使用情况。
[NET I/O]:网络 I/O 数据。
[BLOCK I/O]:磁盘 I/O 数据。
[PIDS]:PID 号。
如果不想持续的监控容器使用资源的情况,可以通过 --no-stream 选项只输出当前的状态:
[root@node1 ~]# docker stats --no-stream
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
1ad181f01c76 k8s_POD_test-capital-schedule-6468f8774f-2s6dd_common-server_78d133b9-21f7-11ea-932e-525400506c6a_0 0.00% 1.766MiB / 30.89GiB 0.01% 0B / 0B 0B / 0B 1
73c1189ddd0e k8s_test-huishi-server_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 1.72% 1.178GiB / 2GiB 58.89% 0B / 0B 0B / 254kB 68
ed1a36493259 k8s_POD_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 0.00% 1.25MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
05c08624b3d7 k8s_POD_test-p2p-bms-7db78b7c46-9vvnt_common-server_759c4604-1c7e-11ea-932e-525400506c6a_0 0.00% 1.543MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
9013e1d0a243 k8s_POD_test-institution-6569774458-t8sk9_institution-server_f35e22c0-1a2e-11ea-932e-525400506c6a_0 0.00% 1.578MiB / 30.89GiB 0.00% 0B / 0B 0B / 0B 1
366e27c0265f k8s_debug-agent_debug-agent-h88sf_kube-system_263ac99f-133f-11ea-932e-525400506c6a_0 0.00% 10.3MiB / 30.89GiB 0.03% 0B / 0B 0B / 0B 14
格式化输出
[root@node1 ~]# docker stats --no-stream --format "table {{.Container}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
CONTAINER NAME CPU % MEM USAGE / LIMIT
1ad181f01c76 k8s_POD_test-capital-schedule-6468f8774f-2s6dd_common-server_78d133b9-21f7-11ea-932e-525400506c6a_0 0.00% 1.766MiB / 30.89GiB
73c1189ddd0e k8s_test-huishi-server_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 0.32% 1.178GiB / 2GiB
ed1a36493259 k8s_POD_test-huishi-server-7f4f5c5f8c-kqzrw_irm-server_2bc27a95-216a-11ea-932e-525400506c6a_0 0.00% 1.25MiB / 30.89GiB
05c08624b3d7 k8s_POD_test-p2p-bms-7db78b7c46-9vvnt_common-server_759c4604-1c7e-11ea-932e-525400506c6a_0 0.00% 1.543MiB / 30.89GiB
9013e1d0a243 k8s_POD_test-institution-6569774458-t8sk9_institution-server_f35e22c0-1a2e-11ea-932e-525400506c6a_0 0.00% 1.578MiB / 30.89GiB
366e27c0265f k8s_debug-agent_debug-agent-h88sf_kube-system_263ac99f-133f-11ea-932e-525400506c6a_0 0.05% 10.3MiB / 30.89GiB
上面的命令中我们只输出了 Name, CPUPerc 和 Memusage 三列。
下面是自定义的格式中可以使用的所有占位符:
.Container 根据用户指定的名称显示容器的名称或 ID。
.Name 容器名称。
.ID 容器 ID。
.CPUPerc CPU 使用率。
.MemUsage 内存使用量。
.NetIO 网络 I/O。
.BlockIO 磁盘 I/O。
.MemPerc 内存使用率。
.PIDs PID 号。
有了这些信息我们就可以完全按照自己的需求或者是偏好来控制 docker stats 命令输出的内容了。
JSON格式输出
docker stats --no-stream --format "{\"container\":\"{{ .Container }}\",\"memory\":{\"raw\":\"{{ .MemUsage }}\",\"percent\":\"{{ .MemPerc }}\"},\"cpu\":\"{{ .CPUPerc }}\"}"
{"container":"1ad181f01c76","memory":{"raw":"1.766MiB / 30.89GiB","percent":"0.01%"},"cpu":"0.00%"}
{"container":"73c1189ddd0e","memory":{"raw":"1.178GiB / 2GiB","percent":"58.90%"},"cpu":"0.33%"}
{"container":"ed1a36493259","memory":{"raw":"1.25MiB / 30.89GiB","percent":"0.00%"},"cpu":"0.00%"}
{"container":"05c08624b3d7","memory":{"raw":"1.543MiB / 30.89GiB","percent":"0.00%"},"cpu":"0.00%"}
{"container":"9013e1d0a243","memory":{"raw":"1.578MiB / 30.89GiB","percent":"0.00%"},"cpu":"0.00%"}
{"container":"366e27c0265f","memory":{"raw":"10.3MiB / 30.89GiB","percent":"0.03%"},"cpu":"0.00%"}
{"container":"9f206bab70fd","memory":{"raw":"1.465MiB / 30.89GiB","percent":"0.00%"},"cpu":"0.00%"}
{"container":"7a34c4cb664f","memory":{"raw":"1.555MiB / 30.89GiB","percent":"0.00%"},"cpu":"0.00%"}
标签:des clu agent 状态 ber sheet cmd option 情况下
原文地址:https://www.cnblogs.com/hongdada/p/12066802.html