feat(probe): port monitor-probe collector into agent, persist latest snapshot (item 7 B1)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user