From 98a3cb9b50ae86b4b563c02bc16a35fbcd30b999 Mon Sep 17 00:00:00 2001 From: Ilya Gavrilov Date: Tue, 8 Jul 2025 12:49:52 +0200 Subject: [PATCH 1/2] Add CPU and memory information --- api.go | 18 ++++++++++++++++++ go.sum | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 2392a48..95e60a5 100644 --- a/api.go +++ b/api.go @@ -63,6 +63,8 @@ type Resolution struct { HostParentProcessID int `json:"hostParentProcessId"` ProcessName string `json:"processName"` ProcessPath string `json:"processPath"` + CpuUsage int `json:"cpuUsage"` + MemoryUsage int `json:"memoryUsage"` ResolutionMechanism ResolutionMechanism `json:"resolutionMechanism"` sync.Mutex } @@ -118,6 +120,7 @@ func (resolution *Resolution) GetCgroupID() uint { func (resolution *Resolution) GetContainerID() string { resolution.Lock() defer resolution.Unlock() + fmt.Printf("GetContainerID: %s\n", resolution.ContainerID) //XXX return resolution.ContainerID } @@ -229,6 +232,7 @@ func (resolution *Resolution) SetContainerID(ContainerID string) *Resolution { resolution.Lock() defer resolution.Unlock() resolution.ContainerID = ContainerID + fmt.Printf("SetContainerID: %s\n", resolution.ContainerID) //XXX return resolution } @@ -281,6 +285,20 @@ func (resolution *Resolution) SetProcessPath(ProcessPath string) *Resolution { return resolution } +func (resolution *Resolution) SetCpuUsage(CpuUsage int) *Resolution { + resolution.Lock() + defer resolution.Unlock() + resolution.CpuUsage = CpuUsage + return resolution +} + +func (resolution *Resolution) SetMemoryUsage(MemoryUsage int) *Resolution { + resolution.Lock() + defer resolution.Unlock() + resolution.MemoryUsage = MemoryUsage + return resolution +} + func (resolution *Resolution) SetResolutionMechanism(ResolutionMechanism ResolutionMechanism) *Resolution { resolution.Lock() defer resolution.Unlock() diff --git a/go.sum b/go.sum index f49c0e6..b85f4ea 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,6 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubeshark/api2 v0.0.0-20250613175225-65be260e56f6 h1:yDx1eb+qQ3hB3xHQzSP7MLTDAFW9/jWuKGUA1GpFG7U= -github.com/kubeshark/api2 v0.0.0-20250613175225-65be260e56f6/go.mod h1:naOqOy71RRXeKPVH7/Vr2cGbyRDLg9sPKDBeOxdNCWU= github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a h1:+0APmVFqmmpibP2oluAdyqnD05z17iq+sSQvSXj2w2A= github.com/kubeshark/api2 v0.0.0-20250616171331-0bb2df0d448a/go.mod h1:naOqOy71RRXeKPVH7/Vr2cGbyRDLg9sPKDBeOxdNCWU= github.com/kubeshark/gopacket v1.1.30 h1:Dz6eo7b6+NdVCrgiyKxlGEVTm0L6PwgbVvSomsuwIyU= From 2efb167d4a570ce34c88b36477f99b07716a08dd Mon Sep 17 00:00:00 2001 From: Ilya Gavrilov Date: Tue, 8 Jul 2025 12:50:50 +0200 Subject: [PATCH 2/2] Add CPU and memory information --- api.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/api.go b/api.go index 95e60a5..0458096 100644 --- a/api.go +++ b/api.go @@ -120,7 +120,6 @@ func (resolution *Resolution) GetCgroupID() uint { func (resolution *Resolution) GetContainerID() string { resolution.Lock() defer resolution.Unlock() - fmt.Printf("GetContainerID: %s\n", resolution.ContainerID) //XXX return resolution.ContainerID } @@ -232,7 +231,6 @@ func (resolution *Resolution) SetContainerID(ContainerID string) *Resolution { resolution.Lock() defer resolution.Unlock() resolution.ContainerID = ContainerID - fmt.Printf("SetContainerID: %s\n", resolution.ContainerID) //XXX return resolution }