Collecting SFP+ attributes in Linux

13,993

To collect info about plugged modules you can use ethtool --module-info <iface> command. This command doesn't require activation of interface.

Start from this small script:

#!/bin/sh

for IFACE in $( ls /sys/class/net/ )
do
    /sbin/ethtool --module-info ${IFACE} > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo ${IFACE}
        /sbin/ethtool --module-info ${IFACE}
    fi
done
exit 0

Customize it for your needs.

Share:
13,993

Related videos on Youtube

Lubos A.
Author by

Lubos A.

Updated on September 18, 2022

Comments

  • Lubos A.
    Lubos A. almost 2 years

    I need to collect hw component inventory from physical systems running RHEL (6 and 7) and its derivatives. I need to collect the SFP+ attributes along with the rest of the components. I know I can easily get this with ethtool, as long as the interface and the link is up. Is there any way to get this info for all the SFPs from all the ports including those that are down?

    Thank you in advance.

  • Lubos A.
    Lubos A. about 5 years
    I'm getting 'Cannot get module EEPROM information. Operation not supported' when trying to pull this info off the interfaces that do not have a link on. Bringing up an interface at the OS level does not help. It seems to require a link on to be able to get the SFP attributes. Any other suggestions?
  • Anton Danilov
    Anton Danilov about 5 years
    Try to update the ethtool. In my systems (various versions of debian) it works perfectly - enough plug in a SFP module into a network card. pastebin.com/3q0DnGtv
  • Lubos A.
    Lubos A. about 5 years
    This is very interesting. I have the same version, and now I'm wondering if this depends on the NIC support. So far I have tried this only with the Solarflare. You seem to be using Intel. Have you come across any other method of pulling this data from the NIC without relying on ethtool?
  • Anton Danilov
    Anton Danilov about 5 years
    Depends on what data you want to collect. But the SFP module properties can be get only through driver of NIC, because these values are gotten through internal i2c bus on NIC. So details of this process is implemented in the driver. Maybe in your case this data can be found somewhere in /sys filesystem without call of the ethtool.