#!/bin/bash
# 系统诊断脚本

echo "=== 系统诊断开始 ==="
echo "时间: $(date)"
echo ""

echo "=== Docker服务状态 ==="
systemctl is-active docker || echo "Docker服务未运行"
echo ""

echo "=== Docker版本 ==="
docker --version 2>/dev/null || echo "Docker命令不可用"
echo ""

echo "=== 容器状态 ==="
docker ps -a 2>/dev/null || echo "无法获取容器状态"
echo ""

echo "=== 网络连接测试 ==="
curl -I --connect-timeout 3 http://localhost 2>/dev/null || echo "本地80端口不可访问"
curl -I --connect-timeout 3 https://aiedu.ireborn.com.cn 2>/dev/null || echo "HTTPS不可访问"
echo ""

echo "=== 端口占用检查 ==="
netstat -tlnp | grep -E ":(80|443|8000|3306|6379|9000)" || echo "关键端口未监听"
echo ""

echo "=== 服务状态 ==="
systemctl is-active kaopeilian.service || echo "kaopeilian服务未运行"
systemctl is-active kaopeilian-webhook.service || echo "webhook服务未运行"
echo ""

echo "=== 诊断完成 ==="
