-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminer.sh
42 lines (36 loc) · 3.11 KB
/
miner.sh
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
32
33
34
35
36
37
38
39
40
41
42
HOSTPUBIP=`ec2metadata --public-hostname|awk '{print $2}'`
AWS_account_owner=` ec2metadata |awk '/public-keys:/{print $NF}'|sed 's/..$//'`
echo "" > /skminer/log/miner_log_bad.txt
echo "" > /skminer/log/miner_log_good.txt
echo "" > /skminer/log/miner_log_check.txt
while [ 1 -eq 1 ]
do
SKMIN=`ps -eaf | grep -i minergate-cli | grep -iv grep |wc -l`
if [ $SKMIN -lt 1 ]
then
echo "`date` ====== miner is not running so starting up " >> /skminer/log/miner_log_check.txt
minergate-cli -user [email protected] -xmr 8 2>> /skminer/log/miner_log_check.txt >> /skminer/log/miner_log_check.txt &
#minergate-cli -user [email protected] -dsh 8 2>> /skminer/log/miner_log_check.txt >> /skminer/log/miner_log_check.txt &
#minergate-cli -user [email protected] -bcn 8 2>> /skminer/log/miner_log_check.txt >> /skminer/log/miner_log_check.txt &
#minergate-cli -user [email protected] -dsh 8 &
sleep 90
HRATE=`tail /skminer/log/miner_log_check.txt | grep -i H/s | tail -1 | awk '{print int($(NF-1))}'`
(echo "SUBJECT:$HRATE SKMINER-SKRAJ $AWS_account_owner $HOSTPUBIP started at $HRATE /s ";uptime ; echo "====== " ; cat /skminer/log/miner_log_check.txt) |sendmail [email protected]
echo " mail sent for startup " >> /skminer/log/miner_log_check.txt
else
sleep 90
HRATE=`tail /skminer/log/miner_log_check.txt | grep -i H/s | tail -1 | awk '{print int($(NF-1))}'`
if [ $HRATE -gt 1 ]
then
echo " `date` ===== running good at rate of $HRATE " >> /skminer/log/miner_log_good.txt
else
echo " `date` ===== not good speed at rate of $HRATE ; so we will reboot `hostname` " >> /skminer/log/miner_log_bad.txt
#(echo "$HOSTPUBIP will be rebooted \n logs are below \n";uptime ; cat /skminer/log/miner_log_bad.txt /skminer/log/miner_log_good.txt /skminer/log/miner_log_check.txt ) |sendmail -v [email protected]
(echo "SUBJECT:$HRATE SKMINER-SKRAJ $AWS_account_owner stop $HOSTPUBIP due to $HRATE /s " ; echo "BODY:$HOSTPUBIP will be rebooted \n logs are below \n" ; echo " ======= ` uptime ` ======= Few last full logs =============== ";tail -5 /skminer/log/miner_log_check.txt ;echo "========= last 10 good logs ============== \n"; tail -10 /skminer/log/miner_log_good.txt;echo "======= last bad logs =========== \n" ; tail -10 /skminer/log/miner_log_bad.txt;echo "========= all logs good and full =========== \n\n" ; cat /skminer/log/miner_log_good.txt /skminer/log/miner_log_check.txt ) |sendmail -v [email protected]
#(echo "SUBJECT: mail2 Miner will be stopped in $HOSTPUBIP due to low speed = $HRATE" ; cat /skminer/log/miner_log_bad.txt /skminer/log/miner_log_good.txt /skminer/log/miner_log_check.txt ) |sendmail [email protected]
sleep 60
#init 0
exit
fi
fi
done