# 早班巡检 - 服务器检查批处理 (2026-07-29) # 注:此文件将被上传到 /tmp 并通过 batch 子命令执行 # === 2.1 Docker 容器状态 === echo "=== [1/8] docker ps -a ===" docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' echo "" echo "=== [2/8] 健康异常的容器 ===" docker ps -a --filter 'status=exited' --format '{{.Names}} {{.Status}}' docker ps -a --filter 'status=restarting' --format '{{.Names}} {{.Status}}' # === 2.2 后端 API 健康 === echo "" echo "=== [3/8] backend health ===" docker ps --filter 'name=wecom_it_backend' --format '{{.Names}} {{.Status}}' curl -sS -o /tmp/health_out.txt -w 'HTTP %{http_code} | %{time_total}s\n' http://127.0.0.1:8000/health cat /tmp/health_out.txt 2>/dev/null | head -20 # === 2.3 数据库与缓存 === echo "" echo "=== [4/8] PostgreSQL ===" docker exec -i wecom_it_postgres pg_isready -U postgres docker exec -i wecom_it_postgres psql -U postgres -d wecom_it_desk -c 'select version();' 2>&1 | head -5 echo "" echo "=== [5/8] Redis ===" docker exec -i wecom_it_redis redis-cli -a $(cat /run/secrets/redis_pw 2>/dev/null) ping 2>/dev/null || docker exec -i wecom_it_redis redis-cli ping # === 2.4 资源使用 === echo "" echo "=== [6/8] 磁盘 ===" df -h | grep -v tmpfs | head -20 echo "" echo "=== [7/8] 内存 ===" free -h echo "" echo "=== [8/8] 日志大小 ===" du -sh /opt/wecom-it-desk/logs/* 2>/dev/null | sort -h | tail -20 # === 2.5 Nginx 状态 === echo "" echo "=== [Nginx] 容器与首页 ===" docker ps --filter 'name=wecom_it_nginx' --format '{{.Names}} {{.Status}}' curl -sS -o /dev/null -w '员工端 / HTTP %{http_code}\n' http://127.0.0.1/ curl -sS -o /dev/null -w '管理端 /itadmin/ HTTP %{http_code}\n' http://127.0.0.1/itadmin/ curl -sS -o /dev/null -w '坐席端 /agent/ HTTP %{http_code}\n' http://127.0.0.1/agent/ echo "" echo "=== [end] ==="