mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-28 07:36:38 +08:00
2.3 KiB
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
tunnelQualityProbeIntervalfrom 10s to 1s - Add
tunnelQualityReportInterval = 30sfor DB write throttling - Update
storeResultto cache in-memory every tick, write to DB only every 30s per tunnel - Add atomic
probingflag to prevent overlappingprobeAll()goroutine pile-up - Increase
maxWorkersfrom 4 to 20
2. Service Monitor Checker (go-backend/internal/health/checker.go)
- Add
serviceMonitorReportInterval = 30sfor DB write throttling - Add
latestResultsin-memory map andlastDBWritemap per monitor - Add
GetLatestCached()method for real-time API reads - Add atomic
checkingflag to prevent overlappingrunChecks()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
CheckerScanIntervalSecdefault from 30 to 1 - Change
WorkerLimitdefault from 5 to 20 - Change
MinIntervalSecdefault from 30 to 1 - Change
DefaultIntervalSecdefault from 60 to 1
4. Monitoring API Handler (go-backend/internal/http/handler/monitoring.go)
- Update
monitorServiceLatestResultsHandlerto prefer in-memory cached results fromhealthCheck.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_INTERVALfrom 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_LIMITSdefaults to match backend (1s intervals) - Change service monitor + latest results polling from 30s to 1s
- Update info bar text: "每秒测试,30秒上报"