Update README and installation scripts for Resource Monitor Service v2.1, enhancing web dashboard features and adjusting firewall configurations.

This commit is contained in:
Phoenix
2025-08-07 23:10:40 +08:00
parent 3d47fc1439
commit 96b6e3dcd9
4 changed files with 380 additions and 192 deletions
+25 -17
View File
@@ -6,8 +6,8 @@ param(
)
$SERVICE_NAME = "ResourceMonitorService"
$SERVICE_DISPLAY_NAME = "Resource Monitor Service v2.0"
$SERVICE_DESCRIPTION = "Monitors VM resources for Unraid integration"
$SERVICE_DISPLAY_NAME = "Resource Monitor Service v2.1"
$SERVICE_DESCRIPTION = "Monitors system resources with web dashboard for Unraid integration"
$INSTALL_PATH = "C:\Services\ResourceMonitor"
Write-Host "=== Resource Monitor Service - Windows Service Installer ===" -ForegroundColor Cyan
@@ -135,14 +135,18 @@ try {
Write-Host "WARNING: Failed to configure service recovery options" -ForegroundColor Yellow
}
# Configure firewall rule
Write-Host "Configuring Windows Firewall..."
# Configure firewall rule for web dashboard
Write-Host "Configuring Windows Firewall for web dashboard..."
try {
New-NetFirewallRule -DisplayName "Resource Monitor Service" -Direction Inbound -Protocol TCP -LocalPort 2414 -Action Allow -Profile Any -ErrorAction Stop
Write-Host "Firewall rule created" -ForegroundColor Green
# Remove old rule if it exists
Remove-NetFirewallRule -DisplayName "Resource Monitor Service" -ErrorAction SilentlyContinue
# Create new rule for port 5000 (web dashboard)
New-NetFirewallRule -DisplayName "Resource Monitor Service" -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow -Profile Any -ErrorAction Stop
Write-Host "Firewall rule created for web dashboard (port 5000)" -ForegroundColor Green
} catch {
Write-Host "WARNING: Failed to create firewall rule. You may need to configure manually." -ForegroundColor Yellow
Write-Host "Manual command: New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 2414 -Action Allow" -ForegroundColor Gray
Write-Host "Manual command: New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow" -ForegroundColor Gray
}
# Start the service
@@ -165,8 +169,9 @@ Write-Host
Write-Host "=== Installation Complete ===" -ForegroundColor Cyan
Write-Host "Service Name: $SERVICE_NAME" -ForegroundColor White
Write-Host "Installation Path: $INSTALL_PATH" -ForegroundColor White
Write-Host "Service URL: http://localhost:2414" -ForegroundColor White
Write-Host "API Health Check: http://localhost:2414/api/health" -ForegroundColor White
Write-Host "Web Dashboard: http://localhost:5000" -ForegroundColor Yellow
Write-Host "API Documentation: http://localhost:5000/swagger" -ForegroundColor Yellow
Write-Host "API Health Check: http://localhost:5000/api/health" -ForegroundColor White
Write-Host
Write-Host "The service is now running and will start automatically with Windows." -ForegroundColor Green
Write-Host "You can manage it through Services.msc or using PowerShell commands:" -ForegroundColor White
@@ -177,17 +182,20 @@ Write-Host " - Restart: Restart-Service -Name $SERVICE_NAME" -ForegroundColor G
Write-Host
Write-Host "To uninstall: .\install-service.ps1 -Uninstall" -ForegroundColor Yellow
# Test the API endpoint
# Test the web dashboard
Write-Host
Write-Host "Testing API endpoint..." -ForegroundColor Yellow
Write-Host "Testing web dashboard..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
try {
$response = Invoke-RestMethod -Uri "http://localhost:2414/" -TimeoutSec 10
Write-Host "API Test Result: SUCCESS" -ForegroundColor Green
Write-Host "Service Version: $($response.Service) v$($response.Version)" -ForegroundColor White
Write-Host "Status: $($response.Status)" -ForegroundColor White
$response = Invoke-RestMethod -Uri "http://localhost:5000/api/health" -TimeoutSec 10
Write-Host "Web Dashboard Test: SUCCESS" -ForegroundColor Green
Write-Host "Service Status: $($response.status)" -ForegroundColor White
Write-Host "Service Uptime: $($response.uptime)" -ForegroundColor White
Write-Host
Write-Host "🎉 Web Dashboard is ready at: http://localhost:5000" -ForegroundColor Green
Write-Host "📖 API Documentation at: http://localhost:5000/swagger" -ForegroundColor Green
} catch {
Write-Host "API Test Result: FAILED" -ForegroundColor Red
Write-Host "Web Dashboard Test: FAILED" -ForegroundColor Red
Write-Host "The service may still be starting up. Wait a few minutes and try accessing:" -ForegroundColor Yellow
Write-Host "http://localhost:2414/api/health" -ForegroundColor White
Write-Host "http://localhost:5000" -ForegroundColor White
}