summaryrefslogtreecommitdiff
path: root/hetzner-admin/run-command.sh
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-11-01 04:24:31 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-11-01 04:24:31 +0900
commitbe8565934a15c49eeeacb84dd30c0a1eb9ea8770 (patch)
tree00d237c9f20ed13a5d3a7d2758e703641a34510e /hetzner-admin/run-command.sh
parentde58a03a219fe2e93da8fef32ba3484149befb0f (diff)
hetzner-admin: show CPU load / memory / disk / uptime, add Container Stats command
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N5eS3SG9dxKszFC7t3QZn9
Diffstat (limited to 'hetzner-admin/run-command.sh')
-rwxr-xr-xhetzner-admin/run-command.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/hetzner-admin/run-command.sh b/hetzner-admin/run-command.sh
index d1f68f8..b473ce4 100755
--- a/hetzner-admin/run-command.sh
+++ b/hetzner-admin/run-command.sh
@@ -56,9 +56,20 @@ case "$SSH_ORIGINAL_COMMAND" in
if [ -n "$unit" ]; then systemctl enable --now "$unit" 2>&1; else docker compose -f "$compose" up -d 2>&1; fi
fi
;;
+ "resources")
+ # 管理画面のリソース表示用。"key value..." 形式で出力し app.py がパースする
+ echo "cpus $(nproc)"
+ echo "load $(cut -d' ' -f1-3 /proc/loadavg)"
+ awk '/^MemTotal:/{t=$2} /^MemAvailable:/{a=$2} END{print "mem", t*1024, (t-a)*1024}' /proc/meminfo
+ df -B1 --output=size,used / | awk 'NR==2{print "disk", $1, $2}'
+ echo "uptime $(cut -d. -f1 /proc/uptime)"
+ ;;
"docker ps")
exec docker ps
;;
+ "docker stats")
+ exec docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}'
+ ;;
"docker compose -f /app/infra/caddy/docker-compose.yml restart")
exec docker compose -f /app/infra/caddy/docker-compose.yml restart
;;