This is my latest approach to get server and port from 1bash for wdog check
Please check, test and let me know if there is any codes that can be simplified or corrected.
Tested many coins but not all,
Claymore dual Mining included to check main server
ZM dual server check not included but can be done easily if not fixed from dstm.
So many echo included for testing, will be removed later
#!/bin/bash
source /home/m1/1bash
CURRENT_COIN=$(head -n 200 /home/m1/1bash | grep COIN= | sed 's/COIN=//' | sed 's/\"//' | sed 's/\"//')
#echo "$CURRENT_COIN"
CURRENT_COIN_POOL=$(echo {$CURRENT_COIN}_POOL |sed 's/{//' | sed 's/}//' )
#echo $CURRENT_COIN_POOL
POOL_SERVER=$(cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//')
#echo "$POOL_SERVER"
CURRENT_COIN_PORT=$(echo {$CURRENT_COIN}_PORT | sed 's/{//' | sed 's/}//')
#echo "$CURRENT_COIN_PORT"
if [[ $POOL_SERVER == *stratum* || $COIN == "ETH" || $COIN == "ETC" || $COIN == "EXP" || $COIN == "UBQ" || $COIN == "MUSIC" || $COIN == "SOIL" ]]
then
#echo "stratum/ethash"
PING_SERVER=$( cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//' | sed 's/stratum+tcp\?:\/\///' | cut -d':' -f1 )
#echo "Server: $PING_SERVER"
PING_PORT=$(cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//' | sed 's/stratum+tcp\?:\/\///' | grep -Eo '[0-9]+$' )
#echo "Port: $PING_PORT"
if nc -vzw2 $PING_SERVER $PING_PORT;
then
#echo "Strartum Server, INTERNET_IS_GO=1"
INTERNET_IS_GO=1
else
echo "WARNING: $(date) - Mining Pool Stratum Server is DOWN" | tee -a ${LOG_FILE} ${ALERT_LOG_FILE}
INTERNET_IS_GO=0
fi
elif [[ $CURRENT_COIN == *ZPOOL_SKUNK* || $CURRENT_COIN == *SALFTER* ]]
then
#echo "Cant get pool, check google"
if nc -vzw2 google.com 443
then
#echo "Cant get pool, google is up"
INTERNET_IS_GO=1
else
echo "WARNING: $(date) - Cant reach google" | tee -a ${LOG_FILE} ${ALERT_LOG_FILE}
INTERNET_IS_GO=0
fi
elif [[ $CURRENT_COIN == *DUAL* ]]
then
CURRENT_COIN=$( head -n 200 /home/m1/1bash | grep COIN= | sed 's/COIN=//' | sed 's/\"//' | sed 's/\"//' | sed 's/DUAL_//' | cut -d _ -f 1)
#echo "$CURRENT_COIN"
CURRENT_COIN_POOL=$(echo {$CURRENT_COIN}_POOL |sed 's/{//' | sed 's/}//' )
#echo $CURRENT_COIN_POOL
POOL_SERVER=$(cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//')
#echo "$POOL_SERVER"
CURRENT_COIN_PORT=$(echo {$CURRENT_COIN}_PORT | sed 's/{//' | sed 's/}//')
#echo "$CURRENT_COIN_PORT"
PING_SERVER=$( cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//' | sed 's/stratum+tcp\?:\/\///' | cut -d':' -f1 )
#echo "Server: $PING_SERVER"
PING_PORT=$(cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//' | sed 's/stratum+tcp\?:\/\///' | grep -Eo '[0-9]+$' )
#echo "Port: $PING_PORT"
#echo "Dual mining, check main server $PING_SERVER "
if nc -vzw2 $PING_SERVER $PING_PORT;
then
#echo "Dual mining, main server $PING_SERVER is up"
INTERNET_IS_GO=1
else
echo "WARNING: $(date) - Cant reach main server $PING_SERVER " | tee -a ${LOG_FILE} ${ALERT_LOG_FILE}
INTERNET_IS_GO=0
fi
else
PING_SERVER=$( cat /home/m1/1bash | grep $CURRENT_COIN_POOL | grep -o '".*"' | sed 's/"//'| sed 's/"//')
#echo "Server: $PING_SERVER"
PING_PORT=$(cat /home/m1/1bash | grep $CURRENT_COIN_PORT | grep -o '".*"' | sed 's/"//' |sed 's/"//')
#echo "Port: $PING_PORT"
if nc -vzw1 $PING_SERVER $PING_PORT
then
#echo "Not a stratum server,INTERNET_IS_GO=1" # | tee -a ${LOG_FILE}
INTERNET_IS_GO=1
else
echo "WARNING: $(date) - Mining Pool Server $PING_SERVER is DOWN" | tee -a ${LOG_FILE} ${ALERT_LOG_FILE}
INTERNET_IS_GO=0
fi
fi
Edit:
All this can be much simpler if all coin addresses become same in 1bash
Example:
new 1bash
ZCOIN_WORKER="$WORKERNAME"
ZCOIN_ADDRESS="papampi"
ZCOIN_POOL="xzc.suprnova.cc"
ZCOIN_PORT=1569
current 1bash:
ZCOIN_WORKER="$WORKERNAME"
ZCOIN_ADDRESS="papampi"
ZCOIN_POOL="stratum+tcp://xzc.suprnova.cc:1569"
new 3main:
if [ $COIN == "ZCOIN" ]
then
HCD='/home/m1/TPccminer/ccminer'
ADDR="$ZCOIN_ADDRESS.$ZCOIN_WORKER"
screen -dmSL miner $HCD -a lyra2z -o stratum+tcp://$ZCOIN_POOL:ZCOIN_PORT -u $ADDR -p x
current 3main:
screen -dmSL miner $HCD -a lyra2z -o $ZCOIN_POOL -u $ADDR -p x
Everything looks fine mate, I would like to add a case where zm/ewbf/ethminer doesn't like stratum addresses, it complicate if people want to change pool address (not all users, only new/some users!!)
But, would like to see/work towards everything get revamped and make it more efficient. We should try to make it more dynamic, so that we don't get swamped up with users facing issues.
Really appreciate the work by our mighty @fullzero, @papampi, @kkoo3, @Stubo & @leenoox valuable out of box guidance, kudos