Here's an updated script that tries to keep temps consistent. What I added was the ability to view/fetch the logs though http.
#!/bin/sh
#
# Installation instructions:
# - Place in /config/hashcheck.sh
# - Set execute flag on file (chmod 0744)
# - Create log file: touch /config/log.txt
# - Create link to view from http: ln -s /config/log.txt /www/pages/.
# - Run with: /config/hashcheck.sh &
#
# How to obtain log from http
# - http://[ip of miner]/log.txt
#
# ADJUST THESE VARS ONLY --------------------------------------
#
restart=14400 #hours in seconds
#minhash=290000 #min hash rate 2900.00 ghs without the decimal
minhash=100000 #min hash rate 2900.00 ghs without the decimal
minfan=12 #min fan speed
maxfan=34 #max fan speed
mintemp=60 #min avg temp
maxtemp=65 #max avg temp
pwm=20 #starting pwm speed
maxloglines=70 #max log lines to save in file
#
#--------------------------------------------------------------
resetcgminer () {
restartcount=$((restartcount+1))
restarthash=$(cgminer-api | grep 'GHS 5s] => ' | cut -c 16-)
elapsedtime=$E
if [ "$1" = "1" ]; then
logger "| applying new fan speed"
sed -i "/bitmain-fan-pwm/c\"bitmain-fan-pwm\" : \"$pwm\"," /config/cgminer.conf
fi
logger "| restarting cgminer"
/etc/init.d/cgminer.sh stop > /dev/null
sleep 5
/etc/init.d/cgminer.sh start > /dev/null
logger "| miner restarted: $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), up at $restarttime for $elapsedtime seconds"
tailit
sleep 60
}
getstats () {
S=$(cgminer-api | grep 'GHS 5s] => ' | cut -c 16- | tr -d '.')
E=$(cgminer-api summary | grep 'Elapsed]' | cut -c 17-)
T=$(cgminer-api stats | grep 'temp_avg] =>' | cut -c 18-)
T1=$(cgminer-api stats | grep 'temp1] =>' | cut -c 15-)
T2=$(cgminer-api stats | grep 'temp2] =>' | cut -c 15-)
T3=$(cgminer-api stats | grep 'temp3] =>' | cut -c 15-)
HASH=$(cgminer-api | grep 'GHS 5s] => ' | cut -c 16-)
}
logger () {
echo $(date +%Y-%m-%d:%H:%M:%S) "$1 " >> /config/log.txt
}
tailit () {
tail -$maxloglines /config/log.txt > /config/log2.txt && cp /config/log2.txt /config/log.txt
}
rm /config/log.txt
touch /config/log.txt
logger "| hashcheck monitor started. reboot every $restart seconds or if hash lower than $minhash Ghs"
logger "| tempcheck monitor started"
restartcount=0
T=0
T1=0
T2=0
T3=0
PCT="%"
resetcgminer 1
sleep 60
while true
do
getstats
if [ $T1 -gt "75" ] || [ $T2 -gt "75" ] || [ $T3 -gt "75" ] && [ $pwm -lt "100" ]; then
pwm=100
logger "| failed too hot: setting fan to 100$PCT, $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 1
continue
fi
if [ $E -gt $restart ]; then
logger "| miner scheduled restart: $restarthash GH/s, $T1 $T2 $T3 deg ($T AVG), up for $elapsedtime seconds"
resetcgminer 0
continue
fi
if [ -z "S$" ] || [ $S -eq "0" ]; then
logger "| failed low hash: $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 0
continue
fi
if [ $S -lt $minhash ] && [ $E -gt "120" ]; then
logger "| rechecking in 120s low hash: $HASH $T1 $T2 $T3 deg, $restartcount restarts"
sleep 120
getstats
if [ $S -lt $minhash ]; then
logger "| failed low hash: $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 0
continue
else
logger "| recovered: $HASH MH/s, $E seconds, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
fi
fi
if [ $T -lt $mintemp ] && [ $pwm -gt $minfan ] && [ $E -gt "120" ]; then
logger "| rechecking in 120s low temp: $HASH GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
sleep 120
getstats
if [ $S -lt $minhash ]; then
logger "| failed low hash: $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 0
continue
else
if [ $T -lt $mintemp ] && [ $pwm -gt $minfan ]; then
pwm=$((pwm-2))
logger "| failed too cold: setting fan to $pwm$PCT, $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 1
continue
else
logger "| recovered: $HASH GH/s, $E seconds, $T1 $T2 $T3 deg ($T avg)"
fi
fi
fi
if [ $T -gt $maxtemp ] && [ $pwm -lt $maxfan ] && [ $E -gt "120" ]; then
pwm=$((pwm+2))
logger "| failed too hot: setting fan to $pwm$PCT, $restarthash GH/s, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
resetcgminer 1
continue
else
logger "| normal operation: fan at $pwm$PCT, $HASH GH/s, $E seconds, $T1 $T2 $T3 deg ($T avg), $restartcount restarts"
fi
tailit
sleep 60
done