mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-28 13:48:49 +08:00
add Uids field to net_linux
This commit is contained in:
parent
14eb7acb23
commit
cba0992ab3
15
net/net.go
15
net/net.go
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user