在Linux系统中,检查性能的常用命令和工具如下,按类别分类整理:
top
q
退出,1
显示多核CPU)。htop
(需安装)top
,支持颜色、树状视图和鼠标操作。vmstat 1
1
表示每秒刷新)。dstat
(需安装)mpstat -P ALL 1
sysstat
包)。sar -u 1
sysstat
,-u
显示全局使用率)。pidstat -u 1
free -h
-h
人类可读格式)。vmstat 1
si
(Swap In)、so
(Swap Out)判断内存是否不足。pmap -x <PID>
iostat -xz 1
-x
扩展统计,-z
忽略零值)。iotop
(需安装)top
,实时显示磁盘I/O占用高的进程。df -h
du -sh <目录>
netstat -tulnp
ss -tulnp
netstat
替代工具。sar -n DEV 1
iftop
(需安装)nload
(需安装)ps aux --sort=-%cpu
ps -efL
L
显示线程)。strace -p <PID>
perf top
linux-tools
。nmon
(需安装)glances
(需安装)sar
(需 sysstat
)journalctl -xe
dmesg
bash
top; vmstat 1; iostat -xz 1; dstat
sar
或配置 sysstat
定期收集数据。根据具体问题选择合适的工具,如CPU瓶颈用 mpstat
,内存问题用 free
和 vmstat
,I/O问题用 iostat
。