@@ -85,12 +85,7 @@ func (c *ContainerCheck) Run(cfg *config.AgentConfig, groupID int32) ([]model.Me
8585
8686// fmtContainers formats and chunks the ctrList into a slice of chunks using a specific
8787// number of chunks. len(result) MUST EQUAL chunks.
88- func fmtContainers (
89- ctrList []* containers.Container ,
90- lastRates map [string ]util.ContainerRateMetrics ,
91- lastRun time.Time ,
92- chunks int ,
93- ) [][]* model.Container {
88+ func fmtContainers (ctrList []* containers.Container , lastRates map [string ]util.ContainerRateMetrics , lastRun time.Time , chunks int ) [][]* model.Container {
9489 perChunk := (len (ctrList ) / chunks ) + 1
9590 chunked := make ([][]* model.Container , chunks )
9691 chunk := make ([]* model.Container , 0 , perChunk )
@@ -136,6 +131,7 @@ func fmtContainers(
136131 NetSentPs : calculateRate (ifStats .PacketsSent , lastCtr .NetworkSum .PacketsSent , lastRun ),
137132 NetRcvdBps : calculateRate (ifStats .BytesRcvd , lastCtr .NetworkSum .BytesRcvd , lastRun ),
138133 NetSentBps : calculateRate (ifStats .BytesSent , lastCtr .NetworkSum .BytesSent , lastRun ),
134+ Addresses : convertAddressList (ctr ),
139135 Started : ctr .StartedAt ,
140136 Tags : tags ,
141137 })
@@ -152,6 +148,23 @@ func fmtContainers(
152148 return chunked
153149}
154150
151+ // convertAddressList converts AddressList into process-agent ContainerNetworkAddress objects
152+ func convertAddressList (ctr * containers.Container ) []* model.ContainerAddr {
153+ addrs := make ([]* model.ContainerAddr , 0 , len (ctr .AddressList ))
154+ for _ , a := range ctr .AddressList {
155+ protocol := model .ConnectionType_tcp
156+ if a .Protocol == "UDP" {
157+ protocol = model .ConnectionType_udp
158+ }
159+ addrs = append (addrs , & model.ContainerAddr {
160+ Ip : a .IP .String (),
161+ Port : int32 (a .Port ),
162+ Protocol : protocol ,
163+ })
164+ }
165+ return addrs
166+ }
167+
155168func calculateCtrPct (cur , prev , sys2 , sys1 uint64 , numCPU int , before time.Time ) float32 {
156169 now := time .Now ()
157170 diff := now .Unix () - before .Unix ()
0 commit comments