1、在 linux 中,查看指定进程下各线程运行情况
# ps 方式,查看 pid 为 776 的进程有哪些线程
ps -Tp 776
#> PID SPID TTY TIME CMD
#> 776 776 ? 00:00:01 zebra
#> 776 778 ? 00:00:00 RCU sweeper
#> 776 779 ? 00:00:00 zebra_dplane
#> 776 780 ? 00:00:00 zebra_opaque
#> 776 789 ? 00:00:00 zebra_apic
#> 776 790 ? 00:00:00 zebra_apic
#> 776 794 ? 00:00:00 zebra_apic
#> 776 798 ? 00:00:00 zebra_apic
#> 776 803 ? 00:00:00 zebra_apic
#> 776 806 ? 00:00:00 zebra_apic# top 方式,查看 pid 为 776 的进程下各线程资源使用情况
top -Hp 776
#> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
#> 776 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:01.16 zebra
#> 778 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 RCU sweeper
#> 779 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.01 zebra_dplane
#> 780 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_opaque
#> 789 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
#> 790 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
#> 794 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
#> 798 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
#> 803 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
#> 806 frr 15 -5 614592 1480 1480 S 0.0 0.1 0:00.00 zebra_apic
2、进程级、线程级资源(如 cpu、memory、disk)使用情况监控 pidstat
# 每隔 1s 打印一次该进程下各线程 cpu 使用情况
pidstat -u -p 8625 1
#> Linux 5.4.0-163-generic (ethNode) 09/25/23 _x86_64_ (8 CPU)
#> 11:15:16 UID PID %usr %system %guest %wait %CPU CPU Command
#> 11:15:17 0 8625 9.00 7.00 0.00 0.00 16.00 2 geth
#> 11:15:18 0 8625 17.00 2.00 0.00 0.00 19.00 2 geth
#> 11:15:19 0 8625 17.00 4.00 0.00 0.00 21.00 2 geth
#> 11:15:20 0 8625 22.00 9.00 0.00 0.00 31.00 2 geth# 选项说明
-u # cpu 资源
-r # memory 资源
-d # disk 资源
-t # 该进程下各线程资源使用情况
-p # 指定进程 ID
3、接口级网络流量监控 sar
sar -n DEV 1
#> Linux 5.4.0-163-generic (ethNode) 09/25/23 _x86_64_ (8 CPU)
#> 11:12:28 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
#> 11:12:29 eth0 677.00 709.00 212.16 197.84 0.00 0.00 0.00 0.17
#> 11:12:29 lo 4.00 4.00 0.88 0.88 0.00 0.00 0.00 0.00
4、磁盘级设备读写监控 iostat
iostat -x 1
#> Linux 5.4.0-163-generic (ethNode) 09/25/23 _x86_64_ (8 CPU)
#> Device r/s rkB/s rrqm/s %rrqm r_await rareq-sz w/s wkB/s wrqm/s %wrqm w_await wareq-sz d/s dkB/s drqm/s %drqm d_await dareq-sz aqu-sz %util
#> dm-0 1.53 47.64 0.00 0.00 2.17 31.11 4.18 20.08 0.00 0.00 1.88 4.80 0.02 32.91 0.00 0.00 0.38 1573.38 0.01 0.64
#> sda 1.26 47.69 0.27 17.88 1.16 37.87 3.56 19.52 0.62 14.91 1.40 5.49 0.02 40.29 0.00 0.00 0.39 1912.40 0.00 0.64
#> vda 505.13 7806.08 0.04 0.01 1.38 15.45 35.37 7464.75 2.00 5.35 82.61 211.03 0.79 3727.05 0.00 0.00 0.04 4688.18 3.35 37.43
码字不易,若觉得本文对你有用,欢迎点赞 👍、分享 🚀 ,相关技术热点时时看🔥🔥🔥…