-
-
Save anonymous/306a5dacb91607b9f495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
a=`ping -c2 ya.ru|grep round|awk -F"/" '{ print $6 }'|awk -F"." '{ print $1}'` | |
b=1000 | |
ip="195.239.81.51" | |
UP=`/sbin/ifconfig carp0 up` | |
DOWN=`/sbin/ifconfig carp0 down` | |
CHK=`/sbin/ifconfig carp0|grep UP` | |
p=`ping -q -c 3 -i 1 $ip | grep '100.0% packet loss' &>/dev/null` | |
if [ "$a" -le "$b" ] && [ -z "$p" ]; | |
then | |
if [ -z $CHK ]; then /sbin/ifconfig carp0 up && echo "OK BEELINE"`date`; fi | |
fi | |
if [ "$a" -le "$b" ] && [ -n "$p" ]; then /sbin/ifconfig carp0 up&&echo "change to BEELINE"`date`; fi | |
if [ "$a" -ge "$b" ] && [ -z "$p" ]; then /sbin/ifconfig carp0 down&&echo "change to MEGAPOLIS"; fi | |
if [ "$a" -ge "$b" ] && [ -n "$p" ]; then echo "OK MEGAPOLIS"`date`; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment