Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# ALERT CONDITION: STATUS = DOWN
GATEWAY=$2
STATUS=$3
function REPORT {
GWINFO DESCRIPTION "" $GATEWAY | VIEWER
GWINFO DESCRIPTION "" $GATEWAY | MAIL
echo | MAIL
GWINFO STAT | MAIL
echo | MAIL
GWINFO LIST | MAIL
GWINFO DESCRIPTION "" $GATEWAY | SMS
echo | SMS
GWINFO STAT MLines | SMS
}
function DOWNVPN {
for d in /var/register/system/net/interfaces/*/;
do if [[ $(cat "$d"Gateway) == "$GATEWAY" ]]; then
$(/root/kerbynet.cgi/scripts/net_updown IF,$(basename $d) false);
fi;
done ;
}
function UPVPN {
for d in /var/register/system/net/interfaces/*/;
do if [[ $(cat "$d"Gateway) == "$GATEWAY" ]]; then
$(/root/kerbynet.cgi/scripts/net_updown IF,$(basename $d) true);
fi;
done ;
}
if ! SYSTEM_STARTED ; then
sleep 45.23
fi
sleep 9.13
if [ "$STATUS" = DOWN ] ; then
if GWINFO OK '' $GATEWAY ; then
CANCEL
exit
fi
else
if ! GWINFO OK '' $GATEWAY ; then
CANCEL
exit
fi
fi
if [ -f "$STATEDIR/Faults/$GATEWAY" ] ; then
if [ "$STATUS" = UP ] ; then
rm "$STATEDIR/Faults/$GATEWAY"
if ! ls $STATEDIR/Faults/* 2>/dev/null >/dev/null ; then
RECOVERED
UPVPN
fi
REPORT
else
CANCEL
fi
else
if [ "$STATUS" = DOWN ] ; then
ALERT
mkdir -p $STATEDIR/Faults
touch "$STATEDIR/Faults/$GATEWAY"
REPORT
DOWNVPN
else
CANCEL
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.