Last active
August 29, 2015 14:15
-
-
Save tyr0chen/065c0c8cf4cc95b209f2 to your computer and use it in GitHub Desktop.
monitor ps of adbyby for openwrt.
This file contains hidden or 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/bash | |
log_file=/mnt/sda3/log/adbyby.log | |
echo " | |
To:[email protected] | |
From:[email protected] | |
Subject:Netgear 3800 overload warning | |
I'm sorry to tell you the overload up to 5. | |
" > /tmp/mail.txt | |
dodo() { | |
while [ "1" ]; | |
do | |
cc=`ps | grep adby | grep -v grep | grep -v catch` | |
load=`uptime |sed -e 's/.*://g' -e 's/,.*//g' -e 's/\..*//g'` | |
echo "`date` now overload is `uptime |sed -e 's/.*://g'`" >> $log_file | |
if [ $((load)) -ge "5" ];then | |
echo "`date` overload up to $load" >>$log_file | |
killall adbyby &>/dev/null | |
echo " trying to killall adbyby process" >> $log_file | |
ssmtp [email protected] < /tmp/mail.txt | |
echo " trying to send mail to [email protected]" >>$log_file | |
#echo " sleeping 120s">>$log_file | |
fi | |
if [ -z "$cc" ];then | |
echo "`date` didn't find adbyby,try to run it.">>$log_file | |
/mnt/sda3/adbyby/bin/adbyby >/dev/null 2>&1 | |
fi | |
sleep 4 | |
done | |
} | |
dodo & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment