Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Linux 伺服器效能監控核心指令大全

編輯:Linux 系統常見問題解答

掌握以下指令,即可全方位掌握 Linux 伺服器 CPU、記憶體、磁碟 I/O、網路與程序資源使用狀況。

1. iostat - 磁碟 I/O 與 CPU 總覽

iostat          # 基本報表
iostat -x 2     # 每 2 秒顯示擴充統計(%util, await, svctm 等)

關鍵欄位:%iowait(CPU 等待 I/O 比例)、tps(每秒傳輸請求)、Blk_read/s、Blk_wrtn/s。

2. free - 記憶體使用摘要

free -m         # 以 MB 顯示
free -h         # 人類易讀單位

重點看 -/+ buffers/cache 行:真實可用記憶體 = free + buffers + cached。

3. /proc/meminfo - 記憶體詳細資訊

cat /proc/meminfo

包含 MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree, Dirty, Writeback, Slab 等細項。

4. mpstat - 多核心 CPU 狀態

mpstat -P ALL   # 顯示所有核心統計
mpstat -P 0     # 單核心詳細

欄位說明:%usr 用戶態、%sys 核心態、%iowait、%irq、%soft、%steal(虛擬化偷佔)、%idle。

5. netstat - 網路連線與協定統計

netstat -a      # 所有 socket
netstat -r      # 路由表
netstat -i      # 介面統計
netstat -s      # 協定統計

6. pmap - 程序記憶體對應

pmap <PID> | head -20   # 查看前 20 行映射
# 找出佔用記憶體最多的程序
ps -ef | grep nginx
pmap 19402

善用這組工具,快速定位效能瓶頸。

Copyright © Windows教程網 All Rights Reserved