16
16
# ## BTC 31qHHFPtR6mqgyhJ1EgMVdZ2WAr7izQQyB
17
17
# ## PAYPAL https://paypal.me/ajki
18
18
19
+ RedEcho (){ echo -e " $( tput setaf 1) $1 $( tput sgr0) " ; }
20
+ GreenEcho (){ echo -e " $( tput setaf 2) $1 $( tput sgr0) " ; }
21
+ YellowEcho (){ echo -e " $( tput setaf 3) $1 $( tput sgr0) " ; }
19
22
20
23
LogFile=" /home/ethos/watchdog.log"
21
24
# ## EXIT IF WATCHDOG ALREADY RUNNING
27
30
StatsJson=" /var/run/ethos/stats.json"
28
31
# ## EXIT IF STATS.JSON IS MISSING
29
32
if [[ ! -f " $StatsJson " ]]; then
30
- echo " $( date " +%d.%m.%Y %T" ) EXIT: stats.json not available yet." | tee -a " $LogFile "
33
+ echo " $( date " +%d.%m.%Y %T" ) EXIT: stats.json not available yet.(make sure ethosdistro is ver: 1.3.0+)" | tee -a " $LogFile "
34
+ exit 1
35
+ fi
36
+ UpTimeSeconds=$( cat /proc/uptime | xargs | cut -d " " -f 1)
37
+ UpTime=$( printf ' %dh:%dm:%ds' $(( ${UpTimeSeconds/ .* } / 3600 )) $(( ${UpTimeSeconds/ .* } % 3600 / 60 )) $(( ${UpTimeSeconds/ .* } % 60 )) )
38
+ if [ ${UpTimeSeconds/ .* } -lt 300 ]; then
39
+ echo " EXIT: System booted less then 5 minutes ago.Current running time: $UpTime "
31
40
exit 1
32
41
fi
33
42
@@ -42,7 +51,12 @@ if [[ ! -f /dev/shm/restartminercount ]]; then
42
51
echo " 0" > /dev/shm/restartminercount
43
52
fi
44
53
RestartMinerCount=$( cat /dev/shm/restartminercount)
45
-
54
+ YellowEcho " WATCHDOG.SH STARTED WITH FOLLOWING VALUES:"
55
+ YellowEcho " Minimum Hash Rate: $MinHashRate "
56
+ YellowEcho " Minimum Watts: $MinWatts "
57
+ YellowEcho " Reboot on to many restarts: ${RebootMaxRestarts} /${RestartMinerCount} "
58
+ YellowEcho " OS running for: $UpTime "
59
+ YellowEcho " Miner $Miner running for $MinerTime "
46
60
function RestartMiner() {
47
61
# # COUNT RESTARTS IF MINNER IS RUNNING FOR LESS THEN 1H
48
62
if [[ $MinerSeconds -lt 3600 ]]; then
@@ -76,22 +90,21 @@ function Json2Array() {
76
90
}
77
91
78
92
### SKIP CHECKS IF MINER IS RUNNING LESS THEN 5 MINUTES
79
- if [[ $MinerSeconds -lt " 300" ]]; then
80
-
93
+ if [[ $MinerSeconds -gt 300 ]]; then
81
94
Json2Array miner_hashes
82
95
Json2Array watts
83
96
84
97
Index=0
85
98
for Value in " ${miner_hashes[@]} "
86
99
do
87
100
if [[ " ${miner_hashes[$Index]/ .* } " -lt $MinHashRate ]]; then
88
- echo " $( date " +%d.%m.%Y %T" ) RESTART: GPU[$Index ] HASH:${miner_hashes[$Index]} .[Miner was running for: $MinerTime ]" | tee -a " $LogFile "
101
+ RedEcho " $( date " +%d.%m.%Y %T" ) RESTART: GPU[$Index ] HASH:${miner_hashes[$Index]} .[Miner was running for: $MinerTime ]" | tee -a " $LogFile "
89
102
RestartMiner
90
103
elif [[ " ${watts[$Index]/ .* } " -lt $MinWatts ]]; then
91
- echo " $( date " +%d.%m.%Y %T" ) RESTART: GPU[$Index ] WATTS:${watts[$Index]} .[Miner was running for: $MinerTime ]" | tee -a " $LogFile "
104
+ RedEcho " $( date " +%d.%m.%Y %T" ) RESTART: GPU[$Index ] WATTS:${watts[$Index]} .[Miner was running for: $MinerTime ]" | tee -a " $LogFile "
92
105
RestartMiner
93
106
else
94
- echo " STATUS OK: GPU[$Index ] HASH:${miner_hashes[$Index]} WATTS:${watts[$Index]} "
107
+ GreenEcho " STATUS OK: GPU[$Index ] HASH:${miner_hashes[$Index]} WATTS:${watts[$Index]} "
95
108
fi
96
109
let Index++
97
110
done
0 commit comments