Process Monitor Dashboard
What This Does
A real-time terminal dashboard for monitoring system processes and resource usage. Provides a live, updating view of CPU, memory, disk, network, and running processes—all within your terminal.
Key features:
- - Real-time CPU monitoring - Overall usage + per‑core breakdown
- Memory dashboard - RAM usage, swap, detailed memory stats
- Disk I/O & usage - Read/write rates, free space per filesystem
- Network activity - Upload/download speeds, connections
- Process list - Top processes by CPU/memory, with sorting options
- Refresh control - Adjustable update interval (1–10 seconds)
- Color‑coded alerts - Highlight high resource usage
- Lightweight - Minimal overhead, runs in background
How To Use
Start the dashboard:
CODEBLOCK0
Monitor with custom interval (3 seconds):
CODEBLOCK1
Get a single snapshot (no continuous updates):
CODEBLOCK2
List top N processes by CPU:
CODEBLOCK3
List top N processes by memory:
CODEBLOCK4
Monitor a specific process by PID:
CODEBLOCK5
Full command reference:
CODEBLOCK6
Commands
- -
dashboard: Start interactive real‑time dashboard
-
--interval: Refresh interval in seconds (default: 2)
-
--simple: Simplified view (no per‑core/disk details)
-
--log: Also write metrics to a log file
- -
snapshot: Print a one‑time system snapshot
-
--json: Output as JSON for scripting
- -
top: Show top processes
-
--by: Sort by
cpu,
memory,
disk,
name (default: cpu)
-
--limit: Number of processes to show (default: 10)
-
--user: Filter by username
-
--json: Output as JSON
- -
monitor: Monitor a specific process
-
--pid: Process ID to monitor (required)
-
--interval: Refresh interval (default: 2)
-
--watch: Watch for process creation/termination
- -
stats: Show system‑wide statistics
-
--cpu: CPU details only
-
--memory: Memory details only
-
--disk: Disk details only
-
--network: Network details only
-
--json: Output as JSON
- -
alert: Check for resource alerts
-
--threshold-cpu: CPU alert threshold % (default: 90)
-
--threshold-memory: Memory alert threshold % (default: 85)
-
--threshold-disk: Disk alert threshold % (default: 90)
Output Examples
Dashboard view (sample):
CODEBLOCK7
JSON snapshot (via --json):
CODEBLOCK8
Installation Notes
Requires Python 3.6+ and psutil library. Install with:
CODEBLOCK9
On most systems, psutil is available via package managers:
CODEBLOCK10
Limitations
- - Terminal size - Dashboard optimized for terminals ≥ 80 columns
- Refresh rate - Very fast intervals (<1s) may cause high CPU
- Platform support - Best on Linux/macOS; Windows support limited
- Process details - Some process information may require root
- Historical data - No built‑in long‑term trending (single‑session only)
- No remote monitoring - Only monitors the local system
- No alert actions - Only displays warnings, doesn’t auto‑resolve issues
Security Considerations
- - Only reads system metrics (no writes or modifications)
- Doesn’t require root/sudo for basic operation
- No network listening or external connections
- All data stays local; no telemetry
- Process listing may reveal running applications (same as
ps/top)
Examples
Basic dashboard (2‑second updates):
CODEBLOCK11
Lightweight dashboard (simple view, 3‑second updates):
CODEBLOCK12
Get a JSON snapshot for scripting:
CODEBLOCK13
Find top 5 memory‑hungry processes:
CODEBLOCK14
Monitor a specific web server:
CODEBLOCK15
Check for resource alerts:
CODEBLOCK16
进程监控仪表盘
功能说明
一个用于监控系统进程和资源使用情况的实时终端仪表盘。在终端内提供CPU、内存、磁盘、网络和运行进程的实时更新视图。
主要特性:
- - 实时CPU监控 - 总体使用率 + 每核心详细数据
- 内存仪表盘 - RAM使用率、交换分区、详细内存统计
- 磁盘I/O与使用率 - 读写速率、各文件系统剩余空间
- 网络活动 - 上传/下载速度、连接数
- 进程列表 - 按CPU/内存排序的进程,支持排序选项
- 刷新控制 - 可调节更新间隔(1-10秒)
- 颜色编码告警 - 高亮显示高资源使用率
- 轻量级 - 资源占用低,可后台运行
使用方法
启动仪表盘:
bash
./scripts/main.py dashboard
自定义间隔监控(3秒):
bash
./scripts/main.py dashboard --interval 3
获取单次快照(不持续更新):
bash
./scripts/main.py snapshot
按CPU列出前N个进程:
bash
./scripts/main.py top --by cpu --limit 10
按内存列出前N个进程:
bash
./scripts/main.py top --by memory --limit 10
按PID监控特定进程:
bash
./scripts/main.py monitor --pid 1234
完整命令参考:
bash
./scripts/main.py help
命令说明
- --interval:刷新间隔(秒,默认:2)
- --simple:简化视图(不显示每核心/磁盘详情)
- --log:同时将指标写入日志文件
- --json:以JSON格式输出,便于脚本处理
- --by:按cpu、memory、disk、name排序(默认:cpu)
- --limit:显示进程数量(默认:10)
- --user:按用户名筛选
- --json:以JSON格式输出
- --pid:要监控的进程ID(必填)
- --interval:刷新间隔(默认:2)
- --watch:监控进程创建/终止
- --cpu:仅显示CPU详情
- --memory:仅显示内存详情
- --disk:仅显示磁盘详情
- --network:仅显示网络详情
- --json:以JSON格式输出
- --threshold-cpu:CPU告警阈值%(默认:90)
- --threshold-memory:内存告警阈值%(默认:85)
- --threshold-disk:磁盘告警阈值%(默认:90)
输出示例
仪表盘视图(示例):
─────────────────────────────────────────────────────
系统监控 | 刷新间隔:2秒 | 2026‑03‑16 10:30:00 UTC
─────────────────────────────────────────────────────
CPU: ███████░░░ 72% 内存: █████████░ 92%(8.2/12 GB)
核心0:65% 核心1:78% 核心2:70% 核心3:75%
进程排行(按CPU):
PID 用户 CPU% 内存% 命令
1234 alice 45.2 12.3 python3 /app/server.py
5678 bob 22.1 5.8 /usr/bin/node index.js
9101 root 10.5 0.3 systemd-journal
磁盘:/ █████░░░░ 52% 剩余 网络:▲ 1.2 MB/s ▼ 4.5 MB/s
─────────────────────────────────────────────────────
JSON快照(通过--json):
json
{
timestamp: 2026-03-16T10:30:00Z,
cpu: {
total_percent: 72.5,
per_core: [65.2, 78.1, 70.3, 75.0],
load_average: [1.2, 1.5, 1.8]
},
memory: {
total_gb: 12.0,
used_gb: 8.2,
percent: 68.3,
swap
usedgb: 0.5
},
processes: [
{pid: 1234, name: python3, cpu
percent: 45.2, memorypercent: 12.3}
]
}
安装说明
需要Python 3.6+和psutil库。使用以下命令安装:
bash
pip install psutil
在大多数系统上,psutil可通过包管理器获取:
bash
Debian/Ubuntu
sudo apt install python3-psutil
RHEL/CentOS
sudo yum install python3-psutil
macOS
brew install psutil
限制说明
- - 终端尺寸 - 仪表盘优化适用于≥80列的终端
- 刷新频率 - 极短间隔(<1秒)可能导致高CPU占用
- 平台支持 - 在Linux/macOS上效果最佳;Windows支持有限
- 进程详情 - 部分进程信息可能需要root权限
- 历史数据 - 无内置长期趋势记录(仅限单次会话)
- 不支持远程监控 - 仅监控本地系统
- 无告警操作 - 仅显示警告,不自动解决问题
安全说明
- - 仅读取系统指标(不进行写入或修改)
- 基本操作无需root/sudo权限
- 不监听网络或建立外部连接
- 所有数据保留在本地;无遥测功能
- 进程列表可能显示正在运行的应用程序(与ps/top相同)
使用示例
基本仪表盘(2秒更新):
bash
./scripts/main.py dashboard
轻量级仪表盘(简化视图,3秒更新):
bash
./scripts/main.py dashboard --simple --interval 3
获取JSON快照用于脚本处理:
bash
./scripts/main.py snapshot --json > system.json
查找内存占用最高的5个进程:
bash
./scripts/main.py top --by memory --limit 5
监控特定Web服务器:
bash
./scripts/main.py monitor --pid $(pgrep -f nginx) --interval 5
检查资源告警:
bash
./scripts/main.py alert --threshold-cpu 95 --threshold-memory 90