You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm using sysinfo 0.26 on CentOS 7.
Sysinfo is reading /sys/class/net for interface list, but setting network namespace will not refresh sysfs, making it impossible for sysinfo to read statistics for interfaces in the new namespace.
To Reproduce
The code:
use sysinfo::{System, SystemExt, NetworksExt};
fn main() {
let mut system = System::new();
system.refresh_networks_list();
system.networks().iter().for_each(|(s, _)| println!("{}", s));
}
Compile this code as netns and run it under CentOS 7:
[root@mars-1 ~]# ip netns add test
[root@mars-1 ~]# nsenter --net=/var/run/netns/test ip a
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
[root@mars-1 ~]# nsenter --net=/var/run/netns/test ./netns
cali90f3eb8a8da
calif27411bfc29
cali31894e8eb51
cali05f070dffe3
calia118c7520e3
lo
cali577f4fcaaf9
tunl0
... (more)
A possible fix is to use netlink to retrieve interface statistics.
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm using sysinfo 0.26 on CentOS 7.
Sysinfo is reading
/sys/class/net
for interface list, but setting network namespace will not refresh sysfs, making it impossible for sysinfo to read statistics for interfaces in the new namespace.To Reproduce
The code:
Compile this code as
netns
and run it under CentOS 7:A possible fix is to use
netlink
to retrieve interface statistics.The text was updated successfully, but these errors were encountered: