提交 cba0992a 编写于 作者: J Jean Kahrs

add Uids field to net_linux

上级 14eb7acb
......@@ -39,13 +39,14 @@ type Addr struct {
}
type ConnectionStat struct {
Fd uint32 `json:"fd"`
Family uint32 `json:"family"`
Type uint32 `json:"type"`
Laddr Addr `json:"localaddr"`
Raddr Addr `json:"remoteaddr"`
Status string `json:"status"`
Pid int32 `json:"pid"`
Fd uint32 `json:"fd"`
Family uint32 `json:"family"`
Type uint32 `json:"type"`
Laddr Addr `json:"localaddr"`
Raddr Addr `json:"remoteaddr"`
Status string `json:"status"`
Uids []int32 `json:"uids"`
Pid int32 `json:"pid"`
}
// System wide stats about different network protocols
......
......@@ -14,6 +14,7 @@ import (
"syscall"
"github.com/shirou/gopsutil/internal/common"
"github.com/shirou/gopsutil/process"
)
// NetIOCounters returnes network I/O statistics for every network
......@@ -281,6 +282,7 @@ type connTmp struct {
laddr Addr
raddr Addr
status string
uids []int32
pid int32
boundPid int32
path string
......@@ -338,6 +340,7 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
Type: c.sockType,
Laddr: c.laddr,
Raddr: c.raddr,
Uids: c.uids,
Status: c.status,
Pid: c.pid,
}
......@@ -346,6 +349,11 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
} else {
conn.Pid = c.pid
}
// fetch process owner Real, effective, saved set, and filesystem UIDs
proc := process.Process{Pid: conn.Pid}
conn.Uids, _ = proc.Uids()
// check duplicate using JSON format
json := conn.String()
_, exists := dupCheckMap[json]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册