0

I'm looking through the D-Bus API for Network Manager, on Centos Stream 8, and for the entire org.freedesktop.NetworkManager.Device.Statistics interface all the properties are showing 0 including RxBytes and TxBytes. This is for all network interfaces including the active ethernet port being used to log into the machine and the loopback.

Is there some other object type that actually has this information? Is the interface deprecated? Do I need to run a method to start recording somewhere? Do I need to subscribe to changes somehow? Is this related to nm-settings-ifcfg-rh?

Netstat has no problem reporting these stats. And Ubuntu 22.04 reports them but only for loopback.

Edit: I thought I was on the Ubuntu device but actually it was the Centos box.

1
  • Could be a bug worth reporting. Works here but I use NetworkManager-1.38.4-1.fc36.x86_64 which is a far newer version. Commented Aug 26, 2022 at 5:50

1 Answer 1

1

These transfer statistics basically poll kernel API, which has some (tiny?) overhead and is disabled by default.

It is actually the same, as getting the information yourself from netlink.

Anyway, to enable this polling, set

busctl set-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/2 org.freedesktop.NetworkManager.Device.Statistics RefreshRateMs u 1000

where the D-Bus path is the one you get from nmcli -g GENERAL.DBUS-PATH device show eth0.

Do I need to subscribe to changes somehow?

There are these properties on D-Bus, which keep updating every RefreshRateMs millseconds. You could either poll this property, or listen to signals. The latter implies that you "subscribe" to the PropertiesChanged D-Bus signal

4
  • Are the quantities only during the sample period? Or does that still need to be calculated manually? Commented Aug 30, 2022 at 17:33
  • if you set RefreshRateMs to a non-zero value, then NM will automatically refresh (poll) the values at least every RefreshRateMs milliseconds. The sample period is on, until you reset RefreshRateMs to zero. Commented Aug 31, 2022 at 19:17
  • Sorry about the misunderstanding. I was hoping maybe it would give statistics only for the measured period of time rather than the total bytes for the life of the interface, which is already easily accessible in /proc. It sounds like you still need to subtract your current value from your past value so you can't just feed this into something like a network performance chart. Commented Aug 31, 2022 at 22:13
  • that's right. It would be an interesting feature, to expose also the current throughput per RefreshRateMs (possibly still integrating and smartly averaging over the past few RefreshRateMs intervals). The first problem is that nobody sent a patch for that. The other problem is, how to choose a "smart averaging" algorithm that is really generally useful to many users. Currently, they can implement their own integration in any way they want. Commented Sep 1, 2022 at 10:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.