得到ethX对应网卡控制器信息

2371阅读 0评论2009-10-21 seaquester
分类:系统运维

得到ethX对应网卡控制器信息

冷胜魁(Seaquester)
lengshengkui@gmail.com
2009-10-21

由于某种原因,需要知道每一个ehtX对应的网卡控制器(网卡芯片)的信息,所以写了下面的脚本。

#!/bin/bash
#List the ethernet controller info of ethX

ETH_PCI=`find /sys/devices/ -print | grep eth | awk -F"/" '{print $(NF-1)}'`

for i in $ETH_PCI ; do

    eth=`find /sys/devices/ -print | grep eth | grep $i | awk -F"/" '{print $(NF)}' | awk -F":" '{print $2}'`
    echo -n "$eth: "
    if [ -f ./pci.ids ] ; then
        lspci -s$i -i ./pci.ids
    else
        lspci -s$i
    fi
done

执行结果如下:
 
eth0: 00:19.0 Ethernet controller: Intel Corporation 82567LM-2 Gigabit Network Connection
eth2: 02:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit Network Connection
eth1: 02:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit Network Connection
eth6: 06:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
eth4: 06:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
eth5: 08:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
eth3: 08:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)

上一篇:修改svn log的脚本
下一篇:没有makefile也可以make