From 0c8251c01ef11039fc7d67a0ae38334cb5cd2ea2 Mon Sep 17 00:00:00 2001 From: Fern Date: Fri, 22 Jun 2018 23:43:08 +0200 Subject: [PATCH] 0.5-60 ewbf 0.2, autofans --- hive/bin/agent.miner_stats.sh | 53 ++++++++++++++++++----------------- hive/bin/ewbf | 18 ++++-------- hive/bin/hello | 2 +- hive/sbin/autofan | 8 +++--- 4 files changed, 37 insertions(+), 44 deletions(-) mode change 100644 => 100755 hive/sbin/autofan diff --git a/hive/bin/agent.miner_stats.sh b/hive/bin/agent.miner_stats.sh index 94d2befa2..624984639 100644 --- a/hive/bin/agent.miner_stats.sh +++ b/hive/bin/agent.miner_stats.sh @@ -46,6 +46,7 @@ function miner_stats { khs=`echo $stats_raw | jq -r '.result[].speed_sps' | awk '{s+=$1} END {print s/1000}'` #sum up and convert to khs local ac=$(jq '[.result[].accepted_shares] | add' <<< "$stats_raw") local rj=$(jq '[.result[].rejected_shares] | add' <<< "$stats_raw") + #All fans speed array local fan=$(jq -r ".fan | .[]" <<< $gpu_stats) #EWBF's busid array @@ -57,20 +58,24 @@ function miner_stats { fan=`sed 's/\n/ /' <<< $fan` IFS=' ' read -r -a bus_id_array <<< "$bus_id_array" IFS=' ' read -r -a fan <<< "$fan" - #busid's equality + #busid equality local fans_array= - for ((i = 0; i < ${#all_bus_ids_array[@]}; i++)) - do - for ((j = 0; j < ${#bus_id_array[@]}; j++)) - do - if [ "${all_bus_ids_array[$i]}" == "${bus_id_array[$j]}" ]; then - fans_array+=("${fan[$i]}") - fi - done + for ((i = 0; i < ${#all_bus_ids_array[@]}; i++)); do + for ((j = 0; j < ${#bus_id_array[@]}; j++)); do + if [ "${all_bus_ids_array[$i]}" == "${bus_id_array[$j]}" ]; then + fans_array+=("${fan[$i]}") + fi done - stats=$(jq -c --arg ac "$ac" --arg rj "$rj" --argjson fan "`echo "${fans_array[@]}" | jq -s . | jq -c .`"\ - '{speed_sps: [.result[].speed_sps], temp: [.result[].temperature], $fan, busid: [.result[].busid[5:]|ascii_downcase], start_time: - .result[0].start_time, ar: [$ac, $rj]}' <<< "$stats_raw") + done + + local uptime=$(( `date +%s` - $(jq '.result[0].start_time' <<< "$stats_raw") )) + [[ -z $EWBF_ALGO ]] && EWBF_ALGO="equihash" + + stats=$(jq -c --arg uptime "$uptime" --arg ac "$ac" --arg rj "$rj" --arg algo "$EWBF_ALGO" \ + --argjson fan "`echo "${fans_array[@]}" | jq -s . | jq -c .`" \ + '{hs: [.result[].speed_sps], temp: [.result[].temperature], $fan, + $uptime, ar: [$ac, $rj]}' <<< "$stats_raw") + #busid: [.result[].busid[5:]|ascii_downcase] fi ;; ccminer) @@ -179,15 +184,11 @@ function miner_stats { else khs=`echo $stats_raw | jq '.result[].sol_ps' | awk '{s+=$1} END {print s/1000}'` local uptime=$(( `date +%s` - $(stat -c%X /proc/`pidof zm`) )) #dont think zm will die so soon after getting stats - #todo: use gpu_stats if busid is known - #local nvidiastats=`gpu-stats nvidia` #a bit overhead in calling nvidia-smi again, shame on dstm, he gives no temps - #stats=`echo $stats_raw | jq '{ hs: [.result[].sol_ps], temp: [.result[].temperature], uptime: "'$uptime'"}'` - #stats=$(jq '{ hs: [.result[].sol_ps], uptime: "'$uptime'"}' <<< $stats_raw) - #stats=$(jq -s '.[0] * .[1]' <<< "$stats $nvidiastats") #local fan=$(jq -c "[.fan$nvidia_indexes_array]" <<< $gpu_stats) #local temp=$(jq -c "[.temp$nvidia_indexes_array]" <<< $gpu_stats) local ac=`echo $stats_raw | jq '[.result[].accepted_shares] | add'` local rj=`echo $stats_raw | jq '[.result[].rejected_shares] | add'` + #All fans speed array local fan=$(jq -r ".fan | .[]" <<< $gpu_stats) #DSTM's busid array @@ -199,17 +200,17 @@ function miner_stats { fan=`sed 's/\n/ /' <<< $fan` IFS=', ' read -r -a bus_id_array <<< "$bus_id_array" IFS=' ' read -r -a fan <<< "$fan" - #busid's equality + + #busid equality local fans_array= - for ((i = 0; i < ${#all_bus_ids_array[@]}; i++)) - do - for ((j = 0; j < ${#bus_id_array[@]}; j++)) - do - if [ "${all_bus_ids_array[$i]}" == "${bus_id_array[$j]}" ]; then - fans_array+=("${fan[$i]}") - fi - done + for ((i = 0; i < ${#all_bus_ids_array[@]}; i++)); do + for ((j = 0; j < ${#bus_id_array[@]}; j++)); do + if [ "${all_bus_ids_array[$i]}" == "${bus_id_array[$j]}" ]; then + fans_array+=("${fan[$i]}") + fi done + done + stats=$(jq --argjson fan "`echo "${fans_array[@]}" | jq -s . | jq -c .`" --arg uptime "$uptime" --arg ac "$ac" --arg rj "$rj" \ '{ hs: [.result[].sol_ps], temp: [.result[].temperature], $fan, $uptime, ar: [$ac, $rj] }' <<< "$stats_raw") fi diff --git a/hive/bin/ewbf b/hive/bin/ewbf index fe16fc240..8845140e0 100755 --- a/hive/bin/ewbf +++ b/hive/bin/ewbf @@ -26,13 +26,9 @@ function config_gen() { cat $EWBF_GLOBAL_CONFIG > $EWBF_CONFIG - if [[ ! -z $EWBF_FORK ]] || [[ $EWBF_FORK != "legacy" ]]; then - if [[ ! -z $EWBF_ALGO ]]; then - algo=$EWBF_ALGO - else - algo="zhash" - fi - echo -e "\nalgo\t" $algo >> $EWBF_CONFIG + if [[ $EWBF_FORK == "zhash" ]]; then + [[ -z $EWBF_ALGO ]] && EWBF_ALGO="192_7" + echo -e "\nalgo\t" $EWBF_ALGO >> $EWBF_CONFIG fi [[ ! -z $EWBF_USER_CONFIG ]] && echo -e "#USER CONFIG\n$EWBF_USER_CONFIG" >> $EWBF_CONFIG @@ -76,11 +72,7 @@ function config_gen() { config_gen -if [[ -z $EWBF_FORK ]]; then - FORK="legacy" -else - FORK=$EWBF_FORK -fi +[[ -z $EWBF_FORK ]] && EWBF_FORK="legacy" cd /hive/$THIS_MINER_NAME while true @@ -91,7 +83,7 @@ do done /hive/bin/miner logrotate $THIS_MINER_NAME - /hive/$THIS_MINER_NAME/miner.sh $FORK + /hive/$THIS_MINER_NAME/miner.sh $EWBF_FORK echo "" echo -e "${YELLOW}$THIS_MINER_NAME exited, waiting to cooldown a bit${NOCOLOR}" echo "" diff --git a/hive/bin/hello b/hive/bin/hello index bc32059d1..da3ec72da 100755 --- a/hive/bin/hello +++ b/hive/bin/hello @@ -18,7 +18,7 @@ mkdir -p "/hive-config/openvpn" . $RIG_CONF [[ -z $PROJECT_HASH && -z $RIG_ID ]] && echo "Please use PROJECT_HASH or RIG_ID in config" && exit 1 -[[ -z $PROJECT_HASH && -z $RIG_PASSWD ]] && echo "No RIG_PASSWD in config" && exit 1 +[[ ! -z $RIG_ID && -z $RIG_PASSWD ]] && echo "No RIG_PASSWD in config" && exit 1 [[ -z $HIVE_HOST_URL ]] && echo "No HIVE_HOST_URL in config" && exit 1 diff --git a/hive/sbin/autofan b/hive/sbin/autofan old mode 100644 new mode 100755 index e25e9bd78..149550216 --- a/hive/sbin/autofan +++ b/hive/sbin/autofan @@ -25,6 +25,7 @@ DEF_SLEEP_TIME=20 DEF_TARGET_TEMP= #minimal fan speed DEF_MIN_FAN=30 +#maximum fan speed DEF_MAX_FAN=100 #temperature of stop miner DEF_CRITICAL_TEMP=85 @@ -165,7 +166,7 @@ get_fan_speed () { ### # What we must to do if temperature reached some limits check_overheat() { - if [[ $miner_stopped_by_overheat -eq 1 && ! `screen -ls | grep "miner"` ]]; then + if [[ $miner_stopped_by_overheat == 1 && ! `screen -ls | grep "miner"` ]]; then # if [[ true ]]; then local t local allisok=1 @@ -184,7 +185,7 @@ check_overheat() { echo -en "${NOCOLOR}" #echo2 "${GREEN}$msg${NOCOLOR}" fi - elif [[ $miner_stopped_by_overheat -eq 0 ]]; then + elif [[ $miner_stopped_by_overheat == 0 ]]; then local t for t in ${temperatures_array[@]}; do if [[ $t -ge $CRITICAL_TEMP ]]; then @@ -292,7 +293,7 @@ auto_fan_control() { echo2 "${GREEN}$(date +"%Y-%m-%d %T")${NOCOLOR}" - echo2 "${GREEN}¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯${NOCOLOR}" + #echo2 "${GREEN}¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯${NOCOLOR}" #check if exist .conf declare -a temperatures_array=(`cat $gpu_stats_json | tail -1 | jq -r ".temp | .[]"`) @@ -307,7 +308,6 @@ auto_fan_control() { PREV_CRITICAL_TEMP=$CRITICAL_TEMP PREV_MIN_FAN=$MIN_FAN PREV_MAX_FAN=$MAX_FAN - fi