Chinaunix首页 | 论坛 | 博客
  • 博客访问: 589042
  • 博文数量: 50
  • 博客积分: 4764
  • 博客等级: 上校
  • 技术积分: 597
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-18 09:00
个人简介

资深IT码农,擅长Linux、C/C++、bash

文章分类

全部博文(50)

文章存档

2015年(17)

2014年(2)

2011年(7)

2010年(4)

2009年(20)

分类: 系统运维

2009-10-21 15:04:59

得到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)

阅读(2274) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~