Initial project snapshot
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user