summaryrefslogtreecommitdiff
path: root/hetzner-admin/run-command.sh
diff options
context:
space:
mode:
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
;;