top
- 按1,分cpu显示核心
- 按c,显示command
nmon
- kernel查看contenx 上下文切换,如果切换次数过多,和中断数过多,【分析kafka消息】消息体小,没有pipeline
- 可以查看cpu的性能
- 查看网络
tcpflow
- tcpflow -ci eth0 port 80 # -c 表示输出到终端,-i 表示要监听的网卡端口
#过滤从主机 192.168.1.202 发出的流量并且端口号为 80:
tcpflow -i any src host 192.168.1.202 and port 80
# 过滤主机 192.168.1.202 端口为 80 或 443 的流量:
tcpflow -i en0 'host 192.168.1.202 and (port 80 or port 443)'
可以将 TCP 流保存在文件中:
tcpflow -r test.pcap [ test.pcap 这个是tcpdmp获得的文件,转成tcpflow的文件]
#这样我得到了两个文件:
#183.136.139.016.00080-192.168.199.146.49570
#192.168.199.146.49570-183.136.139.016.00080
ifconfig
- ifconfig需要重点查看 RX errors,这个可以查看到网卡是否正常
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.30.183.88 netmask 255.255.252.0 broadcast 10.30.183.255
ether 00:16:3e:04:6e:91 txqueuelen 1000 (Ethernet)
RX packets 422409291035 bytes 289311728713388 (263.1 TiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 304684224808 bytes 50776640919791 (46.1 TiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
dmesg
- dmesg -T //查看内核日志信息
- vim /var/log/messages 查看是否报错
- netstat -s //查看网络统计信息
- ss -s
[root@zkapp-admin-v3-01 test]# ss -s
Total: 1320 (kernel 3389)
TCP: 4433 (estab 124, closed 3777, orphaned 0, synrecv 0, timewait 3737/0), ports 0
Transport Total IP IPv6
* 3389 - -
RAW 0 0 0
UDP 5 4 1
TCP 656 654 2
INET 661 658 3
FRAG 0 0 0
- vmstat
[root@zkapp-admin-v3-01 ~]# 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 1234048 762040 15831708 0 0 3 103 0 0 11 2 87 0 0
2 0 0 1243540 762040 15831720 0 0 0 96 17154 13420 18 2 80 0 0
- iostat
[root@zkapp-admin-v3-01 test]# iostat -x 1
Linux 3.10.0-123.9.3.el7.x86_64 (zkapp-admin-v3-01) 12/14/2021 _x86_64_ (16 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
11.02 0.00 1.53 0.40 0.00 87.04
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
vda 0.00 2.16 0.13 1.82 1.96 174.43 181.45 0.01 4.71 6.39 4.59 1.15 0.22
vdb 0.07 166.49 1.97 171.81 43.63 1461.53 17.32 0.04 0.24 7.46 0.16 0.18 3.05
vdc 0.00 0.49 0.00 0.47 0.39 6.55 29.44 0.00 1.96 4.31 1.94 0.54 0.03
- iotop 查看io信息
- strace -p 28334 查看某个pid的系统调用
- perf #查找性能瓶颈
perf top可以实时查看当前系统进程函数占用率情况;
- free //buffers 是写缓存,cache 读缓存
[root@zkapp-admin-v3-01 test]# free -m
total used free shared buffers cached
Mem: 32013 31061 951 1756 743 15087
-/+ buffers/cache: 15231 16782
Swap: 0 0 0
- ps查看具体进程,具体线程耗cpu情况
[root@VM-16-2-centos ~]# ps -mp 11949 -o THREAD,tid,time
USER %CPU PRI SCNT WCHAN USER SYSTEM TID TIME
root 158 - - - - - - 1-01:15:49
root 26.7 19 - - - - 11949 04:16:30
root 0.1 19 - - - - 11999 00:01:05
root 0.0 19 - futex_ - - 12000 00:00:00
root 0.0 19 - futex_ - - 12001 00:00:00
root 0.0 19 - futex_ - - 12003 00:00:00
root 36.8 19 - - - - 12005 05:53:37
root 30.0 19 - futex_ - - 12006 04:48:25
root 33.3 19 - futex_ - - 12012 05:20:07
root 32.2 19 - futex_ - - 4185 04:45:16
root 33.1 19 - futex_ - - 26659 00:10:46