360 Secure SkillHub
360 安全技能中心

VM Health Check

通过 SSH 连接 Docker 版 Linux 服务器并运行 vm-check.sh,汇总系统负载、内存、磁盘占用、容器状态与资源消耗、MySQL/Postgres 数据库大小以及 Docker 镜像与构建缓存可回收空间,并按阈值标记警告;首次运行会询问并保存主机、用户名和私钥路径。

tonylnng
tonylnng
热度 54.40
最近更新 2026-05-17 15:19:24
分类:自动化依赖:代码执行 / 读写文件应用场景:DevOps / 报告撰写 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add tonic-vm-check
Metadata
name
tonic-vm-check
description
🖥️ Instant VM health checks — no config needed after first run. Point it at any Docker-based Linux server and get a clean report covering CPU, memory, disk, all running containers (with live stats), MySQL/Postgres database sizes, and Docker image/cache bloat — in one command. First time? It asks for your VM details once, saves them, and never asks again. Perfect for: post-deploy sanity checks, spotting memory hogs, finding disk space to reclaim, and keeping your server tidy. Triggers on: "check VM", "VM resources", "VM health", "how is the server", "Docker usage", "disk usage", "clean up Docker", "free up space".

tonic-vm-check

SSH into a Docker-based VM and report system health, container status, DB sizes, and disk usage.

Step 1: Load VM Config

Before running any check, look for this block in TOOLS.md:

### tonic-vm-check
- VM_HOST: <host>
- VM_USER: <user>
- SSH_KEY: <path>

If found: extract the values and proceed to Step 2.

If not found: ask the user once:

To check your VM, I need a few details (only asked once — saved to TOOLS.md):

  1. VM IP or hostname
  2. SSH username (default: ubuntu)
  3. Path to SSH private key (default: ~/.ssh/id_rsa)

Then append to TOOLS.md:

### tonic-vm-check
- VM_HOST: <answer>
- VM_USER: <answer>
- SSH_KEY: <answer>

Confirm saved, then proceed.

Step 2: Run the Check

VM_HOST=<host> VM_USER=<user> SSH_KEY=<key> bash skills/tonic-vm-check/scripts/vm-check.sh [section]

Sections: all (default) · system · disk · containers · db · docker-df · cleanup

Step 3: Report

Summarise results:

🖥️ System — Uptime, CPU idle%, load average, memory (total / used / available)

💾 Disk — / usage %, used, free

🐳 Docker — Top containers by MEM USAGE; flag any not healthy or recently restarted

🗄️ DB Sizes — MySQL and Postgres databases auto-detected on the VM

🧹 Cleanup Opportunities — Reclaimable image/cache space; stopped containers worth removing

Always flag items that exceed thresholds:

Metric Warning Critical
Disk usage >70% >85%
Memory used >80% >90%
Load avg (1m) >2.0 >4.0
Single container MEM >1 GB >2 GB

Cleanup Safety Rules

  • docker image prune -af — safe (unused images only)
  • docker builder prune -f — safe (build cache only, no data loss)
  • docker container prune — safe only for stopped containers
  • Never run docker system prune -af without explicit user approval (destroys volumes)