[root@controller01 ~]# cat bond.sh #!/bin/bashecho"eno3:"ifgrep-q"eno3" /proc/net/bonding/bond0 ;thenecho"/proc/net/bonding/bond0 :"`ip a |grep eno3`cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface: eno3"elseecho"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"ip a |grep eno3
echo"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"fiecho __________________________________________________________________
echo-e"\n"echo"ens6f0"ifgrep-q"ens6f0" /proc/net/bonding/bond0 ;thenecho"/proc/net/bonding/bond0 :"`ip a |grep ens6f0`cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface: ens6f0"elseecho"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"echo"/proc/net/bonding/bond0 :"`ip a |grep eno3`cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface: eno3"echo"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"fiecho-e"\n"up=`cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface"|egrep-A1 eno3 |grep MII |awk'{print $3}'`if[$up="down"];thenecho"eno3:"echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface: eno3"ip a |grep ens5f0echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"else#为up不输出内容,下面放个echo是为了不让脚本报错echofiecho-e"\n"up=`cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface"|egrep-A1 ens6f0 |grep MII |awk'{print $3}'`if[$up="down"];thenecho"ens6f0:"echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"cat /proc/net/bonding/bond0 |egrep-A1"Slave Interface: ens6f0"ip a |grep ens6f0echo"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"elseechofi
脚本测试
正常场景
2个网卡都正常的情况下,输出内容为下面
[root@compute31 ~]# sh bond.sh
ens5f0:
/proc/net/bonding/bond0 :8: ens5f0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
Slave Interface: ens5f0
MII Status: up
__________________________________________________________________ens6f0
/proc/net/bonding/bond0 :
1、
from ming import * # 有点像C语言中的头文件
"""在Python开发环境中,封装一个函数,功能目标为:通过两个整数参数一次性获取和、差、积、商四个值
"""
def calc(a, b):return a b, a - b, a * b, a / b…