Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2012 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/306a5dacb91607b9f495 to your computer and use it in GitHub Desktop.
Save anonymous/306a5dacb91607b9f495 to your computer and use it in GitHub Desktop.
#!/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