34 lines
983 B
Go
34 lines
983 B
Go
package agent
|
|
|
|
import (
|
|
"runtime"
|
|
"time"
|
|
|
|
"github.com/example/remote-access-platform/agents/rap-node-agent/internal/client"
|
|
"github.com/example/remote-access-platform/agents/rap-node-agent/internal/state"
|
|
)
|
|
|
|
func TelemetryPayload(identity state.Identity, startedAt time.Time) client.TelemetryRequest {
|
|
var mem runtime.MemStats
|
|
runtime.ReadMemStats(&mem)
|
|
used := int64(mem.Alloc)
|
|
total := int64(mem.Sys)
|
|
processCount := runtime.NumGoroutine()
|
|
return client.TelemetryRequest{
|
|
MemoryUsedBytes: &used,
|
|
MemoryTotalBytes: &total,
|
|
ProcessCount: &processCount,
|
|
Payload: map[string]any{
|
|
"agent": "rap-node-agent",
|
|
"agent_version": Version,
|
|
"node_name": identity.NodeName,
|
|
"os": runtime.GOOS,
|
|
"arch": runtime.GOARCH,
|
|
"goroutines": runtime.NumGoroutine(),
|
|
"uptime_seconds": int64(time.Since(startedAt).Seconds()),
|
|
"telemetry_source": "testing_flag",
|
|
},
|
|
ObservedAt: time.Now().UTC(),
|
|
}
|
|
}
|