- 论坛徽章:
- 0
|
告警文件如下
cat /var/adm/messages
Jul 19 10:51:38 10.216.48.1 544: *Nov 14 09:43:11: %LINK-3-UPDOWN: Interface FastEthernet0/9, changed state to up
Jul 19 11:29:16 10.216.48.1 546: *Nov 14 10:20:48: %LINK-3-UPDOWN: Interface FastEthernet0/9, changed state to down
Jul 19 11:30:38 10.216.48.1 548: *Nov 14 10:22:11: %LINK-3-UPDOWN: Interface FastEthernet0/9, changed state to up
其中Ip地址和节点名存在node文件中
cat node
10.216.48.1 node1
10.216.48.2 node3
告警处理程序不断检测告警文件变化,并根据设备端口down时作相应处理。希望输出结果为
node1 port changed state to down
程序为:
cat test.sh
tail -f /var/adm/messages | while read line
do
echo $line |grep "changed state to down"
if [ $? -eq 0 ]; then
IP=`echo $line |grep "changed state to down" | awk '{print $2}'`
Node=`grep $IP node | awk '{print $2}'`
echo "$Node port changed state to down"
fi
done
结果是没有任何输出,这是为什么?
谢谢! |
|