Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # A watchdog for minerd
- # v0.0.1 by MasTi
- #
- # Q: why? I never ever even thought about a watchdog, minerd runs rockstable since months on all my rigs, never had any issues with it!
- # A: You are right, same here, however my Fat Lady (Playstation 3) seems to have some stability problems!
- # Probably because it was not designed to run 24/7 under full workload so once in a while (about 1-2 times a day)
- # one of the SPU threads on the Cell Processor suddenly stops working but minerd continues to run!
- # This will leave you with ~6kh/s less mining power and you probably won't even notice it because there are still 40 kh/s left :D
- # Well, to fire and forget minerd like on other systems I set up this little watchdog. Thats it! Enjoy!
- #
- #
- ##
- ###
- ####
- ##### EDIT THIS !! Your pool and user credentials.
- ####
- ###
- ##
- #
- # URL
- desturl="http://somepool.bit"
- #
- # Port
- destport="1234"
- #
- # username
- username="me"
- #
- # password
- password="mysecret"
- #
- ##
- ###
- ####
- ##### Advanced config! - Normally no need to change!
- ####
- ###
- ##
- #
- # Watchdog scan period
- # check every x seconds - 60 is really enough
- scantime="60"
- #
- # check for Stalerate in percent - To "disable" set to e.g. 100
- # 0.5 is a good but still high value, but you can set it to whatever you want.
- # if the watchdog determines a higher value it will stop the miner and let the system cool down the specified amout of seconds
- maxstalerate="0.44"
- #
- # Time for the system to cool down
- # stops miner for x seconds before restarting it
- cooldowntime="30"
- #
- # path to the miner - need only be changed if the miner is not the same directory as this script
- minerpath="./"
- #
- # miner executable _without_ any slashes or path - just the name
- miner="minerd"
- #
- # overviewlogfile - an overview of performed actions by the watchdog in a simple logfile
- overviewlogfile="./overview"
- #
- ##
- ###
- ####
- ##### Do NOT edit anything below this line!
- ####
- ###
- ##
- #
- # logfile (needed for watchdog(this script))
- minerlogfile="./log"
- datenow=`date`
- echo "WATCHDOG: $datenow - Starting $miner on $desturl:$destport - Worker: $username"
- echo "WATCHDOG: $datenow - watchdog interval set to $scantime seconds."
- echo "WATCHDOG: $datenow - cooldown time on error set to $cooldowntime seconds."
- echo "WATCHDOG: $datenow - thread watchdog enabled."
- echo "WATCHDOG: $datenow - stalerate watchdog enabled - limit at $maxstalerate%."
- echo "WATCHDOG: $datenow - NOTE: You have to kill the $miner process manually"
- echo "WATCHDOG: $datenow - NOTE: if you exit this script by pressing strg+c"
- echo "WATCHDOG: $datenow - NOTE: To do this just type the following into a console"
- echo "WATCHDOG: $datenow - NOTE: killall $miner"
- echo "WATCHDOG: $datenow - NOTE: Thanks for reading this, have a nice day!"
- echo "WATCHDOG: $datenow - Starting $miner on $desturl:$destport - Worker: $username" >> $overviewlogfile
- echo "WATCHDOG: $datenow - watchdog interval set to $scantime seconds." >> $overviewlogfile
- echo "WATCHDOG: $datenow - cooldown time on error set to $cooldowntime seconds." >> $overviewlogfile
- echo "WATCHDOG: $datenow - thread watchdog enabled." >> $overviewlogfile
- echo "WATCHDOG: $datenow - stalerate watchdog enabled - limit at $maxstalerate%." >> $overviewlogfile
- $minerpath$miner --url $desturl:$destport --userpass $username:$password 2>> $minerlogfile >/dev/null &
- while :
- do
- pidofminer=`pidof $miner`
- sleep $scantime
- datenow=`date`
- nullhashes=`cat ./log | tail -n 20 | grep "0.00 khash" | wc -l`
- if [ "$nullhashes" -ne "0" ]; then
- timecode=`date`
- echo "WATCHDOG: $datenow - Detected non working thread!! :( - Restarting!"
- echo "WATCHDOG: $datenow - Stopping miner for $cooldowntime seconds to let the system cool down a little..."
- echo "WATCHDOG: $datenow - Switching to new logfile. Compressing old logfile to $minerlogfile-$timecode.bz2"
- echo "WATCHDOG: $datenow - Detected non working thread!! :( - Restarting!" >> $overviewlogfile
- kill $pidofminer >/dev/null
- mv $minerlogfile $minerlogfile-"$timecode"
- bzip2 -z -f -q -s -9 $minerlogfile-"$timecode"
- sleep $cooldowntime
- $minerpath$miner --url $desturl:$destport --userpass $username:$password 2>> $minerlogfile &
- fi
- yays=`cat $minerlogfile | grep yay | wc -l`
- boos=`cat $minerlogfile | grep boo | wc -l`
- stalerate=`echo "scale=2; $boos*100/$yays" | bc -l `
- staleratetrue=`echo "scale=2; $stalerate>$maxstalerate" | bc`
- echo "WATCHDOG: $datenow - Threads: OK! - Stalerate: 0$stalerate% of allowed $maxstalerate% (Shares: $yays accepted - $boos rejected)"
- if [ "$staleratetrue" = "1" ]; then
- staleratetrue="0"
- timecode=`date`
- echo "WATCHDOG: $datenow - Stalerate 0$stalerate% ($boos/$yays) higher than allowed! ($maxstalerate%) - Restarting!"
- echo "WATCHDOG: $datenow - Stopping miner for $cooldowntime seconds to let the system cool down a little..."
- echo "WATCHDOG: $datenow - Switching to new logfile. Compressing old logfile to $minerlogfile-$timecode.bz2"
- [D echo "WATCHDOG: $datenow - Stalerate 0$stalerate% ($boos/$yays) higher than allowed! ($maxstalerate%) - Restarting!" >> $overviewlogfile
- kill $pidofminer >/dev/null
- mv $minerlogfile $minerlogfile-"$timecode" >/dev/null
- bzip2 -z -f -q -s -9 $minerlogfile-"$timecode"
- sleep $cooldowntime
- $minerpath$miner --url $desturl:$destport --userpass $username:$password 2>> $minerlogfile &
- fi
- done
Add Comment
Please, Sign In to add comment