MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / getProcessData

Function getProcessData

agent/utils/websocket/process_data.go:209–242  ·  view source on GitHub ↗
(processConfig PsProcessConfig)

Source from the content-addressed store, hash-verified

207}
208
209func getProcessData(processConfig PsProcessConfig) (res []byte, err error) {
210 ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
211 defer cancel()
212
213 processes, err := process.ProcessesWithContext(ctx)
214 if err != nil {
215 return
216 }
217
218 connections, err := net.ConnectionsMaxWithContext(ctx, "all", 32768)
219 if err != nil {
220 return
221 }
222
223 pidConnections := make(map[int32][]net.ConnectionStat, len(processes))
224 for _, conn := range connections {
225 if conn.Pid == 0 {
226 continue
227 }
228 pidConnections[conn.Pid] = append(pidConnections[conn.Pid], conn)
229 }
230
231 result := make([]PsProcessData, 0, len(processes))
232
233 for _, proc := range processes {
234 procData := handleProcessData(proc, &processConfig, pidConnections)
235 if procData != nil {
236 result = append(result, *procData)
237 }
238 }
239
240 res, err = json.Marshal(result)
241 return
242}
243
244func getSSHSessions(config SSHSessionConfig) (res []byte, err error) {
245 var (

Callers 1

ProcessDataFunction · 0.85

Calls 1

handleProcessDataFunction · 0.85

Tested by

no test coverage detected