进程级别统计工具ps、top、pmap
pmap:将进程的内存段和使用统计一起列出。
系统级别统计工具vmstat、mpstat、iostat、netstat、sar
vmstat:虚拟内存和物理内存统计工具;
mpstat:每个cpu的使用情况;
iostat:每个磁盘io的使用情况,由块设备接口报告;
netstat:网络接口统计;
sar:各种各样的统计,能归档历史数据。
ethtool检查是否支持全双工
ethtool程序可用于查询是否支持全双工,以及是否正在执行全双工操作,以及相关设置等。
ethtool ens32
Settings for ens32:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
ens32是网卡设备,Supported link modes支持的模式,Speed: 1000Mb/s Duplex: Full表示速率为1000Mb/s的全双工工作模式
网络转包工具tcpdump
centOS下安装yum install tcpdump
抓取8080端口的包
tcpdump port 8080
将抓包写到文件中
tcpdump -w filename
网络状态监控工具SS(socket statistics)
centos系统下,SS指令为系统自带,无需安装。
监听udp所有端口
ss -uln
参考:https://blog.csdn.net/yuwen_dai/article/details/78467686
查看带宽占用情况iftop
iftop是一款实时流量监控工具,监控TCP/IP连接等,缺点就是无报表功能。必须以root身份才能运行。
centOS下安装
CentOS上安装所需依赖包:
yum install -y gcc flex byacc libpcap ncurses ncurses-devel libpcap-devel tcpdump
yum安装
yum install iftop
下载源码并编译安装
# wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz
# tar xvf iftop-0.17.tar.gz
# cd iftop-0.17
# ./configure --prefix=/usr/local/iftop
# make
# make install
# chmod 700 /usr/local/sbin/iftop #修改IFTOP权限
iftop命令可以按ip跟踪网络宽带占用情况
参考:https://blog.csdn.net/qq_34642668/article/details/80974876
建立远程SSH隧道
实用ssh命令建立:
ssh -CfNg -L 8080:10.185.258.69:80 root@10.115.219.230
可以将10.185.258.69的80端口映射到本地的8080端口访问。
在Xshell工具可以通过设置转移规则配置ssh隧道。
利用pstack 和 strace分析程序
pstack 打印进程或者线程的栈信息
strace 统计每一步系统调用花费的时间
查找进程的pid
ps -aux | grep nws
打印出171211进程下所有的线程栈信息
pstack 171211
跟踪171211进程中的171264线程系统调用, 将输出的信息保存在output.txt中
strace -o output.txt -T -tt -e trace=all -p 171264
参考:https://blog.csdn.net/lotluck/article/details/77943152
du
du -lh --max-depth=1 : 查看当前目录下一级子文件和子目录占用的磁盘容量。
#检查D 状态(Uninterruptible Sleep)的进程
Linux上的 load average 除了包括正在使用CPU的进程数量和正在等待 CPU 的进程数量之外,还包括 uninterruptible sleep 的进程数量。通常等待 IO 设备、等待网络的时候,进程会处于 uninterruptible sleep 状态。大量D状态的进程会造成upc负载虚高。只有处于可运行状态(Runnable)的进程可以接受终止信号( kill 信号),D状态的进程不是可运行状态,低版本的linux可能无法kill掉。只能重启机器。
检查D状态进程命令:
ps -aux | awk '$8 == "D"'