Glances 是基於 Python 的跨平台系統監控工具,單一介面整合 CPU、記憶體、磁碟 I/O、網路、感測器、程序、Docker 容器等資訊,支援終端機模式、Web 模式、匯出 CSV/HTML、Client-Server 架構,是 top、htop、iotop、iftop 的最佳整合替代品。
# 安裝相依套件
pip install psutil pysensors hddtemp
# 安裝 Glances
pip install glances
# 或安裝含所有選用相依的完整版
pip install 'glances[all]'
git clone https://github.com/nicolargo/glances.git
cd glances
python setup.py install
# Debian/Ubuntu
apt-get install glances
# CentOS/RHEL (需 EPEL)
yum install glances
# Arch Linux
pacman -S glances
# Docker
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /:/host:ro -p 61208:61208 nicolargo/glances
| 參數 | 功能 |
|---|---|
-h / --help | 顯示說明並結束 |
-b | 網路速率以 Bytes/sec 顯示 (預設 bits/sec) |
-c @IP|host | Client 模式連線至 Glances 伺服器 |
-s | Server 模式啟動 (預設埠 61209) |
-p PORT | 指定 Client/Server TCP 埠號 |
-P password | 設定 Client/Server 密碼 |
-t sec | 重新整理間隔秒數 (預設 3 秒) |
-1 | 逐核心 CPU 模式啟動 |
-d | 停用磁碟 I/O 模組 |
-m | 停用掛載點模組 |
-n | 停用網路模組 |
-e | 啟用感測器模組 (需 pysensors) |
-y | 啟用 hddtemp 模組 (需 hddtemp daemon) |
-o HTML|CSV | 匯出格式 (配合 -f 指定輸出檔案/資料夾) |
-f file | 指定輸出檔案/資料夾路徑 |
-C file | 指定設定檔路徑 |
-z | 停用粗體顏色屬性 |
glancesglances -w → 瀏覽器開啟 https://localhost:61208glances -s -p 61209 -P mypasswordglances -c 192.168.1.100 -P mypasswordglances -o CSV -f /tmp/glances_export -t 5| 按鍵 | 功能 |
|---|---|
| q / Esc / Ctrl+C | 結束 |
| 1 | 切換逐核心/整體 CPU 檢視 |
| m | 依記憶體排序程序 |
| p | 依 CPU 排序程序 |
| i | 依 I/O 排序程序 |
| n | 依網路排序程序 |
| d | 切換磁碟 I/O 顯示 |
| s | 切換感測器顯示 |
| y | 切換硬碟溫度顯示 |
| f | 切換檔案系統顯示 |
| k | 終止程序 (輸入 PID) |
| Enter | 查看程序詳細資訊 |
預設設定檔:/etc/glances/glances.conf 或 ~/.config/glances/glances.conf。可調整門檻值 (CPU、記憶體、溫度警示顏色)、啟用/停用模組、設定預設輸出格式等。
Glances 以單一工具滿足 90% 系統監控需求,無論是本機排錯、遠端監控、自動化匯出分析,都是 Linux 維運人員的必備利器。