利用ansible监控空远程机连通性的shell脚本,ansibleshell


#!/bin/bash
#by fuqiang
#2018-08-13

cd /home/ansible/
ansible vpn -m ping  > log/ping-vpn.log
num=`cat log/ping-vpn.log | grep -o 'SUCCESS' | wc -l`

if [ $num -ne 2 ];then 
   sendEmail -f monitor-xxx@139.com -t fuxxx@skieer.com -s smtp.139.com -u "vpn-ssr machines ping errors!" -xu monitor-xxx@139.com -xp harry*** -m "1.vpn-ssr machines ping errors; 2.Please to see the mail attachment file." -a /home/ansible/log/ping-vpn.log
fi

if [ $num -eq 2 ];then 
   echo 'No errors!' > /home/ansible/log/NoErrors-ping-vpn.log
fi

相关内容

    暂无相关文章