Skip to content

Commit f100a23

Browse files
authored
Critical fix due stupid mistake during testing.
1 parent 39e4d8a commit f100a23

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

ethosdistro/watchdog.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
### BTC 31qHHFPtR6mqgyhJ1EgMVdZ2WAr7izQQyB
1717
### PAYPAL https://paypal.me/ajki
1818

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)"; }
1922

2023
LogFile="/home/ethos/watchdog.log"
2124
### EXIT IF WATCHDOG ALREADY RUNNING
@@ -27,7 +30,13 @@ fi
2730
StatsJson="/var/run/ethos/stats.json"
2831
### EXIT IF STATS.JSON IS MISSING
2932
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"
3140
exit 1
3241
fi
3342

@@ -42,7 +51,12 @@ if [[ ! -f /dev/shm/restartminercount ]]; then
4251
echo "0" > /dev/shm/restartminercount
4352
fi
4453
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"
4660
function RestartMiner() {
4761
## COUNT RESTARTS IF MINNER IS RUNNING FOR LESS THEN 1H
4862
if [[ $MinerSeconds -lt 3600 ]]; then
@@ -76,22 +90,21 @@ function Json2Array() {
7690
}
7791
7892
### SKIP CHECKS IF MINER IS RUNNING LESS THEN 5 MINUTES
79-
if [[ $MinerSeconds -lt "300" ]]; then
80-
93+
if [[ $MinerSeconds -gt 300 ]]; then
8194
Json2Array miner_hashes
8295
Json2Array watts
8396
8497
Index=0
8598
for Value in "${miner_hashes[@]}"
8699
do
87100
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"
89102
RestartMiner
90103
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"
92105
RestartMiner
93106
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]}"
95108
fi
96109
let Index++
97110
done

0 commit comments

Comments
 (0)