Instantly share code, notes, and snippets.

@trick77 /rigcheck.sh
Last active Aug 14, 2018

Embed
What would you like to do?
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
@krtschmr

This comment has been minimized.

Show comment
Hide comment
@krtschmr

krtschmr Mar 8, 2018

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

krtschmr commented Mar 8, 2018

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

@rduchin

This comment has been minimized.

Show comment
Hide comment
@rduchin

rduchin Aug 14, 2018

how would i deploy this

rduchin commented Aug 14, 2018

how would i deploy this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment