#!/bin/bash
MinerIP=192.168.1.126
RetryCount=15
RetrySleep=20
loopcount=1
Shutdown=40
while [ $loopcount -le $RetryCount ]
do
echo ""
echo "Attempt #$loopcount: cgminer API connection."
echo ""
cgminer-api version $MinerIP
res=$?
if test "$res" = 0; then
echo ""
echo "Success! cgminer-api @ $MinerIP has returned a valid connection signal"
break
else
echo "cgminer-api @ $MinerIP connection Failed"
if test "$loopcount" = "$RetryCount"; then
echo ""
echo "Reached Retry Count. Shutting Down Miner"
echo ""
curl --request POST "https://use1-wap.tplinkcloud.com/?token=YOUR_TPLINK_KASSA_TOKEN HTTP/1.1" --data '{"method":"passthrough", "params": {"deviceId": YOUR_DEVICE_ID, "requestData": "{\"system\":{\"set_relay_state\":{\"state\":0}}}" }}' --header "Content-Type: application/json"
echo ""
echo ""
echo "Inno $MinerIP ShutDown Signal Sent"
echo "Discharging for $Shutdown Seconds"
sleep $Shutdown
echo ""
curl --request POST "https://use1-wap.tplinkcloud.com/?token=YOUR_TPLINK_KASSA_TOKEN HTTP/1.1" --data '{"method":"passthrough", "params": {"deviceId": YOUR_DEVICE_ID, "requestData": "{\"system\":{\"set_relay_state\":{\"state\":1}}}" }}' --header "Content-Type: application/json"
echo ""
echo ""
echo "Inno $MinerIP Startup Signal Sent"
echo ""
fi
fi
sleep $RetrySleep
let "loopcount++"
done
I got sick of the Miner crashing so I hodge-podged together a solution. Its a script that calls cgminer-api from one miner to the other, checking each other if they can receive data from cgminer and call a shutdown, pause and powerup to the TP-Link smart plugs (Pretty cheap!
https://www.amazon.com/Kasa-Smart-Wi-Fi-TP-Link-2-Pack/dp/B01KBFWW0O) if no signal is received after multiple attempts.
I noticed when my A9's crash I loose the web interface. Still shows the pages but no data. I think my browser was just caching but I forget to verify that. I tried to view the log and login to SSH. Both didnt work. So in the off chance this call cgminer-api check method doesnt pan out, I'll just do something with SSH failing as a test point, or get actually hashrate from the API.
I could use some help if there are any linux pros here. Anyone know how to schedule a script to periodically run? There is no cron. Maybe i could install it? The A9 Linux seems to be setup to use Systemctl and Systemd as taskmanager/process controller. I tried to create a File.timer file but it wouldnt let me write the file to /etc/systemd/system/and Its too late to be wrapping my head around linux permission issues. I think it would be cool to have these checking up on each other and reasonable immediately power cycling. I could also rust run a script from windows if I could get Curl to take the syntax like the linux version does. Right now Im calling the scripts from Putty plink with a Windows Task scheduled every 10min. Ugly but it works.
On a related note, does anyone know how to set vm.min_free_kbytes permanently? I can just set it with my script but I am interested to know how to properly tweak it to survive a reboot. Its just a guess on what may help these A9's from crashing. I also put back -lowmem in cgminer.conf to see if that helps.