#!/bin/bash # 只读:汇总已排查项,输出结论 set -e DJANGO_DIR="/opt/1panel/apps/openresty/nginx/www/sites/43.142.166.152.443/django" LOG="/opt/1panel/apps/openresty/nginx/log/access.log" cd "$DJANGO_DIR" echo "=== 1. 数据库地址 ===" venv/bin/python -c "import app_secrets; print(app_secrets.DATABASE_HOST, app_secrets.DATABASE_PORT)" echo "" echo "=== 2. Redis 延迟 ===" venv/bin/python manage.py shell -c " import time from django.core.cache import cache t=time.perf_counter() cache.set('ping',1,10); cache.get('ping') print(round((time.perf_counter()-t)*1000), 'ms') " echo "" echo "=== 3. 最近429限流条数 ===" grep -a 'hqhd' "$LOG" 2>/dev/null | awk '$9==429' | wc -l | xargs echo "429 count:" echo "" echo "=== 4. 最近20条 hqhd rt= ===" grep -a 'hqhd' "$LOG" 2>/dev/null | tail -20 | grep -oP 'rt=\K[0-9.]+|POST \K[^ ]+' | paste - - | head -10 echo "" echo "=== 5. Gunicorn ===" systemctl is-active gunicorn-dianjing.service pgrep -cf 'gunicorn.*a_long_dianjing' || true