|
|
|
@ -222,7 +222,7 @@ func (p *Process) IsRunning() (bool, error) {
|
|
|
|
|
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
var ret []MemoryMapsStat
|
|
|
|
|
smapsPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "smaps")
|
|
|
|
|
smapsPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "smaps")
|
|
|
|
|
contents, err := ioutil.ReadFile(smapsPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -303,7 +303,7 @@ func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
|
|
|
|
// Get num_fds from /proc/(pid)/fd
|
|
|
|
|
func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
statPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "fd")
|
|
|
|
|
statPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "fd")
|
|
|
|
|
d, err := os.Open(statPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, nil, err
|
|
|
|
@ -336,7 +336,7 @@ func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
|
|
|
|
|
// Get cwd from /proc/(pid)/cwd
|
|
|
|
|
func (p *Process) fillFromCwd() (string, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
cwdPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "cwd")
|
|
|
|
|
cwdPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "cwd")
|
|
|
|
|
cwd, err := os.Readlink(cwdPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
@ -347,7 +347,7 @@ func (p *Process) fillFromCwd() (string, error) {
|
|
|
|
|
// Get exe from /proc/(pid)/exe
|
|
|
|
|
func (p *Process) fillFromExe() (string, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
exePath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "exe")
|
|
|
|
|
exePath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "exe")
|
|
|
|
|
exe, err := os.Readlink(exePath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
@ -358,7 +358,7 @@ func (p *Process) fillFromExe() (string, error) {
|
|
|
|
|
// Get cmdline from /proc/(pid)/cmdline
|
|
|
|
|
func (p *Process) fillFromCmdline() (string, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
cmdPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "cmdline")
|
|
|
|
|
cmdPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "cmdline")
|
|
|
|
|
cmdline, err := ioutil.ReadFile(cmdPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
@ -376,7 +376,7 @@ func (p *Process) fillFromCmdline() (string, error) {
|
|
|
|
|
// Get IO status from /proc/(pid)/io
|
|
|
|
|
func (p *Process) fillFromIO() (*IOCountersStat, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
ioPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "io")
|
|
|
|
|
ioPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "io")
|
|
|
|
|
ioline, err := ioutil.ReadFile(ioPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -415,7 +415,7 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
|
|
|
|
|
// Get memory info from /proc/(pid)/statm
|
|
|
|
|
func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
memPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "statm")
|
|
|
|
|
memPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "statm")
|
|
|
|
|
contents, err := ioutil.ReadFile(memPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
@ -467,7 +467,7 @@ func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
|
|
|
|
|
// Get various status from /proc/(pid)/status
|
|
|
|
|
func (p *Process) fillFromStatus() error {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
statPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "status")
|
|
|
|
|
statPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "status")
|
|
|
|
|
contents, err := ioutil.ReadFile(statPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
@ -554,7 +554,7 @@ func (p *Process) fillFromStatus() error {
|
|
|
|
|
|
|
|
|
|
func (p *Process) fillFromStat() (string, int32, *cpu.CPUTimesStat, int64, int32, error) {
|
|
|
|
|
pid := p.Pid
|
|
|
|
|
statPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "stat")
|
|
|
|
|
statPath := filepath.Join(common.GetEnv("HOST_PROC", "/proc"), strconv.Itoa(int(pid)), "stat")
|
|
|
|
|
contents, err := ioutil.ReadFile(statPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", 0, nil, 0, 0, err
|
|
|
|
@ -610,7 +610,7 @@ func (p *Process) fillFromStat() (string, int32, *cpu.CPUTimesStat, int64, int32
|
|
|
|
|
func Pids() ([]int32, error) {
|
|
|
|
|
var ret []int32
|
|
|
|
|
|
|
|
|
|
d, err := os.Open("/proc")
|
|
|
|
|
d, err := os.Open(common.GetEnv("HOST_PROC", "/proc"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|