Skip to content

Instantly share code, notes, and snippets.

@vmlinz
Created October 14, 2015 17:43
Show Gist options
  • Save vmlinz/b42e36faca79c0c7e8cb to your computer and use it in GitHub Desktop.
Save vmlinz/b42e36faca79c0c7e8cb to your computer and use it in GitHub Desktop.
Shadowsocks network monitor
#!/bin/sh
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
wget -4 --spider --quiet --tries=1 --timeout=3 www.google.co.jp
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] No Problem.'
exit 0
else
wget -4 --spider --quiet --tries=1 --timeout=3 www.baidu.com
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] Problem decteted, restarting shadowsocks.'
/etc/init.d/shadowsocks restart
else
echo '['$LOGTIME'] Network Problem. Do nothing.'
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment