我想运行一个脚本来检查我的网络接口(interface)是否打开/关闭。如果正常则发送一个 SNMP Trap,如果正常则发送另一个。
ip a ||
while read LINE; do
if [[ $LINE == *"2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000"* ]]; then
TRAP 1
else
TRAP 2
你有什么建议吗?
最佳答案
你可以尝试这样的事情:
while [ 1 ]; do
sleep 1
IS_UP=$(ip a | grep "IFACE:" | grep "state UP")
if [ "${IS_UP}x" == "x" ]; then
TRAP 2
else
TRAP 1
fi
done
将 IFACE 替换为您感兴趣的界面。希望这可以帮助! :)
关于linux - 如果 eth0 关闭/启动,如何发送不同的 SNMP 陷阱?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50043839/