Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #script to monitor and autorestart vpn connections
- #date=`/bin/date +"%m%d%Y-%H%M%S"`
- #!/bin/sh
- #script to monitor and autorestart vpn connections
- APIDATE=`date +"%Y%m%d%H%M"`
- echo $APIDATE >> /LOGS/life_ukr_api_check_date.log
- tail -n 3 /LOGS/life_ukr_api_check_date.log | head -n 1 > /tmp/life_ukr_api_vpn_3_rd_restart.log
- EAPIDATE=$(cat /tmp/life_ukr_api_vpn_3_rd_restart.log)
- DIFF=$(($APIDATE-$EAPIDATE))
- echo $DIFF
- #monitor Life Ukraine - billing API
- echo "b" | telnet -e "b" 212.58.160.71 8170
- echo $?
- echo $DIFF
- if [ $? != 0 ] && $DIFF < 61
- then
- echo "first IF"
- echo "$date no telnet to life ukraine host - billing api 212.58.160.71 8170 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/ipsec restart >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/rinetd restart >> /LOGS/vpn_monitoring_script_log
- echo "b" | telnet -e "b" 212.58.160.71 8170
- elif [ $? != 0 ] && $DIFF > 61
- then
- echo "elif"
- echo "3 restart during 1h was done $date no telnet to life ukraine host - billing api 212.58.160.71 8170 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- else
- echo "else"
- echo "$date telnet to life ukraine host ok - billing api 212.58.160.71 8170" >> /LOGS/vpn_monitoring_script_log
- fi
- SMSCDATE=`date +"%Y%m%d%H%M"`
- echo $SMSCDATE >> /LOGS/life_ukr_smsc_check_date.log
- tail -n 3 /LOGS/life_ukr_smsc_check_date.log | head -n 1 > /tmp/life_ukr_smsc_vpn_3_rd_restart.log
- ESMSCDATE=$(cat /tmp/life_ukr_smsc_vpn_3_rd_restart.log)
- DIFF1=$(($SMSCDATE-$ESMSCDATE))
- echo $DIFF1
- #monitor Life Ukraine - SMSC telnet
- echo "b" | telnet -e "b" 212.58.160.139 16001
- if [ $? != 0 ] && $DIFF1 < 61
- then
- echo "$date no telnet to life ukraine host - smsc 212.58.160.139 16001 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/ipsec restart >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/rinetd restart >> /LOGS/vpn_monitoring_script_log
- echo "b" | telnet -e "b" 212.58.160.139 16001
- elif [ $? != 0 ] && $DIFF1 > 61
- then
- echo "3 restart during 1h was done $date no telnet to life ukraine host - smsc 212.58.160.139 16001 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- else
- echo "$date telnet to life ukraine host ok - smsc 212.58.160.139 16001" >> /LOGS/vpn_monitoring_script_log
- fi
- USSDCDATE=`date +"%Y%m%d%H%M"`
- echo $USSDCDATE >> /LOGS/life_ukr_ussdc_check_date.log
- tail -n 3 /LOGS/life_ukr_ussdc_check_date.log | head -n 1 > /tmp/life_ukr_ussdc_vpn_3_rd_restart.log
- EUSSDCDATE=$(cat /tmp/life_ukr_ussdc_vpn_3_rd_restart.log)
- DIFF2=$(($USSDCDATE-$EUSSDCDATE))
- echo $DIFF2
- #monitor Life Ukraine - USSDC telnet
- echo "b" | telnet -e "b" 212.58.160.142 15000
- if [ $? != 0 ] && $DIFF2 < 61
- then
- echo "$date no telnet to life ukraine host - ussdc telnet 212.58.160.142 15000!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/ipsec restart >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/rinetd restart >> /LOGS/vpn_monitoring_script_log
- echo "b" | telnet -e "b" 212.58.160.142 15000
- elif [ $? != 0 ] && $DIFF2 > 61
- then
- echo "3 restart during 1h was done $date no telnet to life ukraine host - ussdc telnet 212.58.160.142 15000!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- else
- echo "$date telnet to life ukraine host ok - ussdc telnet 212.58.160.142 15000" >> /LOGS/vpn_monitoring_script_log
- fi
- TJVPNDATE=`date +"%Y%m%d%H%M"`
- echo $TJVPNDATE >> /LOGS/megaphone_tj_vpn_check_date.log
- tail -n 3 /LOGS/megaphone_tj_vpn_check_date.log | head -n 1 > /tmp/megaphone_tj_vpn_3_rd_restart.log
- ETJVPNDATE=$(cat /tmp/megaphone_tj_vpn_3_rd_restart.log)
- DIFF3=$(($TJVPNDATE-$ETJVPNDATE))
- echo $DIFF3
- #monitor Megafon TJ VPN - Telnet SMSC
- echo "b" | telnet -e "b" 10.241.201.181 2775
- if [ $? != 0 ] && $DIFF3 < 61
- then
- echo "$date no telnet to megafon tj sms 10.241.201.181 2775 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/ipsec restart >> /LOGS/vpn_monitoring_script_log
- /etc/init.d/rinetd restart >> /LOGS/vpn_monitoring_script_log
- echo "b" | telnet -e "b" 10.241.201.181 2775
- elif [ $? != 0 ] && $DIFF3 > 61
- then
- echo "3 restarts during 1h was done $date no telnet to megafon tj sms 10.241.201.181 2775 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
- else
- echo "$date telnet to ok megafon tj sms 10.241.201.181 2775" >> /LOGS/vpn_monitoring_script_log
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement