@tony-yin
        
        2017-08-20T08:46:01.000000Z
        字数 1110
        阅读 812
    Magicloud
MAC和busid
syspath = os.path.join("/sys/class/net/", interface) // interface such as 'eth0'mac = linecache.getline(os.path.join(syspath, "address"), 1)[:-1].upper()buspath = os.path.realpath(syspath)bus_id = os.path.basename(os.path.dirname(os.path.dirname(buspath)))
syspath目录下读取address文件eth0,查看eth0目录可见该目录被建立了软连接,并不是真实地址,所以需要取出它的真实地址,这个需要使用python中的os.path.realpath()处理获得0000:03:00.0,作为下一步lspci的参数
root@ceph133:/sys/class/net# ll eth0lrwxrwxrwx 1 root root 0 8月 8 01:26 eth0 -> ../../devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eth0/
lspci -s后面的参数为pci设备的地址,也叫pci寻址,这个地址由总线编号、插槽编号和功能块编号信息组成
lspci -m -s xxx // 这边的参数就是上面的bus_id
具体
lspci信息请参照:
lspci命令详解
LSPCI命令详解分析
ethtool工具获取网卡状态,就是看Link detected是否为yes,yes表示已激活
/sbin/ethtool eth0 | grep 'Link detected: yes' | wc -l
目前无论是storage还是public网卡只要down其中一个都无法发送email:
monitor除这两个以外的网卡Python
