欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 维修 > 常用 Linux 各资源指标监控示例(长期更新)

常用 Linux 各资源指标监控示例(长期更新)

2025/4/18 0:31:51 来源:https://blog.csdn.net/gumc123/article/details/140153550  浏览:    关键词:常用 Linux 各资源指标监控示例(长期更新)

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

码字不易,若觉得本文对你有用,欢迎点赞 👍、分享 🚀 ,相关技术热点时时看🔥🔥🔥​​​…


版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词