Common interface for NIC statistics
In Linux 5.13 ethtool gains an interface for querying IEEE and IETF statistics. This removes the need to parse vendor specific strings in ethtool -S.
Linux has two sources of NIC statistics, the common interface stats (which show up in ifconfig, ip link, sysfs and few other places) and ethtool -S. The former – common interface stats – are a mix of basic info (packets, bytes, drops, errors in each direction) and a handful of lower level stats like CRC errors, framing errors, collisions or FIFO errors. Many of these statistics became either irrelevant (collisions) or semantically unclear (FIFO errors) in modern NICs.
This is why deployments increasingly depend on ethtool -S statistics for error tracking. ethtool -S is a free form list of stats provided by the driver. It started out as a place for drivers to report custom, implementation specific stats, but ended up also serving as a reporting place for new statistics as the networking standards developed.
Sadly there is no commonality in how vendors name their ethtool statistics. The spelling and abbreviation of IEEE stats always differ, sometimes the names chosen do not resemble the standard names at all (reportedly because vendors consider those names “too confusing” for the users). This forces infrastructure teams to maintain translations and custom per-vendor logic to scrape ethtool -S output.
Starting with Linux 5.6 Michal Kubecek has been progressively porting ethtool from ioctls to a more structured and extensible netlink interface. Thanks to that we can now augment the old commands to carry statistics. When user specifies
-I | --include-statistics on the command line (or the appropriate flag in netlink) kernel will include relevant statistics in its response, e.g. for flow control:
# ethtool -I -a eth0 Pause parameters for eth0: Autonegotiate: off RX: off TX: on Statistics: tx_pause_frames: 25545561 rx_pause_frames: 0
General statistics such as PHY and MAC counters are now available via ethtool -S under standard-based names though a new
--groups switch, e.g.:
# ethtool -S eth0 --groups eth-mac Standard stats for eth0: eth-mac-FramesTransmittedOK: 902623288966 eth-mac-FramesReceivedOK: 28727667047 eth-mac-FrameCheckSequenceErrors: 1 eth-mac-AlignmentErrors: 0 eth-mac-OutOfRangeLengthField: 0
Each of the commands supports JSON-formatted output for ease of parsing (
So little, so late
Admittedly the new interface is quite basic. It mostly includes statistics provided in IEEE or IETF standards, and NICs may report more interesting data. There is also no metadata about “freshness” of the stats here, or filtering built into the interface.
The starting point is based on fulfilling immediate needs. We hope the interfaces will be extended as needed. Statistics can be made arbitrarily complex, so after a couple false-starts with complex interfaces we decided to let the use cases drive the interface.
It’s also very useful to lean on the standards for clear definition of the semantics. Going forward we can work with vendors on codifying the definitions of other counters they have.
List of currently supported stats
IEEE 802.3 attributes::
126.96.36.199.5 aSymbolErrorDuringCarrier 188.8.131.52.2 aFramesTransmittedOK 184.108.40.206.3 aSingleCollisionFrames 220.127.116.11.4 aMultipleCollisionFrames 18.104.22.168.5 aFramesReceivedOK 22.214.171.124.6 aFrameCheckSequenceErrors 126.96.36.199.7 aAlignmentErrors 188.8.131.52.8 aOctetsTransmittedOK 184.108.40.206.9 aFramesWithDeferredXmissions 220.127.116.11.10 aLateCollisions 18.104.22.168.11 aFramesAbortedDueToXSColls 22.214.171.124.12 aFramesLostDueToIntMACXmitError 126.96.36.199.13 aCarrierSenseErrors 188.8.131.52.14 aOctetsReceivedOK 184.108.40.206.15 aFramesLostDueToIntMACRcvError 220.127.116.11.18 aMulticastFramesXmittedOK 18.104.22.168.19 aBroadcastFramesXmittedOK 22.214.171.124.20 aFramesWithExcessiveDeferral 126.96.36.199.21 aMulticastFramesReceivedOK 188.8.131.52.22 aBroadcastFramesReceivedOK 184.108.40.206.23 aInRangeLengthErrors 220.127.116.11.24 aOutOfRangeLengthField 18.104.22.168.25 aFrameTooLongErrors 22.214.171.124 aMACControlFramesTransmitted 126.96.36.199 aMACControlFramesReceived 188.8.131.52 aUnsupportedOpcodesReceived 184.108.40.206 aPAUSEMACCtrlFramesTransmitted 220.127.116.11 aPAUSEMACCtrlFramesReceived 18.104.22.168.17 aFECCorrectedBlocks 22.214.171.124.18 aFECUncorrectableBlocks
IETF RMON (RFC 2819)
etherStatsUndersizePkts etherStatsOversizePkts etherStatsFragments etherStatsJabbers etherStatsPkts64Octets etherStatsPkts65to127Octets etherStatsPkts128to255Octets etherStatsPkts256to511Octets etherStatsPkts512to1023Octets etherStatsPkts1024to1518Octets (incl. further stats for jumbo MTUs)