2

Is there any way to get rx_broadcast value from /sys/class/net/<intf>/..?

I am using the following commands ETHTOOL_GSTATS and SIOCETHTOOL for IOCTL to get the ethernet statistics, but I am interested in some script which reads the values from /sys/class/net

I looked into /sys/class/net/..., but could not find any entry.

3
+25

Is there any way to get rx_broadcast value from /sys/class/net//..?

No, as it says at https://www.kernel.org/doc/html/latest/networking/statistics.html:

Each device directory in sysfs contains a statistics directory (e.g. /sys/class/net/lo/statistics/) with files corresponding to members of struct rtnl_link_stats64.

and rtnl_link_stats64 doesn't have a field representing rx_broadcast.

Notice that there is a ready to use tool called ethtool maintained at https://git.kernel.org/pub/scm/network/ethtool/ethtool.git that you can use in your script:

$ ethtool -S eth0 | grep rx_broadcast
     rx_broadcast: 48728

If you don't want to add new programs to your system or write C programs that use ioctl() you have to use another scripting language that is available on your system and has ioctl support built-in, for example ethtool -S in Python.

2
  • In the above command is that value in bytes or packets?
    – IrAM
    Aug 4 at 2:38
  • I think it depends on the driver, e1000e for example reports it in packets. Aug 7 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.