System Monitor Guide
系统监控指南

Understanding CPU, Memory, Load & Steal Time
理解 CPU、内存、负载和 Steal 时间

⚡ CPU Usage | CPU 使用率

English

CPU Usage shows the percentage of time the processor spends doing work.

Key metrics from top command:

  • us (user) - Time running user programs
  • sy (system) - Time running kernel operations
  • id (idle) - Time doing nothing
  • wa (wait) - Time waiting for I/O
  • st (steal) - Time stolen by hypervisor

中文

CPU 使用率显示处理器花费在工作上的时间百分比。

top 命令的关键指标:

  • us (用户) - 运行用户程序的时间
  • sy (系统) - 运行内核操作的时间
  • id (空闲) - 空闲时间
  • wa (等待) - 等待 I/O 的时间
  • st (偷取) - 被虚拟机监控程序抢占的时间
%Cpu(s): 26.5 us,  4.1 sy,  0.0 ni, 28.6 id,  0.0 wa,  0.0 hi,  0.0 si, 40.8 st

📊 Load Average | 负载平均值

English

Load average = number of processes waiting for CPU time.

The 3 numbers represent averages over 1 min, 5 min, 15 min.

Load ÷ CPU Count = Utilization Ratio
LoadMeaning (2 CPUs)
< 2.0CPUs not saturated
= 2.0Fully utilized
> 2.0Overloaded, processes waiting

中文

负载平均值 = 等待 CPU 时间的进程数量。

3 个数字分别代表 1 分钟、5 分钟、15 分钟的平均值。

负载 ÷ CPU 核心数 = 利用率
负载含义(2 核 CPU)
< 2.0CPU 未饱和
= 2.0完全利用
> 2.0过载,进程在等待
load average: 2.13, 3.86, 5.41
              ↑      ↑      ↑
           1 min  5 min  15 min  (trending down ↓ is good)

🔒 Steal Time | Steal 时间

English

Steal time (st) = CPU time the hypervisor took away from your VM to give to other VMs on the same physical host.

When your VM is ready to run but the hypervisor gives the CPU to another VM, that's "steal."

Common causes:

  • Burstable instances (t2/t3) - CPU credits exhausted
  • Oversubscribed host - Too many VMs competing
  • Noisy neighbors - Other VMs hogging resources

中文

Steal 时间 (st) = 虚拟机监控程序从你的虚拟机抢走的 CPU 时间,分配给同一物理主机上的其他虚拟机。

当你的虚拟机准备运行,但 hypervisor 把 CPU 分给了其他虚拟机,这就是 "steal"。

常见原因:

  • 可突发实例 (t2/t3) - CPU 积分用完
  • 主机超售 - 虚拟机太多,互相竞争
  • 吵闹的邻居 - 其他虚拟机占用过多资源
Physical Server (Host) 物理服务器 ├── Your VM (wants CPU) 你的虚拟机(需要 CPU) ├── Other VM 1 (wants CPU) 其他虚拟机 1 ├── Other VM 2 (wants CPU) 其他虚拟机 2 └── Hypervisor decides who gets CPU 虚拟机监控程序决定分配

🧠 Memory Usage | 内存使用

English

Memory usage from free -h command:

  • total - Total physical RAM
  • used - Memory in use by programs
  • free - Completely unused memory
  • buff/cache - Memory used for disk caching (can be freed)
  • available - Memory available for new programs

Tip: Look at "available", not "free" - Linux uses free memory for caching.

中文

free -h 命令显示的内存使用:

  • total - 物理内存总量
  • used - 程序使用的内存
  • free - 完全未使用的内存
  • buff/cache - 用于磁盘缓存的内存(可释放)
  • available - 可供新程序使用的内存

提示:看 "available" 而不是 "free" - Linux 会用空闲内存做缓存。

               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       2.3Gi       2.9Gi        15Mi       2.5Gi       5.1Gi

🛠️ Solutions | 解决方案

English

High CPU / Load:

  • Find processes: ps aux --sort=-%cpu | head
  • Kill unused processes: kill PID
  • Consider upgrading instance type

High Steal Time:

  • Wait for CPU credits to regenerate
  • Enable unlimited mode: aws ec2 modify-instance-credit-specification
  • Upgrade to non-burstable instance (m5, c5)

High Memory:

  • Find memory hogs: ps aux --sort=-%mem | head
  • Clear caches: sync; echo 3 > /proc/sys/vm/drop_caches

中文

CPU/负载过高:

  • 查找进程:ps aux --sort=-%cpu | head
  • 终止无用进程:kill PID
  • 考虑升级实例类型

Steal 时间过高:

  • 等待 CPU 积分自动恢复
  • 启用无限模式:aws ec2 modify-instance-credit-specification
  • 升级到非突发实例 (m5, c5)

内存过高:

  • 查找内存大户:ps aux --sort=-%mem | head
  • 清除缓存:sync; echo 3 > /proc/sys/vm/drop_caches

📋 Quick Reference | 快速参考

# Check CPU and Memory 检查 CPU 和内存
top -bn1 | head -5
free -h

# Top processes by CPU 按 CPU 排序的进程
ps aux --sort=-%cpu | head -10

# Top processes by Memory 按内存排序的进程
ps aux --sort=-%mem | head -10

# Disk usage 磁盘使用
df -h /

# Kill a process 终止进程
kill PID