Repository navigation
Expose network link speed #300
Description
Activity
If this is available via proc/sysfs it should be possible. If it's available via netlink it's also possible, but we don't have support for this yet.
Seems the Linux way is an
ioctl:-/http://stackoverflow.com/questions/2872058/get-link-speed-programmatically
Confirmed that
ethtoolalso uses this to get interface stats.Ah,
/sys/class/net/<device>/speedseems to work in some cases. At least it did for me foreth0.See also http://stackoverflow.com/questions/36262078/how-to-get-network-speed-in-linux-using-golang
+1
It would also be nice to directly expose link states. Looking over the code/strace of
ip link, the tool gets things from netlink. But similar information is available via/sys/class/net/...$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s25: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff 3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff 6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ffThis may also provide a nice info metric that would let users map devices to mac address.
Reacted by anarcat/cc @mdlayher
This screams rtnetlink to me. Probably doable, but I'm working on some improvements to my netlink packages before I have time to tackle this.
hi, any progress on this one? Thanks
This is also related to #794. We need to add support for the sysfs data in the procfs library, or as @mdlayher says, implement this via netlink.
@klatys Any ability to sponsor this work? As the node_exporter is a purely volunteer maintained project, we currently don't have the resources to implement things on any kind of schedule. 😢
@klatys We're trying to move more of the procfs/sysfs parsing code to our procfs librarary so the code is more reusable.
Np, I’ll check it out and get back to you.
@klatys Yes, something like that, but there's no need to do anything with json, just use Go structs. Take a look at the other code in the procfs repo.
@SuperQ yes, that was wrong naming of a tag, the struct is actually used, the tag I took was based on
net_dev.go. I changed it's name - It's for identifying filename to be scraped (which is different from other modules as far as I can tell). I opened a pull request, hope it's ok now, otherwise feel free to commentThanks! It looks OK to me, but I'd like to have the other maintainers take a look at it.
Reacted by Jan Klat and Haoyu WangSolved by #851
Reacted by Christian Hoffmann
It would be nice if the exporter could expose the network interface link speed, this would permit us to calculate net utilization %