diff --git a/jiangwei-platform/scripts/windows-node-check.ps1 b/jiangwei-platform/scripts/windows-node-check.ps1 new file mode 100755 index 000000000..eff85063d --- /dev/null +++ b/jiangwei-platform/scripts/windows-node-check.ps1 @@ -0,0 +1,140 @@ +#!/usr/bin/env powershell + +# Windows-Test-Node节点本地检查脚本 +# 使用方法:.\windows-node-check.ps1 + +# 颜色定义 +$RED = "`e[31m" +$GREEN = "`e[32m" +$YELLOW = "`e[33m" +$BLUE = "`e[34m" +$NC = "`e[0m" + +function Log { Write-Host "$GREEN✅ $args$NC" } +function Warn { Write-Host "$YELLOW⚠️ $args$NC" } +function Error { Write-Host "$RED❌ $args$NC" } +function Info { Write-Host "$BLUEℹ️ $args$NC" } + +# Windows节点信息 +$WINDOWS_NODE = "192.168.2.33" +$WINDOWS_USER = "administrator" + +# 测试连接 +Info "测试Windows-Test-Node节点连接..." + +# 尝试Ping节点(允许失败) +Info "1/5: 测试网络连接(Ping)..." +try { + $pingResult = Test-Connection -ComputerName $WINDOWS_NODE -Count 3 -Quiet + if ($pingResult) { + Log "Ping成功" + } else { + Warn "Ping失败,但继续尝试其他方法" + Info "请检查以下问题:" + Info "1. Windows节点是否已启动" + Info "2. 网络连接是否正常" + Info "3. 防火墙是否允许Ping" + Info "4. VPN连接是否已建立" + } +} catch { + Warn "Ping命令执行失败:$_" +} + +# 尝试SSH连接(允许失败) +Info "2/5: 测试SSH连接..." +try { + $sshResult = ssh "$WINDOWS_USER@$WINDOWS_NODE" "echo 'SSH连接成功'" + if ($?) { + Log "SSH连接成功:$sshResult" + } else { + Error "SSH连接失败" + Info "请检查以下问题:" + Info "1. Windows节点是否已启用SSH服务" + Info "2. 用户名和密码是否正确" + Info "3. 防火墙是否允许SSH连接" + Exit 1 + } +} catch { + Error "SSH命令执行失败:$_" + Exit 1 +} + +# 检查Python环境 +Info "3/5: 检查Python环境..." +try { + $pythonVersion = ssh "$WINDOWS_USER@$WINDOWS_NODE" "python --version 2>&1 || python3 --version 2>&1" + if ($?) { + Log "Python环境已安装:$pythonVersion" + } else { + Error "Python环境未安装" + Info "请在Windows节点上安装Python" + Exit 1 + } +} catch { + Error "Python检查失败:$_" + Exit 1 +} + +# 检查AKShare安装 +Info "4/5: 检查AKShare安装..." +try { + $akshareVersion = ssh "$WINDOWS_USER@$WINDOWS_NODE" "python -c 'import akshare; print(akshare.__version__)' 2>/dev/null || python3 -c 'import akshare; print(akshare.__version__)' 2>/dev/null" + if ($?) { + Log "AKShare已安装:$akshareVersion" + } else { + Error "AKShare未安装" + Info "请在Windows节点上安装AKShare:" + Info "pip install akshare" + Exit 1 + } +} catch { + Error "AKShare检查失败:$_" + Exit 1 +} + +# 检查数据采集脚本是否存在 +Info "5/5: 检查数据采集脚本..." +try { + $scriptPath = "C:\sanguo_quant_live\zhaoyun-data\scripts\akshare_downloader.py" + $scriptExists = ssh "$WINDOWS_USER@$WINDOWS_NODE" "test -f '$scriptPath'" + if ($?) { + Log "数据采集脚本已存在:$scriptPath" + } else { + Warn "数据采集脚本不存在:$scriptPath" + Info "请确保脚本已同步到Windows节点" + } +} catch { + Error "脚本检查失败:$_" +} + +# 测试运行数据采集脚本 +Info "测试数据采集脚本..." +try { + $testResult = ssh "$WINDOWS_USER@$WINDOWS_NODE" "python $scriptPath --test 2>&1 || python3 $scriptPath --test 2>&1" + if ($?) { + Log "数据采集脚本测试成功" + } else { + Error "数据采集脚本测试失败" + Info "错误信息:$testResult" + Exit 1 + } +} catch { + Error "脚本测试失败:$_" + Exit 1 +} + +# 输出Windows节点连接信息 +Write-Host "" +Log "Windows-Test-Node节点检查完成!" +Write-Host "" +Info "Windows节点信息:" +Info " IP地址:$WINDOWS_NODE" +Info " 用户名:$WINDOWS_USER" +Info " Python版本:$pythonVersion" +Info " AKShare版本:$akshareVersion" +Write-Host "" +Info "使用方法:" +Info "在Windows节点上执行数据采集任务:" +Info "ssh $WINDOWS_USER@$WINDOWS_NODE 'cd /c/sanguo_quant_live/zhaoyun-data && python scripts/akshare_downloader.py --symbols 510050 510300 --start-date 20210101 --end-date 20231231'" +Write-Host "" +Log "Windows-Test-Node节点已准备好使用!"