-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrm_check
31 lines (28 loc) · 2.03 KB
/
trm_check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
grep -o 'GPU [0-9].*$' /var/log/miner/teamredminer/teamredminer.log | sed '/Generating/d;/generation/d' | tail -{trmgpus} | sed -E 's/Mh\/s, avg.*$//g;s/^.*: ([0-9]*\.[0-9]*$)/\1/g' > /tmp/trm.log
gpu_count=$( wc -l /tmp/trm.log | sed -E 's/^([0-9]*) .*$/\1/' | bc )
if [[ "$gpu_count" -lt {trmgpus} ]] ; then
echo "script initiated due to a teamredminer gpu missing at `date '+%Y-%m-%d_%H:%M:%S'`" >> /home/user/worker_check.log
sleep 180
tail -100 /var/log/miner/teamredminer/teamredminer.log | grep -o 'GPU [0-9].*$' | sed '/Generating/d;/generation/d' | tail -{trmgpus} | sed -E 's/Mh\/s, avg.*$//g;s/^.*: ([0-9]*\.[0-9]*$)/\1/g;/^$/d' > /tmp/trm.log
if [[ "$gpu_count" -lt {trmgpus} ]] ; then
echo "script restarted worker due to a teamredminer gpu missing at `date '+%Y-%m-%d_%H:%M:%S'`" >> /home/user/worker_check.log
# curl -X POST -H "Content-Type: application/json" -d '{"value1":"{rigname} restarted due to a teamredminer gpu missing"}' https://maker.ifttt.com/trigger/notify/with/key/{iftttkey} ; wait
sreboot
fi
fi
while read line ; do
hash_rate=$( echo "$line" | sed -E 's/^([0-9]*)\..*$/\1/' | bc )
if [[ "$hash_rate" -eq 0 ]] ; then
echo "script initiated due to a teamredminer gpu having no hashrate at `date '+%Y-%m-%d_%H:%M:%S'`" >> /home/user/worker_check.log
sleep 180
tail -100 /var/log/miner/teamredminer/teamredminer.log | grep -o 'GPU [0-9].*$' | sed '/Generating/d;/generation/d' | tail -{trmgpus} | sed -E 's/Mh\/s, avg.*$//g;s/^.*: ([0-9]*\.[0-9]*$)/\1/g;/^$/d' > /tmp/trm.log
while read line ; do
hash_rate=$( echo "$line" | bc )
if [[ "$hash_rate" -eq 0 ]] ; then
echo "script restarted worker due to a teamredminer gpu having no hashrate at `date '+%Y-%m-%d_%H:%M:%S'`" >> /home/user/worker_check.log
# curl -X POST -H "Content-Type: application/json" -d '{"value1":"{rigname} restarted due to a teamredminer gpu having no hashrate"}' https://maker.ifttt.com/trigger/notify/with/key/{iftttkey} ; wait
sreboot
fi
done < /tmp/trm.log
fi
done < /tmp/trm.log