feat(probe): port monitor-probe collector into agent, persist latest snapshot (item 7 B1)

This commit is contained in:
Muse
2026-10-22 18:22:56 +00:00
parent 8e89960474
commit 0a973bc95c
6 changed files with 1496 additions and 3 deletions
+9 -1
View File
@@ -118,9 +118,11 @@ func (e *statusError) Error() string {
// Register registers the agent with the master
func (a *Agent) Register() error {
url := fmt.Sprintf("%s/panel/api/agent/register", a.config.MasterURL)
payload := map[string]string{
payload := map[string]any{
"token": a.config.Token,
"name": a.config.NodeName,
// Probe facts ride along (B1): old masters ignore the extra field.
"probeFacts": collectFacts(),
}
body, _ := json.Marshal(payload)
req, err := http.NewRequest("POST", url, bytes.NewReader(body))
@@ -280,6 +282,12 @@ func (a *Agent) sendHeartbeat() error {
"token": a.config.Token,
"timestamp": time.Now().Unix(),
"telemetry": a.collectTelemetry(),
// Probe snapshot (B1): facts are process-cached so re-sending them
// costs nothing and heals a master that missed the register-time
// copy; metrics are sampled fresh each heartbeat. Old masters
// ignore both fields.
"probeFacts": collectFacts(),
"probeMetrics": collectMetrics(),
}
if rep := a.currentUpdateReport(); rep != nil {
payload["updateStatus"] = rep