[关闭]
@tony-yin 2017-08-20T08:46:01.000000Z 字数 1110 阅读 489

Network Down Alert

Magicloud


get role interfaces

get interfaces

get interface info

  1. 获取MACbusid
  1. syspath = os.path.join("/sys/class/net/", interface) // interface such as 'eth0'
  2. mac = linecache.getline(os.path.join(syspath, "address"), 1)[:-1].upper()
  3. buspath = os.path.realpath(syspath)
  4. bus_id = os.path.basename(os.path.dirname(os.path.dirname(buspath)))
  1. root@ceph133:/sys/class/net# ll eth0
  2. lrwxrwxrwx 1 root root 0 8 8 01:26 eth0 -> ../../devices/pci0000:00/0000:00:15.0/0000:03:00.0/net/eth0/
  1. 获取网卡信息
    lspci -s后面的参数为pci设备的地址,也叫pci寻址,这个地址由总线编号、插槽编号和功能块编号信息组成
  1. lspci -m -s xxx // 这边的参数就是上面的bus_id

具体lspci信息请参照:
lspci命令详解
LSPCI命令详解分析

  1. 获取网卡状态
    通过ethtool工具获取网卡状态,就是看Link detected是否为yesyes表示已激活
  1. /sbin/ethtool eth0 | grep 'Link detected: yes' | wc -l

bond filter

Network down notification

  1. 目前无论是storage还是public网卡只要down其中一个都无法发送email:

    • public: visit foreign network and connect smtp server
    • storage: connect ceph rados to get notification info, such as send account and smtp server etc
      所以只能monitor除这两个以外的网卡
  2. Python

    • log打印的文件取决于当前文件进程的初始化log level
    • logger: handler, formatter, filter
    • dictdefault
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注