Skip to content

Commit

Permalink
32 Miners, required by flightsheets
Browse files Browse the repository at this point in the history
  • Loading branch information
dimafern committed Jun 29, 2018
1 parent c910f38 commit 795157e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 25 deletions.
62 changes: 51 additions & 11 deletions hive/bin/agent
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,26 @@ cpu_indexes_array=`echo "$gpu_detect_json" | jq -c '[ . | to_entries[] | select(

########################################################################################################################

function reset_miner_vars() {
#reset all miner vars
for i in {1..32}; do
eval unset MINER$i
done
}


function loop {
date

[ ! -f $RIG_CONF ] && echo -e "No config $RIG_CONF" && return

reset_miner_vars

#each time read config again
. $RIG_CONF
. $WALLET_CONF


[ -z $MINER ] && MINER="claymore"
HIVE_URL="$HIVE_HOST_URL/worker/api"

Expand All @@ -62,20 +73,41 @@ function loop {
local fan=$(jq '.fan' <<< $gpu_stats)
local power=$(jq '.power' <<< $gpu_stats)

# miner2_json=
# if [[ ! -z $MINER2 ]]; then
# miner_stats $MINER2 2
# khs2=$khs
# miner2_json=$(jq -n --arg miner2 "$MINER2" --arg total_khs2 "$khs" --argjson miner_stats2 "$stats" \
# '{"params": {$miner2, $total_khs2, $miner_stats2}}')
# fi

# Get other miners stats
local mindex
for mindex in {32..2}; do
eval minerval=\$MINER$mindex
if [[ ! -z $minerval ]]; then
miner_stats $minerval $mindex
eval khs$mindex=\$khs
miner_json=$(jq -n -c --arg miner$mindex "$minerval" --arg total_khs$mindex "$khs" --argjson miner_stats$mindex "$stats" \
'{"params": {$miner'$mindex', $total_khs'$mindex', $miner_stats'$mindex'}}')
eval miner${mindex}_json="\$miner_json"
fi
done

miner2_json=
if [[ ! -z $MINER2 ]]; then
miner_stats $MINER2 2
khs2=$khs
miner2_json=$(jq -n --arg miner2 "$MINER2" --arg total_khs2 "$khs" --argjson miner_stats2 "$stats" \
'{"params": {$miner2, $total_khs2, $miner_stats2}}')
fi

miner_stats $MINER #khs and stats are global

echo -en "Hashrate ${CYAN}$MINER${NOCOLOR} `[[ $khs > 0 ]] && echo -e ${YELLOW} || echo -e ${RED}`$khs${NOCOLOR} kH/s"
[[ ! -z $MINER2 ]] &&
echo -en " ${CYAN}$MINER2${NOCOLOR} `[[ $khs2 > 0 ]] && echo -e ${YELLOW} || echo -e ${RED}`$khs2${NOCOLOR} kH/s"
for mindex in {2..32}; do
#[[ ! -z $MINER2 ]] &&
# echo -en " ${CYAN}$MINER2${NOCOLOR} `[[ $khs2 > 0 ]] && echo -e ${YELLOW} || echo -e ${RED}`$khs2${NOCOLOR} kH/s"
eval minerval=\$MINER$mindex
if [[ ! -z $minerval ]]; then
eval khs_i=\$khs$mindex
echo -en ", ${CYAN}$minerval${NOCOLOR} `[[ $khs_i > 0 ]] && echo -e ${YELLOW} || echo -e ${RED}`$khs_i${NOCOLOR} kH/s"
fi
done

echo -en "\n"
echo $khs > /run/hive/khs

Expand Down Expand Up @@ -105,8 +137,16 @@ function loop {
}'
)

[[ ! -z $miner2_json ]] && #add miner2 stats to json
request=`echo "$request" "$miner2_json" | jq -s '.[0] * .[1]'`

# Add other miners stats to json
for mindex in {2..32}; do
#[[ ! -z $miner2_json ]] && #add miner2 stats to json
# request=`echo "$request" "$miner2_json" | jq -s '.[0] * .[1]'`
eval miner_json="\$miner${mindex}_json"
[[ ! -z $miner_json ]] && #add miner2 stats to json
request=`echo "$request" "$miner_json" | jq -s '.[0] * .[1]'`
done


echo $request | jq '.' -c

Expand Down
2 changes: 1 addition & 1 deletion hive/bin/agent.miner_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function miner_stats {
local miner=$1
local mindex=$2 #empty or 2
local mindex=$2 #empty or 2, 3, 4, ...

khs=0
stats=
Expand Down
4 changes: 3 additions & 1 deletion hive/bin/hive
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function echo2 {


cat /proc/mounts | grep -q /hive-config
if [[ $? -ne 0 ]]; then #0 - mounted (grep ok), 1 - grep not found (unmounted)
if [[ $? -ne 0 && ! -e /hive-config/rig.conf ]]; then
#0 - mounted (grep ok), 1 - grep not found (unmounted)
#checking for rig.conf is for very old systems without a mounted config partition
echo2 "${RED}Config directory /hive-config is not mounted, please check filesystem.${NOCOLOR}"
echo2 "${RED}This needs to be fixed for proper system operation.${NOCOLOR}"
echo2 "${YELLOW}Alt+F2 to switch to other terminal and login.${NOCOLOR}"
Expand Down
43 changes: 33 additions & 10 deletions hive/bin/miner
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ WALLET_CONF="/hive-config/wallet.conf"

if [ ! -f $RIG_CONF ]; then
echo -e "${RED}No config $RIG_CONF${NOCOLOR}"
#exit 1
else
. $RIG_CONF
fi
Expand All @@ -38,6 +37,7 @@ if ! printf '%s\n' "${miners_avail[@]}" | grep -xq $MINER ; then
fi



########################################################################################################################

function start() {
Expand All @@ -51,8 +51,14 @@ function start() {
fi

echo -en "Starting ${CYAN}$MINER${NOCOLOR}"
[[ ! -z $MINER2 ]] &&
echo -en " and ${CYAN}$MINER2${NOCOLOR}"
#[[ ! -z $MINER2 ]] &&
# echo -en " and ${CYAN}$MINER2${NOCOLOR}"
local mindex
for mindex in {2..32}; do
eval minerval=\$MINER$mindex
[[ ! -z $minerval ]] &&
echo -en ", ${CYAN}$minerval${NOCOLOR}"
done
echo -en "\n"

#screen -dm -S miner bash -c "${MINER}; bash"
Expand All @@ -65,9 +71,15 @@ function start() {
[[ $session_count > 0 ]] && break #echo -e "Found screen miner in $i iterations" &&
[[ $session_count == 25 ]] && echo -e "${RED}screen miner not found in 25 iterations, check logs and maybe flash drive speed${NOCOLOR}"
done
if [[ ! -z $MINER2 ]]; then
screen -S miner -X screen 2 $MINER2
fi

#[[ ! -z $MINER2 ]] &&
# screen -S miner -X screen 2 $MINER2
for mindex in {32..2}; do
eval minerval=\$MINER$mindex
[[ ! -z $minerval ]] &&
screen -S miner -X screen $mindex $minerval
done

screen -S miner -X screen 1 $MINER
}

Expand Down Expand Up @@ -310,13 +322,15 @@ function log_truncate {

# Sets MINER to MINER2 if requested
function check_second_miner {
[[ -z $1 || $1 != "2" ]] && return #not a second miner request
local mindex=$1 #empty or 2, 3, 4, ...
[[ -z $1 ]] && return #not a second miner request

[[ $1 == "2" && -z $MINER2 ]] &&
echo "No second miner configured" &&
eval minerval=\$MINER$mindex
[[ -z $minerval ]] &&
echo "No $mindex miner configured" &&
exit 1

MINER=$MINER2 #substitute MINER var with second miner
MINER=$minerval #substitute MINER var with second miner
}


Expand Down Expand Up @@ -352,6 +366,15 @@ case $1 in
check_second_miner $2
log_truncate $MINER
;;
logtruncateall) #miner logtruncate 2
log_truncate $MINER
for mindex in {2..32}; do
eval minerval=\$MINER$mindex
if [[ ! -z $minerval ]]; then
log_truncate $minerval
fi
done
;;
logdirscreate)
for minername in ${miners_avail[@]}; do
mkdir -p $MINER_LOGS_BASE_DIR/$minername
Expand Down
3 changes: 1 addition & 2 deletions hive/etc/crontab.root
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# applied on every startup

# clear log file to avoid disk usage
*/15 * * * * /hive/bin/miner logtruncate
*/15 * * * * /hive/bin/miner logtruncate 2
*/15 * * * * /hive/bin/miner logtruncateall


# clear logs to freeup space
Expand Down

0 comments on commit 795157e

Please sign in to comment.