feat(monitor): active push loop replacing standalone monitor
Adds a periodic POST loop to <backend>/monitor/server/heartbeat so HF plugin can take over the standalone harborforge-monitor daemon's job — same X-API-Key header, same flat telemetry shape (cpu_pct / mem_pct / disk_pct / swap_pct / load_avg / uptime_seconds / plugin_version / agents[]). HF backend stays unchanged. Config: monitor_push_enabled (default false; opt-in to avoid surprise heartbeats from existing deployments), monitor_push_interval_seconds (default 30), reuses apiKey for the X-API-Key header. Lift the container's HF_MONITER_API_KEY into config.apiKey, flip monitor_push_enabled true, then docker rm -f the container — DB last_seen_at keeps advancing under the plugin's loop. Collector grew swap + cpu sampling (two reads of /proc/stat over a 1-second window when SampleCPU=true). Bridge endpoint stays cheap (SampleCPU=false on demand); push loop is the only caller paying the sampling cost. E2E in sim: monitor_push_enabled=true + apiKey from injected MonitoredServer row → server_states.last_seen_at advances exactly every interval_seconds (10s configured, 10s observed). cpu/mem/disk/ swap_pct all populate correctly.
This commit is contained in:
29
README.md
29
README.md
@@ -18,9 +18,19 @@ submodule of the HarborForge umbrella repo.
|
||||
|
||||
## What it does
|
||||
|
||||
- **Monitor bridge** — HTTP server on `127.0.0.1:<monitor_port>` that
|
||||
responds to `/telemetry` with a Snapshot the HarborForge.Monitor
|
||||
binary expects (system metrics + every Plexum agent's sm-state)
|
||||
- **Monitor push loop** — when `monitor_push_enabled: true`, posts a
|
||||
flat telemetry payload (cpu/mem/disk/swap/load + per-agent state)
|
||||
to `<backendUrl>/monitor/server/heartbeat` every
|
||||
`monitor_push_interval_seconds`. This replaces the standalone
|
||||
`harborforge-monitor` daemon — the plugin's lifecycle (gateway
|
||||
start/stop) bounds the loop, so a separate supervisor isn't needed.
|
||||
Use the same `apiKey` value the standalone monitor's
|
||||
`HF_MONITER_API_KEY` carried.
|
||||
- **Monitor bridge** (optional) — HTTP server on
|
||||
`127.0.0.1:<monitor_port>` that responds to `/telemetry` with a
|
||||
Snapshot. Useful when the standalone monitor is still present and
|
||||
you want it to enrich its push payload from the plugin's view of
|
||||
agents. Disable by setting `monitor_port: 0`.
|
||||
- **Calendar scheduler** — heartbeats `<backendUrl>/calendar/agent/
|
||||
heartbeat` every interval, receives any TimeSlots due to fire, and
|
||||
dispatches them through `HostAPI.WakeAgent` (state-aware queue
|
||||
@@ -64,15 +74,24 @@ And configure at `~/.plexum/plugins/harbor-forge/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"backendUrl": "https://monitor.hangman-lab.top",
|
||||
"backendUrl": "https://hf-api.hangman-lab.top",
|
||||
"identifier": "server-t3",
|
||||
"apiKey": "g1_xxx",
|
||||
"monitor_port": 9100,
|
||||
"monitor_push_enabled": true,
|
||||
"monitor_push_interval_seconds": 30,
|
||||
"monitor_port": 0,
|
||||
"calendar_enabled": true,
|
||||
"calendar_heartbeat_interval_seconds": 30
|
||||
}
|
||||
```
|
||||
|
||||
Replacing the standalone `harborforge-monitor` container: lift the
|
||||
container's `HF_MONITER_API_KEY` into `apiKey`, set
|
||||
`monitor_push_enabled: true`, then `docker rm -f harborforge-monitor`
|
||||
once you've confirmed the plugin's pushes are landing (the backend's
|
||||
`server_states.last_seen_at` should keep advancing without the
|
||||
container running).
|
||||
|
||||
Restart the host (`systemctl --user restart plexum`) and verify:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user