71 lines
2.9 KiB
PowerShell
71 lines
2.9 KiB
PowerShell
# Simple FRP Server Check Script
|
|
# Can be run on the server directly or via SSH
|
|
|
|
param(
|
|
[string]$ServerIP = ""
|
|
)
|
|
|
|
if ([string]::IsNullOrEmpty($ServerIP)) {
|
|
Write-Host "Usage: .\check-frp-servers-simple.ps1 -ServerIP <IP>" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "Example:" -ForegroundColor Cyan
|
|
Write-Host " .\check-frp-servers-simple.ps1 -ServerIP 180.97.221.140" -ForegroundColor White
|
|
Write-Host " .\check-frp-servers-simple.ps1 -ServerIP 103.118.245.6" -ForegroundColor White
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Checking FRP Service on: $ServerIP" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Commands to run on the server
|
|
$commands = @(
|
|
"echo '=== 1. Check FRP processes ==='",
|
|
"ps aux | grep -E '[f]rps|[f]rpc' || echo 'No FRP processes found'",
|
|
"",
|
|
"echo '=== 2. Check systemd services ==='",
|
|
"systemctl status frps --no-pager 2>/dev/null || echo 'frps service not found'",
|
|
"systemctl status frpc --no-pager 2>/dev/null || echo 'frpc service not found'",
|
|
"",
|
|
"echo '=== 3. Check binary locations ==='",
|
|
"which frps frpc 2>/dev/null || echo 'Not in PATH'",
|
|
"find /usr/local/bin /opt /root -name '*frp*' -type f -executable 2>/dev/null | head -10 || echo 'No binaries found'",
|
|
"",
|
|
"echo '=== 4. Check config files ==='",
|
|
"find /etc /root -name '*frp*.toml' -o -name '*frp*.ini' 2>/dev/null | head -10 || echo 'No config files found'",
|
|
"",
|
|
"echo '=== 5. Check network connections ==='",
|
|
"(netstat -tlnp 2>/dev/null || ss -tlnp 2>/dev/null) | grep -E 'frp|7000|7001' || echo 'No FRP connections found'"
|
|
)
|
|
|
|
$allCommands = $commands -join " && "
|
|
|
|
Write-Host "Connecting to $ServerIP..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "Run these commands on the server:" -ForegroundColor Cyan
|
|
Write-Host "----------------------------------------" -ForegroundColor Gray
|
|
Write-Host $allCommands -ForegroundColor White
|
|
Write-Host "----------------------------------------" -ForegroundColor Gray
|
|
Write-Host ""
|
|
|
|
Write-Host "Or run via SSH:" -ForegroundColor Cyan
|
|
Write-Host "ssh root@$ServerIP `"$allCommands`"" -ForegroundColor White
|
|
Write-Host ""
|
|
|
|
# Try to execute via SSH if ssh command is available
|
|
if (Get-Command ssh -ErrorAction SilentlyContinue) {
|
|
Write-Host "Attempting SSH connection..." -ForegroundColor Yellow
|
|
try {
|
|
$result = ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no "root@$ServerIP" $allCommands 2>&1
|
|
Write-Host $result
|
|
} catch {
|
|
Write-Host "SSH connection failed. Please run the commands manually on the server." -ForegroundColor Red
|
|
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
} else {
|
|
Write-Host "SSH command not found. Please run the commands manually on the server." -ForegroundColor Yellow
|
|
}
|
|
|
|
|