2026-01-18 19:21:16 +00:00
|
|
|
package sender
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"log"
|
|
|
|
|
|
|
|
|
|
"bugs.watch/agent/internal/aggregate"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// LoggingSender sends snapshots to the local log.
|
|
|
|
|
// This is a stand-in for HTTP or disk-backed senders.
|
|
|
|
|
type LoggingSender struct{}
|
|
|
|
|
|
|
|
|
|
func NewLoggingSender() *LoggingSender {
|
|
|
|
|
return &LoggingSender{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *LoggingSender) Send(ctx context.Context, snap aggregate.Snapshot) error {
|
|
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
// Context cancelled. Best effort: do not block shutdown.
|
|
|
|
|
return ctx.Err()
|
|
|
|
|
default:
|
|
|
|
|
log.Printf(
|
2026-06-18 14:41:04 +01:00
|
|
|
"SEND cpu=%.2f%% mem=%.2f%% disk=%.2f%% uptime=%ds load=%.2f",
|
2026-01-18 19:21:16 +00:00
|
|
|
snap.CPUAvg,
|
|
|
|
|
snap.MemAvg,
|
|
|
|
|
snap.DiskAvg,
|
|
|
|
|
snap.Uptime,
|
2026-06-18 14:41:04 +01:00
|
|
|
snap.Load,
|
2026-01-18 19:21:16 +00:00
|
|
|
)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|