mirror of https://github.com/shirou/gopsutil
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
804 B
Go
35 lines
804 B
Go
// +build linux
|
|
// +build !netlink
|
|
|
|
package net
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/shirou/gopsutil/internal/common"
|
|
)
|
|
|
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int, skipUids bool) ([]ConnectionStat, error) {
|
|
tmap, ok := netConnectionKindMap[kind]
|
|
if !ok {
|
|
return nil, fmt.Errorf("invalid kind, %s", kind)
|
|
}
|
|
root := common.HostProc()
|
|
var err error
|
|
var inodes map[string][]inodeMap
|
|
if pid == 0 {
|
|
inodes, err = getProcInodesAll(root, max)
|
|
} else {
|
|
inodes, err = getProcInodes(root, pid, max)
|
|
}
|
|
if len(inodes) == 0 {
|
|
// no connection for the pid
|
|
return []ConnectionStat{}, nil
|
|
}
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cound not get pid(s), %d: %s", pid, err)
|
|
}
|
|
return statsFromInodes(root, pid, tmap, inodes, skipUids)
|
|
}
|