Skip to content

read dev and tcp files with specific pid ##218

Closed
shippomx wants to merge 1 commit intoeminence:masterfrom
shippomx:master
Closed

read dev and tcp files with specific pid ##218
shippomx wants to merge 1 commit intoeminence:masterfrom
shippomx:master

Conversation

@shippomx
Copy link

@shippomx shippomx commented Nov 30, 2022

I have to write some kata-containers metrics interface, which will use the specific /proc/{pid}/net/tcp file. And some one has mentioned this problem one yeas ago. #126.

for some mistake, i had add libc package to reference pid_t type, but this pr i removed it, and test this function in examples/interface_stats.rs

Comment on lines +352 to +356
pub fn tcp_with_pid(pid: i32) -> ProcResult<Vec<TcpNetEntry>> {
let file = FileWrapper::open(format!("/proc/{}/net/tcp", pid))?;

read_tcp_table(BufReader::new(file))
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure how this new function is different from Process::tcp()

Comment on lines +669 to +672
pub fn dev_status_with_pid(pid: i32) -> ProcResult<HashMap<String, DeviceStatus>> {
let file = FileWrapper::open(format!("/proc/{}/net/dev", pid))?;
read_dev_status(file)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be part of the Process struct

eminence added a commit that referenced this pull request Dec 18, 2022
The functions in the `net` module all read from the `/proc/net` symlink,
which always points to the current process.

These new functions read from `/proc/pid/net`

Closes #126
Supersedes #218
@eminence
Copy link
Owner

hi @shippomx -- I just merged #226, which supersedes your pull request, so I'm going to close this. Thank you though for your PR.

@eminence eminence closed this Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants