Skip to content

Commit

Permalink
0.5-60 ewbf 0.2, autofans
Browse files Browse the repository at this point in the history
  • Loading branch information
dimafern committed Jun 22, 2018
1 parent 8e2c53d commit 0c8251c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 44 deletions.
53 changes: 27 additions & 26 deletions hive/bin/agent.miner_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 5 additions & 13 deletions hive/bin/ewbf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 ""
Expand Down
2 changes: 1 addition & 1 deletion hive/bin/hello
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
8 changes: 4 additions & 4 deletions hive/sbin/autofan
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 | .[]"`)
Expand All @@ -307,7 +308,6 @@ auto_fan_control() {
PREV_CRITICAL_TEMP=$CRITICAL_TEMP
PREV_MIN_FAN=$MIN_FAN
PREV_MAX_FAN=$MAX_FAN

fi


Expand Down

0 comments on commit 0c8251c

Please sign in to comment.