I have this problem with one of my antminers, that randomly it will start under performing, like for example when I first turn it on it will hash fine for random amount of hours averaging 440 GH/s, but then will go to 400-410 GH/s AVG for days unless I will reboot it, sometimes needs couple of reboots.
see example here:
https://bitcointalk.org/index.php?topic=671189.4980https://bitcointalk.org/index.php?topic=671189.2820https://bitcointalk.org/index.php?topic=671189.3680user suggested restarting every hour or more often, but I wrote a script that should only restart when it is really required.
This is for advanced users only that know how to use vim or other ways of editing text file in Unix shell. And only do this with the unit that has problems with performance, do not do this with good units!
first create a file: /usr/bin/cgminer-avg-monitor
for example by issuing following command:
vim /usr/bin/cgminer-avg-monitor
#!/bin/sh
# This file is for cron job
# This if for make sure the start cgminer when there is network problem
nowtime=$(date +%s)
avglog=$(date +%s -r /usr/bin/avg.log)
age=$(( nowtime - avglog ))
if [ "$age" -lt 600 ]; then
exit 0;
else
set -x
date
avg=`/usr/bin/cgminer-api -o summary | sed -n "s/.*GHS av=\([^']*\)...,F.*/\1/p"`
if [ "$avg" -lt 439 ]; then
killall -s 9 cgminer
sleep 1
/etc/init.d/cgminer restart
echo restarted at $(date '+%Y-%m-%d-%H-%M-%S') because avg hashrate: $avg >> /usr/bin/avg.log
exit 0;
fi
fi
change file permission by:
chmod 700 /usr/bin/cgminer-avg-monitor
then back up original monitor script:
cp /usr/bin/cgminer-monitor /usr/bin/cgminer-monitor_BACKUP
and modify (or replace) it so it looks like this:
nowtime=$(date +%s)
avglog=$(date +%s -r /usr/bin/avg.log)
age=$(( nowtime - avglog ))
if [ "$age" -lt 600 ]; then
exit 0;
else
set -x
date
C=`pidof cgminer | wc -w`
if [ "$C" != "1" ]; then
echo "Case C"
killall -s 9 cgminer
sleep 1
/etc/init.d/cgminer restart
echo restarted at $(date '+%Y-%m-%d-%H-%M-%S') no process running >> /usr/bin/avg.log
exit 0;
fi
A=`cat /tmp/cm.log`
B=`cgminer-api devs | grep "^ \[Last Valid Work\]"`
echo "$B" > /tmp/cm.log
if [ "$B" != "" -a "$A" == "$B" ]; then
echo "Case B"
killall -s 9 cgminer
sleep 1
/etc/init.d/cgminer restart
echo restarted at $(date '+%Y-%m-%d-%H-%M-%S') because no valid work being done >> /usr/bin/avg.log
exit 0;
fi
D=`cgminer-api stats | grep "^ \[miner_count\]"`
if [ "$D" == "" ]; then
echo "Case D"
killall -s 9 cgminer
sleep 1
/etc/init.d/cgminer restart
echo restarted at $(date '+%Y-%m-%d-%H-%M-%S') because of miner count >> /usr/bin/avg.log
exit 0;
fi
fi
your crontab should look like this:
root@antMiner:/usr/bin# crontab -l
*/3 * * * * /usr/bin/cgminer-monitor
59 19 * * 0 reboot
0,30 * * * * /usr/bin/cgminer-avg-monitor
for safety create the log file, that is mentioned in the scripts by command:
echo START >> /usr/bin/avg.log
what will happen now:
1) as usual there will be /usr/bin/cgminer-monitor executed every 3 minutes, but will not do anything if something has already been done during last 10 minutes (600 seconds) - like a restart.
2) /usr/bin/cgminer-avg-monitor will run every 30 minutes, its purpose is to check if AVG hashrate of the miner is below 439 GH/s, if it is, then it will restart cgminer (only if it has not been done within last 10 minutes)
3) reboot antminer every sunday at 19:59... just to reboot once in a while.
UNINSTALLING:
rm /usr/bin/cgminer-monitor
mv /usr/bin/cgminer-monitor_BACKUP /usr/bin/cgminer-monitor
rm /usr/bin/cgminer-avg-monitor
rm /usr/bin/avg.log
edit crontab to its original version:
*/3 * * * * /usr/bin/cgminer-monitor
Hope someone finds this useful.
EDIT: I did this for all (2) of my units and am forgetting they exist even if internet goes offline, or losing electricity, the units will go back and will make sure they hash at 439+ GH/s even if couple of restarts are required. I found out that even the good unit will start under performing if internet goes down for a while (I know what I am talking about, I am taking into consideration only pool side 3 hour AVG after the internet is back), I know that after internet goes down in miner status it will show less AVG until rebooted and it does not show actual AVG, so I am looking at poolside - I want it to be ~880+-5% GH/s poolside and it was not hapenning before this script, I had to manually restart after downtime.