Files
flvx/plans/060-tunnel-quality-polling.md
T

2.3 KiB

060 Nezha-style Monitoring (1s test, 30s report)

Objective

Update all monitoring subsystems to test every 1 second and report (write to DB) every 30 seconds, matching Nezha-style monitoring behavior.

Changes

1. Tunnel Quality Prober (go-backend/internal/http/handler/tunnel_quality_prober.go)

  • Change tunnelQualityProbeInterval from 10s to 1s
  • Add tunnelQualityReportInterval = 30s for DB write throttling
  • Update storeResult to cache in-memory every tick, write to DB only every 30s per tunnel
  • Add atomic probing flag to prevent overlapping probeAll() goroutine pile-up
  • Increase maxWorkers from 4 to 20

2. Service Monitor Checker (go-backend/internal/health/checker.go)

  • Add serviceMonitorReportInterval = 30s for DB write throttling
  • Add latestResults in-memory map and lastDBWrite map per monitor
  • Add GetLatestCached() method for real-time API reads
  • Add atomic checking flag to prevent overlapping runChecks() goroutine pile-up
  • Modify worker goroutines to always update in-memory cache, only write to DB every 30s

3. Service Monitor Limits (go-backend/internal/monitoring/limits.go)

  • Change CheckerScanIntervalSec default from 30 to 1
  • Change WorkerLimit default from 5 to 20
  • Change MinIntervalSec default from 30 to 1
  • Change DefaultIntervalSec default from 60 to 1

4. Monitoring API Handler (go-backend/internal/http/handler/monitoring.go)

  • Update monitorServiceLatestResultsHandler to prefer in-memory cached results from healthCheck.GetLatestCached()

5. Agent WebSocket Reporter (go-gost/x/socket/websocket_reporter.go)

  • Change pingInterval (metric reporting) from 5s to 1s

6. Frontend - Tunnel Monitor (vite-frontend/src/pages/node/tunnel-monitor-view.tsx)

  • Change QUALITY_POLL_INTERVAL from 10s to 1s
  • Update detail view text: "自动探测中(每秒测试,30秒上报)"
  • Update list view text: "每秒探测 · 更新于 ..."

7. Frontend - Service Monitor (vite-frontend/src/pages/node/monitor-view.tsx)

  • Change DEFAULT_SERVICE_MONITOR_LIMITS defaults to match backend (1s intervals)
  • Change service monitor + latest results polling from 30s to 1s
  • Update info bar text: "每秒测试,30秒上报"