性能监控

CPU:
top
top -H -p PID
printf %x PPID
jstack pid | grep UPID

vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
7 0 77920 25696 51880 738992 1 56 1145 566 0 4147 22 19 59 1
0 0 77920 25712 51904 739004 0 0 0 196 0 8823 16 18 67 0

r:可运行状态的线程,只是CPU当前不可用
b:等待io
cs: 系统正在处理上下文切换数目
us:用户占用CPU占比
sy:系统占用CPU占比
id:空闲的CPU占比

查看某个进程的CPU资源
top -H -p PID

MEMORY
[root@VM_16_6_centos ~]# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
3 0 0 79056 46908 550796 0 0 10 37 6 13 1 1 98 0 0
0 0 0 78808 46908 550804 0 0 8 0 251 504 2 1 97 0 0

swpd: 已用内存
free:空闲内存
buff:磁盘缓存内存
cache:文件缓存内存

free -h
total used free shared buffers
Mem: 1.7G 1.7G 22M 2.0M 65M
-/+ buffers/cache: 1.6G 86M
Swap: 1.0G 82M 942M
可用:86M,已用:1.6G


IO

iowait<20%

[root@VM_16_6_centos ~]# sar -d 2 2
Linux 3.10.0-1062.9.1.el7.x86_64 (VM_16_6_centos) 05/20/2020 _x86_64_ (1 CPU)

11:58:57 AM DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util
11:58:59 AM dev253-0 3.52 28.14 0.00 8.00 0.00 1.14 1.14 0.40
11:58:59 AM dev11-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

await 等待时间
svctm:服务时间
%util: 一秒有百分之几的时间在操作io


NETWORK IO

ac8257_demo:/ # netstat -lunp
netstat -lunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program Name
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1612/mdnsd
udp 0 0 0.0.0.0:39341 0.0.0.0:* 1612/mdnsd
udp6 0 0 :::47781 :::* 1612/mdnsd
udp6 0 0 ::ffff:127.0.0.1:10000 :::* 1867/com.txznet.txz
udp6 0 0 :::51174 :::* 1857/com.txznet.txzsetting

Recv-Q Send-Q等于0或者不高表示正常

[root@VM_16_6_centos ~]# netstat -su
IcmpMsg:
InType0: 12
InType3: 218
InType8: 1127250
InType11: 28
InType13: 1
OutType0: 1127250
OutType3: 26
OutType14: 1
Udp:
224577 packets received
9 packets to unknown port received.
0 packet receive errors
227687 packets sent
0 receive buffer errors
0 send buffer errors
UdpLite:
IpExt:
InNoRoutes: 13
InMcastPkts: 23756
OutMcastPkts: 23744
InOctets: 859160787
OutOctets: 1852953147
InMcastOctets: 859170
OutMcastOctets: 953642
InNoECTPkts: 9683941
InECT0Pkts: 6119
InCEPkts: 1926

packet receive errors 增加表示在丢包

[root@VM_16_6_centos ~]# cat /proc/net/snmp : grep Tcp
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
Tcp: 1 200 120000 -1 794219 245030 6439 2096 35 8264990 8951500 456124 69 6513 69
重传率=RetransSegs/OutSegs

原文地址:https://www.cnblogs.com/fengliting/p/13167534.html