implements Process.open_files on linux.
This commit is contained in:
parent
887f7514a4
commit
db655861e3
|
@ -91,6 +91,7 @@ Current Status
|
|||
- memory_info (linux)
|
||||
- memory_info_ex (linux)
|
||||
- Memory_maps() (linux) <- this is a function
|
||||
- open_files (linux)
|
||||
|
||||
- not yet
|
||||
|
||||
|
@ -112,7 +113,6 @@ Current Status
|
|||
- cpu_affinity
|
||||
- memory_percent
|
||||
- children
|
||||
- open_files
|
||||
- connections
|
||||
- is_running
|
||||
|
||||
|
|
|
@ -153,7 +153,24 @@ func fillFromfd(pid int32, p *Process) error {
|
|||
}
|
||||
defer d.Close()
|
||||
fnames, err := d.Readdirnames(-1)
|
||||
p.Num_fds = int32(len(fnames))
|
||||
num_fds := len(fnames)
|
||||
p.Num_fds = int32(num_fds)
|
||||
|
||||
openfiles := make([]Open_filesStat, num_fds)
|
||||
for _, fd := range fnames{
|
||||
fpath := filepath.Join(statPath, fd)
|
||||
filepath, err := os.Readlink(fpath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
o := Open_filesStat{
|
||||
Path: filepath,
|
||||
Fd: parseUint64(fd),
|
||||
}
|
||||
openfiles = append(openfiles, o)
|
||||
}
|
||||
|
||||
p.Open_files = openfiles
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue