To get around not being able to write a file, you have to remount the filesystem as read/write: "mount / -o rw,remount"
Thanks!, I did need "mount / -o rw,remount"
I thought I would never have to do this again but I did. Worked like a charm. And besides some annoying syntax issues, so did everything else. So here it is.
More polished solution for Miners checking up on each other and automatically power-cycling TP-Link Smart/Wifi Plugs, if one finds the other not hashing.New Things:Fully Miner Managed Service on a 10min Timer to execute
Outputs all steps Directly To miner GUI Log (Main System Log)
*Edited post with Logging to TeamCheck.logInstructions - Quick and dry instructions. Hope I didn't miss anything.
Get Putty>Enter IP address of Miner
Left Window>SSH>X11>Check Enable X11 Forwarding
Name "Saved Sessions" and Click Save
Click Open, type login:admin, type password:blacksheepwall
cd /etc/systemd/system/ #standard place for timer/service files
mount / -o rw,remount #Thanks Sweeper!!
Create the 3 files:
vi TeamCheck.service
i for insert mode
Shift-Insert to paste code from below
:wq to save (q! is quit without save)
vi TeamCheck.timer
" same
vi TeamCheck.sh
" same
chmod -x TeamCheck.sh #This may not be necessary
systemctl enable TeamCheck.timer #Enables/Recognizes the timer
systemctl start TeamCheck.timer #Starts the timer
Setup elements:TeamCheck.timer: OnCalendar=*:0/10 #is how oftern the script runs and target miner is contacted. This is 10min. *:0/5 would be 5min
TeamCheck.sh:
MinerIP=192.168.1.126 #Target Miner to Check onRetryCount=8 #How many times to Retry contacting target miner. RetryCount*RetrySleep=time before ac plug powercycle
RetrySleep=30 #how many seconds to wait between attempts to contact miner.
loopcount=1 #static variable for loop. Leave as 1
Shutdown=40 #Time to wait in seconds after target Miner Power Down is sent before sending Power Up signal
My On Off Signals are in TeamCheck.shThese are for TP Link Plugs. A Solution to send a reboot command to your Plugs WILL NEED TO NEED to be figured out.TP-Link Plugs are about 15-$20 each. So not a bad investment to eliminate almost any issue that a power cycle will resolve.
That being said. If someone has an issue where their non hashing miner will take an SSH command. Than a reboot/service restart would be easy todo.
On: curl --request POST "
https://use1-wap.tplinkcloud.com/?token=YOUR_TOKEN HTTP/1.1" --data '{"method":"passthrough", "params": {"deviceId": YOUR_DEVICE_ID, "requestData": "{\"system\":{\"set_relay_state\":{\"state\":0}}}" }}' --header "Content-Type: application/json"
Off: curl --request POST "
https://use1-wap.tplinkcloud.com/?token=YOUR_TOKEN HTTP/1.1" --data '{"method":"passthrough", "params": {"deviceId": YOUR_DEVICE_ID, "requestData": "{\"system\":{\"set_relay_state\":{\"state\":0}}}" }}' --header "Content-Type: application/json"
FOR TP-LINK WIFI/SMART Plugs setup with the Kasa App
You need you Device id for YOUR_DEVICE_ID and Security Token for YOUR_TOKEN. They were pretty easy to get with online guides.
http://itnerd.space/2017/01/22/how-to-control-your-tp-link-hs100-smartplug-from-internet/Some other NOT IMPORTANT but interesting things I learned making this.echo "Hello" | systemd-cat #Adding this at the end of an echo line will print to the Web GUI Log
systemctl list-timers -all #Shows all timers. When they will execute again.
systemctl start/stop/restart cgminer #For those that dont know
May have been able todo without the TeamCheck.timer file by using a service restart command in the service file but it was poorly documented and I went with textbook.
Still todo is add a Log of AC Powercycles that wont disappear. Got to look up how to log with chance of file overgrowth. Should never happen in this scenario but im being particular and trying to force better habits to learnChecking on a second Miner would be most easily accomplished at this point by copying TeamCheck.sh to ex TeamCheck2.sh. Changing IP and adding to TeamCheck.service ExecStart line
Last, If anyone finds this concept/code more than interesting and actually uses it at any kind of scale. Feel Free to Donate. Feel Free not to tho
BTC - 3MDjV9Hk2qQUyoYAEx9jP594iBo8uJtVmm
TeamCheck.service
[Unit]
Description=Scheduled Remote Miner Checker/PowerCycler
After=network.target
[Service]
ExecStart=/bin/sh /etc/systemd/system/TeamCheck.sh
Type=oneshot
[Install]
WantedBy=multi-user.target
TeamCheck.timer
[Unit]
Description=Scheduled Remote Miner Checker/PowerCycler
[Timer]
OnCalendar=*:0/10
[Install]
WantedBy=timers.target
TeamCheck.sh
#!/bin/bash
MinerIP=192.168.1.126
RetryCount=8
RetrySleep=30
loopcount=1
Shutdown=40
while [ $loopcount -le $RetryCount ]
do
echo ""
echo "Checkup Attempt #$loopcount: Contacting Miner $MinerIP cgminer-API." | systemd-cat
echo ""
cgminer-api version $MinerIP
res=$?
if test "$res" = 0; then
echo ""
echo "Checkup Attempt #$loopcount: SUCCESS! cgminer-API @ $MinerIP has returned a valid connection signal" | systemd-cat
break
else
echo "!!!!!FAILED!!!!! cgminer-API @ $MinerIP connection Failed" | systemd-cat
if test "$loopcount" = "$RetryCount"; then
echo ""
echo "!!Shutting Down Miner $MinerIP!! Connection Retry Count Reached" | systemd-cat
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 "Miner $MinerIP" >> /etc/systemd/system/TeamCheck.log
date +'Power Cycled on Date : %d/%m/%Y Time : %H.%M.%S' >> /etc/systemd/system/TeamCheck.log
echo "$(tail -n 50 /etc/systemd/system/TeamCheck.log)" > /etc/systemd/system/TeamCheck.log
echo ""
echo ""
echo "Miner $MinerIP ShutDown Signal Sent" | systemd-cat
echo "Discharging for $Shutdown Seconds" | systemd-cat
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 "Miner $MinerIP Startup Signal Sent" | systemd-cat
echo ""
fi
fi
sleep $RetrySleep
let "loopcount++"
done
Hi. Is this a solution for miners going offline?
As I mentioned, it happens to me at least a few times per week. At most, once per day.