I am writing an application that reports attributes of network devices on the local machine. I need the mac address, mtu, link speed and a few others. I'm using udev for this. I've already figured out how to get the mac address and mtu, but not how to get the link speed. I can get it with ethtool from the terminal, but I need a way to get it programmatically.
Does anyone know how I can get the link speed attribute with udev or another library?
You can get the link speed in bit per second using the sysfs
interface:
cat /sys/class/net/eth0/speed
1000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With