I wonder if there is a script that if the rig cannot communicate through API (or is just offline) it initiates reboot or shutdown & boot in 30s. Sometimes it gets kinda stuck, the rig is working but not mining and looks offline and not all rigs are always physically accessible.
Temporary solution: I decided to buy smart plugs (15 usd here), so when it goes offline, I will shut down from android app. Mobo has a feature for power cuts to reboot automatically when power is back.
I have very similar approach with Woox smart plugs and IFTTT. So I ping the HiveOS API every 2 minutes, if the rig is offline for 4 or more minutes I send command automatically to IFTTT and that resets the plug which resets the server⦠not the best solution, but at least something.
I tried to set up the watchdog, got 2 USB watchdogs but was not able to make them work fully reliably.
Hello my friend, could you explain how configure the IFTTT for ping and restart rig?
Or does anyone have any other solution? I also have a smart plug and I reset the rig remotely, but for that I need to know itās locked, so I lose hours of mining.
@dncz explains his setup here: Rig total freeze, requires power reset - #9 by dncz
I started to replicate his setup, but realized my smart plugs do not work with IFFFT. One of my rigs has been crashing in the middle of the night and not restarting, so I wrote a simple cron script. Iām not entirely sure what happens to the system when it freezes up, so I donāt know whether the cron script will successfully run, but I guess Iāll find out. Here are the steps:
Login to hiveos.farm (on a browser), click on your username in the top right corner, scroll down, and click on āGenerate new Personal API-token.ā Once itās generated, click on āShowā and copy the 220 character API key and save it somewhere.
Go to hiveos.farm and click on your farm, then copy and save your farm id from the url. Select each worker from the drop down list, then copy and save your worker id from the url. The format is: https://the.hiveos.farm/farms/{$farmid}/workers/{$workerid}/
You can test whether the api is working with the following command in Terminal (replace {$apikey} and {$farmid} with that of your own api key and farm id): curl -s -w '\n%{http_code}' -H 'Content-Type: application/json' -H 'Authorization: Bearer {$apikey}' https://api2.hiveos.farm/api/v2/farms/{$farmid}
SSH into your rig and create a reboot script. For instance: mkdir -p /home/user/scripts ; nano /home/user/scripts/worker1reboot.sh
Paste the following code into your script, replacing {$API-Key}, {$farmid}, and {$workerid} with that of your own api key, farm id, and worker id:
#!/bin/bash worker_status=$( curl -s -w '\n%{http_code}' -H 'Content-Type: application/json' -H 'Authorization: Bearer {$apikey}' https://api2.hiveos.farm/api/v2/farms/{$farmid}/workers/{$workerid} | grep -o '"stats":{"online":[a-z]*' | sed 's/[ ":,{]//g;s/stats//;s/online//' ) datetime=$(date '+%Y-%m-%d_%H:%M:%S') if [[ "$worker_status" = 'false' ]] ; then echo "cron script initiated at $datetime" >> /home/user/worker1reboot.log sleep 300 if [[ "$worker_status" = 'false' ]] ; then echo "cron script restarted worker1 at $datetime" >> /home/user/worker1reboot.log sudo reboot fi elif [[ "$worker_status" != 'true' ]] && [[ "$worker_status" != 'false' ]] ; then echo "cron script initiated at $datetime, but was unable to check the online status of worker1" >> /home/user/worker1reboot.log fi
Save the script by pressing ctrl+x, then y, then enter. Then make the script executable: chmod +x /home/user/scripts/worker1reboot.sh
Create a new crontab with crontab -e. Scroll to the bottom of the window and press enter. Paste this on the last line: */5 * * * * /home/user/scripts/worker1reboot.sh
Assuming youāre editing the crontab with Internal File Editor, which is the default editor for hiveos, press enter again so thereās another blank line on the bottom, otherwise the editor will complain about it. Then press FN+F10 and then y to save your changes. The cron script will run every five minutes and check the online status of your worker. If the status shows offline, it will wait for five minutes and check the status again. If itās still offline, it will reboot the rig.
Iām hoping this resolves the offline issue Iāve been having, thank you. I have one slight modification. when I use crontab -e, the changes disappear after I exit crontab. I found a solution, and that is to use the following command: sudo nano /hive/etc/crontab.root
then I add */5 * * * * /home/user/scripts/worker1reboot.sh
to the file, press control +x to exit, yes to save the changes, and from there, the script will be included in crontab.
Iām waiting to confirm this resolves the offline issue, but Iām hopeful. Thanks for your help!
I wrote a script that will set everything up for you, as long as youāre using Teamredminer or lolminer (or both in a dual mining setup). I canāt confirm that all of the checks work, but in theory they should. I also set it up as a timer/service instead of a cron job, so I could have it wait until the rig has been booted for 5 minutes to start running checks. Any feedback would be appreciated. These random freezes are really annoying⦠canāt believe hiveos hasnāt fixed it yet.
Follow the instructions here: Bash script to reboot rig that is offline or has a dead gpu