Closed djspacedevil closed 8 years ago
submit a PR :)
PR ??
i have the same errors on the profit.sh the "[: =: unary operator expected" errors i fixed manuell...
Shift: 2
Start time: 1462315081
(integer) 0
.025
(integer) 0
(integer) 0
(integer) 0
(integer) 1
(integer) 1
(integer) 0
(integer) 0
(integer) 1
(integer) 1
Start: 1462315081 End: 1462317281
(standard_in) 2: syntax error
(standard_in) 1: syntax error
(error) ERR wrong number of arguments for 'hset' command
thisalgoEarned: ERR wrong number of arguments for 'hget' command
dayslength: .025
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: R
(standard_in) 1: syntax error
(standard_in) 1: illegal character: '
(standard_in) 1: illegal character: '
(error) ERR wrong number of arguments for 'hset' command
(integer) 0
(integer) 0
For Current Shift Algo had an average of - profitability was 0
(integer) 0
(integer) 0
(error) ERR Background save already in progress
my neu_profit.sh
#!/bin/bash
# Search/replace NEU with ticker symbol of your desired payout coin. To
# enumerate for additional coins, add a line for EVERY place you see NEU. Leave things 'BTC' alone. :)
cp -rf /var/lib/redis/6379/dump.rdb /opt/unomp/multipool/backup/redis.dump4.rdb
AlgoCounter=0
now="$(date +"%s")"
ShiftNumber=$(/usr/local/bin/redis-cli hget Pool_Stats This_Shift)
echo "Shift: $ShiftNumber"
echo
#startstring="Pool_Stats:$ShiftNumber"
starttime=$(/usr/local/bin/redis-cli hget Pool_Stats:"$ShiftNumber" starttime)
echo "Start time: $starttime"
endtime="$now"
length=$(echo "$endtime - $starttime" | bc -l)
/usr/local/bin/redis-cli hset Pool_Stats CurLength $length
dayslength=$(echo "scale=3;$length / 86400" | bc -l)
echo $dayslength
NEUCoinPrice=$(/usr/local/bin/redis-cli hget Exchange_Rates neucoin)
TotalEarned=0
TotalEarnedNEUCoin=0
/usr/local/bin/redis-cli hset Pool_Stats CurDaysLength "$dayslength"
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:WorkerBtc
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:WorkerNEUCoin
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:Algos
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:AlgosNEUCoin
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:Coins
/usr/local/bin/redis-cli del Pool_Stats:CurrentShift:CoinsNEUCoin
# START CALCULATING COIN PROFIT FOR CURRENT ROUND - THIS ALSO CALCULATES WORKER EARNINGS MID SHIFT.
# PLEASE NOTE ALL COIN NAMES IN COIN_ALGO REDIS KEY MUST MATCH KEY NAMES IN EXCHANGE_RATES KEY CASE-WISE
while read line
do
AlgoTotal=0
AlgoTotalNEUCoin=0
logkey2="Pool_Stats:CurrentShift:Algos"
logkey2NEUCoin="Pool_Stats:CurrentShift:AlgosNEUCoin"
# loop through each coin for that algo
while read CoinName
do
coinTotal=0
coinTotalNEUCoin=0
thiskey=$CoinName":balances"
logkey="Pool_Stats:CurrentShift:Coins"
logkeyNEUCoin="Pool_Stats:CurrentShift:CoinsNEUCoin"
# Determine price for Coin
coin2btc=$(/usr/local/bin/redis-cli hget Exchange_Rates "$CoinName")
#echo "$CoinName - $coin2btc"
workersPerCoin=$(/usr/local/bin/redis-cli hlen "$thiskey")
if [[ "$workersPerCoin" = 0 ]]
then
echo "do nothing" > /dev/null
else
while read WorkerName
do
thisBalance=$(/usr/local/bin/redis-cli hget "$thiskey" "$WorkerName")
thisEarned=$(echo "scale=8;$thisBalance * $coin2btc" | bc -l)
coinTotal=$(echo "scale=8;$coinTotal + $thisEarned" | bc -l)
AlgoTotal=$(echo "scale=8;$AlgoTotal + $thisEarned" | bc -l)
NEUCoinEarned=$(echo "scale=8;$thisEarned / $NEUCoinPrice" | bc -l)
coinTotalNEUCoin=$(echo "scale=8;$coinTotalNEUCoin + $NEUCoinEarned" | bc -l)
AlgoTotalNEUCoin=$(echo "scale=8;$AlgoTotalNEUCoin + $NEUCoinEarned" | bc -l)
echo "$WorkerName earned $NEUCoinEarned from $CoinName"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:WorkerNEUCoin "Total" "$NEUCoinEarned"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:AlgosNEUCoin "Total" "$NEUCoinEarned"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:Algos "Total" "$thisEarned"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:WorkerNEUCoin "$WorkerName" "$NEUCoinEarned"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:WorkerBtc "Total" "$thisEarned"
/usr/local/bin/redis-cli hincrbyfloat Pool_Stats:CurrentShift:WorkerBtc "$WorkerName" "$thisEarned"
done< <(/usr/local/bin/redis-cli hkeys "$CoinName":balances)
/usr/local/bin/redis-cli hset "$logkey" "$CoinName" "$coinTotal"
/usr/local/bin/redis-cli hset "$logkeyNEUCoin" "$CoinName" "$coinTotalNEUCoin"
#echo "$CoinName: $coinTotal"
fi
done< <(/usr/local/bin/redis-cli hkeys Coin_Names_"$line")
/usr/local/bin/redis-cli hset "$logkey2" "$line" "$AlgoTotal"
/usr/local/bin/redis-cli hset "$logkey2NEUCoin" "$line" "$AlgoTotalNEUCoin"
TotalEarned=$(echo "scale=8;$TotalEarned + $AlgoTotal" | bc -l)
TotalEarnedNEUCoin=$(echo "scale=8;$TotalEarnedNEUCoin + $AlgoTotalNEUCoin" | bc -l)
done< <(/usr/local/bin/redis-cli hkeys Coin_Algos)
# END CALCULATING COIN PROFITS FOR CURRENT SHIFT
# START CALCULATIN AVERAGE HASHRATES SO FAR THIS SHIFT
echo "Start: $starttime End: $endtime"
AlgoCounter=0
while read Algo
do
AlgoCounter=$(($AlgoCounter + 1))
if [[ $Algo = "sha256" ]]
then
Algo="sha"
fi
AlgoHRTotal=0
counter=0
loopstring="Pool_Stats:AvgHRs:"$Algo
while read HR
do
IN=$HR
arrIN=(${IN//:/ })
amt=${arrIN[0]}
counter=`echo "$counter + 1" | bc`
AlgoHRTotal=`echo "$AlgoHRTotal + $amt" | bc -l`
done< <(/usr/local/bin/redis-cli zrangebyscore $loopstring $starttime $endtime)
if [[ $Algo = "sha" ]]
then
Algo="sha256"
fi
thisalgoAVG=`echo "scale=8;$AlgoHRTotal / $counter" | bc -l`
string="average_"$Algo
/usr/local/bin/redis-cli hset Pool_Stats:CurrentShift $string $thisalgoAVG
string3="Pool_Stats:CurrentShift:Algos"
thisalgoEarned=`/usr/local/bin/redis-cli hget $string3 $Algo`
echo "thisalgoEarned: $thisalgoEarned"
echo "dayslength: $dayslength"
thisalgoP=`echo "scale=8;$thisalgoEarned / $thisalgoAVG / $dayslength" | bc -l`
string2="Profitability_$Algo"
/usr/local/bin/redis-cli hset Pool_Stats:CurrentShift $string2 $thisalgoP
if [[ $Algo = "keccak" ]]
then
thisalgoP=`echo "scale=8;$thisalgoP * 500" | bc -l`
elif [[ $Algo = "sha256" ]]
then
thisalgoP=`echo "scale=8;$thisalgoP * 1000" | bc -l`
elif [[ $Algo = "x11" ]]
then
thisalgoP=`echo "scale=8;$thisalgoP * 1" | bc -l`
else
echo "done" >/dev/null
fi
if [[ -z "$thisalgoP" ]]
then
thisalgoP=0
fi
ProArr[$AlgoCounter]=$thisalgoP
NameArr[$AlgoCounter]=$Algo
thisShift=$(/usr/local/bin/redis-cli hget Pool_Stats This_Shift)
/usr/local/bin/redis-cli hset Pool_Stats:CurrentShift $string2 $thisalgoP
/usr/local/bin/redis-cli hset Pool_Stats:$thisShift $string2 $thisalgoP
echo "For Current Shift Algo $Algo had an average of $thisalgoAVG - profitability was $thisalgoP"
done< <(/usr/local/bin/redis-cli hkeys Coin_Algos)
profitstring=${ProArr[1]}":"${ProArr[2]}":"${ProArr[3]}":"${ProArr[4]}":"${ProArr[5]}
stringnames=${NameArr[1]}":"${NameArr[2]}":"${NameArr[3]}":"${NameArr[4]}":"${NameArr[5]}
/usr/local/bin/redis-cli hset Pool_Stats:CurrentShift:Profitability $now $profitstring
/usr/local/bin/redis-cli hset Pool_Stats:CurrentShift NameString $stringnames
/usr/local/bin/redis-cli bgsave
PR == Pull Request
What version Linux are you running?
Ah ok, when the scripts running, i made a pull. i run this in a docker container with ubuntu 14 .
After install "BC" (this is not documented) i get errors:
In Line 89, 93 and 97 a simple replace "[" to "[[" and "]" to "]]" helps,
But i dont find the another ones...
Why is this so long unpatched?