16个linux监控命令 linux常用监控命令( 二 )


nid : 对应的linux操作系统下的tid,就是前面转化的16进制数字
tid: 这个应该是jvm的jmm内存规范中的唯一地址定位,如果你详细分析jvm的一些内存数据时用得上 , 我自己还没到那种程度 , 所以先放下
top命令
命令:top -Hp pid
结果显示:
和前面的效果一下,你可以实时的跟踪并获取指定进程中最耗cpu的线程 。再用前面的方法提取到对应的线程堆栈信息 。
判断I/O瓶颈
mpstat命令
命令:mpstat -P ALL 1 1000
结果显示:
注意一下这里面的%iowait列,CPU等待I/O操作所花费的时间 。这个值持续很高通常可能是I/O瓶颈所导致的 。
通过这个参数可以比较直观的看出当前的I/O操作是否存在瓶颈
几个常用的linux性能监控命令1. sar
每两秒刷新一次, 总共5次
[root@dbhost01 ~]# sar 2 5
Linux 2.6.32-504.el6.x86_64 (dbhost01)03/30/2018_x86_64_ (4 CPU)
02:53:15 PMCPU%user%nice%system%iowait%steal%idle
02:53:17 PMall0.660.001.720.660.0096.96
02:53:19 PMall1.340.003.350.800.0094.51
02:53:21 PMall0.790.001.591.450.0096.17
02:53:23 PMall0.400.002.000.800.0096.80
02:53:25 PMall0.660.001.850.790.0096.70
Average:all0.770.002.100.900.0096.23
2. top
top -a 按照内存降序
[root@dbhost01 ~]# top -a
top - 15:00:54 up6:04,1 user,load average: 0.31, 0.19, 0.11
Tasks: 306 total,1 running, 305 sleeping,0 stopped,0 zombie
Cpu(s):7.8%us,2.4%sy,0.0%ni, 88.9%id,0.8%wa,0.0%hi,0.1%si,0.0%st
Mem:4048972k total,3848576k used,200396k free,134844k buffers
Swap:4194300k total,1788k used,4192512k free,1835360k cached
3. vmstat
vmstat用于显示虚拟内存,内核线程,磁盘 , 系统进程,CPU活动等统计信息 。
需要安装sysstat工具 。
[root@dbhost01 ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
rbswpdfreebuffcachesisobiboincs us sy id wa st
201788 202508 135064 18359200032269627612 9510
[root@dbhost01 ~]#
[root@dbhost01 ~]# vmstat 2 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
rbswpdfreebuffcachesisobiboincs us sy id wa st
001788 202336 135068 18360000032269727612 9510
001788 202624 135068 1836000002529 4012 668201 9810
001788 202624 135072 1836004005787 4003 668501 9810
101788 202508 135072 1836004005733 4402 735311 9800
001788 202540 135076 1836004003347 4002 667401 9810
4. lsof(list open files)
[root@dbhost01 ~]# lsof | grep 1521
certmonge2348root16rFIFO0,80t015212 pipe
certmonge2348root18rFIFO0,80t015218 pipe
gipcd.bin2754grid109uunix 0xffff8801391521800t036936 socket
5. tcpdump
tcpdump -i eth1
15:24:28.777779 IP dbhost01.ssh192.168.2.82.50990: Flags [P.], seq 393080:393596, ack 105, win 148, options [nop,nop,TS val 22996360 ecr 2443327], length 516
15:24:28.777809 IP dbhost01.ssh192.168.2.82.50990: Flags [P.], seq 393080:393596, ack 105, win 148, options [nop,nop,TS val 22996360 ecr 2443327], length 516
15:24:28.778976 IP dbhost01.ssh192.168.2.82.50990: Flags [P.], seq 393596:393968, ack 105, win 148, options [nop,nop,TS val 22996361 ecr 2443327], length 372
15:24:28.779011 IP dbhost01.ssh192.168.2.82.50990: Flags [P.], seq 393596:393968, ack 105, win 148, options [nop,nop,TS val 22996361 ecr 2443327], length 372
15:24:28.779013 IP 192.168.2.82.50990dbhost01.ssh: Flags [.], ack 393968, win 16652, options [nop,nop,TS val 2443327 ecr 22996360], length 0
15:24:28.779481 IP dbhost02-priv.23602dbhost01-priv.24271: UDP, length 556
15:24:28.779585 IP dbhost01-priv.24271dbhost02-priv.23602: UDP, length 80
15:24:28.779909 IP dbhost01-priv.24271dbhost02-priv.23602: UDP, length 80
15:24:28.780584 IP dbhost01.ssh192.168.2.82.50990: Flags [P.], seq 393968:394724, ack 105, win 148, options [nop,nop,TS val 22996362 ecr 2443327], length 756

推荐阅读