# 3 种方法在服务器上跑诊断脚本

**目标**:在 10.90.5.110 服务器上跑 diagnose-500.sh,把输出粘回给我

---

## 方法 1(推荐):PuTTY 连进去,一行命令恢复 + 跑

**步骤 1**:PuTTY 客户端
- Host:`10.212.189.210`,Port:`2222`,SSH → Open
- 用户 `sxn` + 密码
- 堡垒机内再 `ssh sxn@10.90.5.110` 跳目标机

**步骤 2**:服务器内贴这一行(整段一次性):
```bash
cat > /tmp/diag.sh << 'ENDOFSCRIPT'
#!/bin/bash
docker compose ps
echo "---"
ls -la /opt/wecom-it-desk/frontend-h5/dist/ 2>&1 | head -10
echo "--- assets ---"
ls -la /opt/wecom-it-desk/frontend-h5/dist/assets/ 2>&1 | head -10
echo "--- nginx 容器内 ---"
docker compose exec nginx ls -la /usr/share/nginx/html/itdesk/ 2>&1 | head -10
echo "--- nginx 容器内 assets ---"
docker compose exec nginx ls -la /usr/share/nginx/html/itdesk/assets/ 2>&1 | head -10
echo "--- SSL ---"
docker compose exec nginx ls -la /etc/nginx/ssl/ 2>&1 | head -10
echo "--- /itdesk/ 头 ---"
curl -ksI https://itsupport.servyou.com.cn/itdesk/ 2>&1 | head -8
echo "--- /itportal/ 头 ---"
curl -ksI https://itsupport.servyou.com.cn/itportal/ 2>&1 | head -8
echo "--- /itagent/ 头 ---"
curl -ksI https://itsupport.servyou.com.cn/itagent/ 2>&1 | head -8
echo "--- /itadmin/ 头 ---"
curl -ksI https://itsupport.servyou.com.cn/itadmin/ 2>&1 | head -8
echo "--- /itdesk/ 完整 body 前 20 行 ---"
curl -ks https://itsupport.servyou.com.cn/itdesk/ 2>&1 | head -20
echo "--- nginx 错误日志 ---"
docker compose exec nginx tail -30 /var/log/nginx/error.log 2>&1
echo "--- nginx 访问日志 ---"
docker compose exec nginx tail -20 /var/log/nginx/access.log 2>&1
echo "--- backend 日志 ---"
docker compose logs --tail=20 backend 2>&1
ENDOFSCRIPT
bash /tmp/diag.sh 2>&1
```

**步骤 3**:把输出整段粘回给我

---

## 方法 2:用 scp 上传本地脚本

**前提**:你能 scp 到 10.90.5.110(堡垒机后的方式)

```bash
scp "C:\Users\simon\Downloads\diagnose-500 (1).sh" sxn@10.90.5.110:/tmp/
# (如果直连 scp 不通,可能要用堡垒机的文件传输功能)
```

然后 PuTTY 连进去跑:
- Host:`10.212.189.210`,Port:`2222`,SSH → Open
- 堡垒机内 `ssh sxn@10.90.5.110` 跳目标机
```bash
sudo cp /tmp/diagnose-500.sh /opt/wecom-it-desk/
cd /opt/wecom-it-desk
bash diagnose-500.sh > /tmp/diag.log 2>&1
cat /tmp/diag.log
```

把 `cat /tmp/diag.log` 的输出粘回

---

## 方法 3:服务器直接下载(若服务器能上外网)

```bash
# PuTTY 连:Host 10.212.189.210 Port 2222 → 堡垒机内 ssh sxn@10.90.5.110
cd /tmp
# 如果服务器能访问 GitHub raw / Gitea
curl -O https://你的存放点/diagnose-500.sh
bash diagnose-500.sh > /tmp/diag.log 2>&1
cat /tmp/diag.log
```

---

## 最简版(只要 5 行输出)

如果方法 1 太长,**只要这 5 行**就够我定位:

```bash
docker compose ps 2>&1
ls -la /opt/wecom-it-desk/frontend-h5/dist/assets/ 2>&1
docker compose exec nginx ls -la /usr/share/nginx/html/itdesk/ 2>&1
docker compose exec nginx tail -10 /var/log/nginx/error.log 2>&1
curl -ksI https://itsupport.servyou.com.cn/itdesk/ 2>&1 | head -8
```

**把这 5 段输出粘回,我能立刻定位 500 原因。**
