Checks for crashed ethOS mining processes
#!/bin/bash | |
LOG_FILE=/tmp/rigcheck.log | |
if grep -qv active /var/run/ethos/status.file; then | |
echo "$(date) Mining not active or currently starting, exiting..." | tee -a ${LOG_FILE} | |
exit 0 | |
fi | |
NUM_PROC=`ps uax| egrep "ccminer|cgminer-skein|claymore|dstm-zcash|ethminer|ethminer-amd|ewbf-zcash|sgminer-gm|silentarmy|optiminer-zcash" | grep -v "curl" | grep -v "update-miner" | grep -v grep | awk '{print $2}' | wc -l` | |
NUM_GPU=`cat /var/run/ethos/gpulist.raw | wc -l` | |
NEEDS_RESTART=false | |
if [ "${NUM_PROC}" != "${NUM_GPU}" ]; then | |
echo "$(date) Number of GPU (${NUM_GPU}) differs from number of mining processes (${NUM_PROC})!" | tee -a ${LOG_FILE} | |
NEEDS_RESTART=true | |
fi | |
AGE_IN_MINUTES=3 | |
for (( i = 0; i < ${NUM_GPU}; i++ )) | |
do | |
FILENAME=/var/run/miner.$i.output | |
IS_OLD=$(( (`date +%s` - `stat -L --format %Y ${FILENAME}`) > (${AGE_IN_MINUTES}*60) )) | |
if [ "${IS_OLD}" == "1" ]; then | |
NEEDS_RESTART=true | |
echo "$(date) Mining process log ${FILENAME} is older than ${AGE_IN_MINUTES} minutes!" | tee -a ${LOG_FILE} | |
fi | |
done | |
if [ "${NEEDS_RESTART}" == "true" ]; then | |
echo "$(date) Mining process crash detected, restarting mining processes..." | tee -a ${LOG_FILE} | |
/opt/ethos/bin/minestop | |
sleep 5 | |
/opt/ethos/bin/minestart | |
echo "$(date) Done restarting mining processes!" | tee -a ${LOG_FILE} | |
fi |
This comment has been minimized.
This comment has been minimized.
how would i deploy this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
sleep 5
in between the stop ^ start is useless.
if allowed (default) mining will auto-restart if you say minestop.
you only need minestart if you had disable