#!/bin/bash #define status STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 a=`ps -ef|grep shadowsocks-local |grep -v grep |wc -l` if [ $a -eq 0 ];then echo "CRITICAL - ShadowSocks is not running!" exit $STATE_CRITICAL fi b=`tail -n 3 /tmp/shadowsocks.log |grep -c "Failed connect to all avaiable shadowsocks server"` if [ $b -ne 0 ];then echo "CRITICAL - Failed to connect shadowsocks server!" exit $STATE_CRITICAL fi c=`tail -n 10 /tmp/shadowsocks.log |grep -c "connection timed out"` d=`tail -n 1 /tmp/shadowsocks.log |grep -c "socks handshake: EOF"` if [ $c -gt 8 -a $d -eq 0 ];then echo "WARNING - Connect to shadowsocks server timed out!" exit $STATE_WARNING fi echo "OK - ShadowSocks service is Ok!" exit $STATE_OK