Skip to content

Commit

Permalink
Merge pull request #20 from bu11ettrain/master
Browse files Browse the repository at this point in the history
Add mmpOS integration. Special thanks to @ddobreff
  • Loading branch information
CoinFuMasterShifu authored Mar 26, 2024
2 parents 56b7660 + e1265cd commit 2470496
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docker_build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
run: |
cp ./integrations/hiveos/* ./build/Ubuntu20
./build/Ubuntu20/build.sh janusminer_hiveosbeta ${{ env.VERSION }}
- name: Build for mmpOS
run: |
cp ./integrations/mmpos/* ./build/Ubuntu20
./build/Ubuntu20/build_mmpos.sh janusminer_mmpos ${{ env.VERSION }}
- name: Create Release
id: create_release
Expand Down Expand Up @@ -91,6 +96,17 @@ jobs:
asset_path: ./build/Ubuntu20/janusminer_hiveosbeta-${{ env.VERSION }}.tgz
asset_name: janusminer_hiveosbeta-${{ env.VERSION }}.tgz
asset_content_type: application/octet-stream

- name: Upload mmpOS build
id: upload-docker-build-output-mmpos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/Ubuntu20/janusminer_mmpos_${{ env.VERSION }}.tar.gz
asset_name: janusminer_mmpos_${{ env.VERSION }}.tar.gz
asset_content_type: application/octet-stream

- name: Upload Windows build
id: upload-docker-build-output-windows
Expand Down
17 changes: 17 additions & 0 deletions integrations/mmpos/build_mmpos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
####################################################################################
###
### janusminer
###
####################################################################################

if [ "$#" -ne "2" ]
then
echo "No arguments supplied. Call using build.sh <CUSTOM_NAME> <VERSION_NUMBER>"
exit
fi

cd `dirname $0`
./createconf.sh $2
mkdir $1
cp mmp-* wart-miner $1
tar czvf $1_$2.tar.gz $1
47 changes: 47 additions & 0 deletions integrations/mmpos/createconf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
####################################################################################
###
### janusminer
###
####################################################################################

if [ "$#" -ne "1" ]
then
echo "No arguments supplied. Call using createmanifest.sh <VERSION_NUMBER>"
exit
fi

cat > mmp-external.conf << EOF
####################################################################################
###
### janusminer
###
### MMP integration: Dobromir Dobrev < [email protected] >
###
####################################################################################
# Name of external miner
EXTERNAL_NAME="janusminer"
# API Protocol used - TBA.
EXTERNAL_PROTOCOL="miner-script"
# Architecture support for miner damominer
EXTERNAL_ARCH="nvidia"
# Version if provided
EXTERNAL_VERSION=$1
# Miner executable binary
EXTERNAL_BIN="wart-miner"
# Miner command options
EXTERNAL_CMD_OPTS=""
# Specify miner config for startup if available
# EXTERNAL_CONFIG=/opt/mmp/miners/external/damominer/damominer.conf
# If you provide extra params place them below this comment
EXTERNAL_REQUIREMENTS=""
EOF
119 changes: 119 additions & 0 deletions integrations/mmpos/mmp-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/usr/bin/env bash
# This file will contain functions related to gathering stats and displaying it for agent
# Agent will have to call mmp-stats.sh which will contain triggers for configuration files and etc.
# Do not add anything static in this file
GPU_COUNT=$1
LOG_FILE=$2
cd `dirname $0`
. mmp-external.conf


get_bus_ids() {
local vendor_id="$1"
local bus_ids=$(/bin/lspci -n | awk '$1 !~ /^00:/ && $2 ~ /^0300|0302:/ && $3 ~ /^'"${vendor_id}"':/ {print $1}')
local format_bus_ids=()

if [ -z "$bus_ids" ]; then
exit 1
fi

while read -r bus_id; do
local format_bus_id=${bus_id%%:*}
format_bus_ids+=("$format_bus_id")
done <<< "$bus_ids"

echo "${format_bus_ids[*]}"
}

get_cpu_hashes() {
hash=''
local khs=$(cat "$LOG_FILE" | grep 'Total hashrate (CPU): [0-9.].*mh/s'| sed -n 's/.*: \([0-9.]\+\) mh\/s.*/\1/p'|tail -n1)
if [[ -z "$khs" ]]; then
khs="0"
fi
if (( $(echo "$khs > 0" | bc -l) )); then
hash_cpu=$khs
fi
}

get_cards_hashes() {
hash=''
for (( i=0; i < $GPU_COUNT; i++ )); do
hash[$i]=''
local mhs=$(cat "$LOG_FILE" | grep "\[${i}\].*mh/s"| sed -n 's/.*: \([0-9.]\+\) mh\/s.*/\1/p'|head -n1)
if [[ -z "$mhs" ]]; then
mhs="0"
fi
if (( $(echo "$mhs > 0" | bc -l) )); then
hash_gpu[$i]=$mhs
fi
done
}

get_miner_shares_ac(){
ac=0
local ac=$(cat "$LOG_FILE" |grep Mined | head -n 1 | awk '{print substr($(NF-2), 1, length($(NF-2))-1)}')
if [[ -z "$ac" ]]; then
local ac="0"
fi
echo $ac
}

get_miner_shares_rj(){
rj=0
local rj=$(cat "$LOG_FILE" |grep Mined | head -n 1 | awk '{print substr($NF, 1, length($NF)-1)}')
if [[ -z "$rj" ]]; then
local rj="0"
fi
echo $rj
}

get_miner_stats() {
stats=

local amd_bus_ids=$(get_bus_ids "1002")
local nv_bus_ids=$(get_bus_ids "10de")
local intel_bus_ids=$(get_bus_ids "8086")

# busid generation for both CPU and GPU
busid=( "cpu" )
busid+=( "${amd_bus_ids[@]}" )
busid+=( "${nv_bus_ids[@]}" )
busid+=( "${intel_bus_ids[@]}" )

# Construct the JSON string for busid
json_busid="[\"${busid[0]}\","
for ((i = 1; i < ${#busid[@]}; i++)); do
IFS=' ' read -ra ids <<< "${busid[$i]}"
for id in "${ids[@]}"; do
json_busid+="\"$id\", "
done
done
json_busid="${json_busid%, }"
json_busid+="]"

# hashrate gathering
local hash_cpu
get_cpu_hashes
local hash_gpu=()
get_cards_hashes
local hash=()
hash+=( "${hash_cpu[@]}" )
hash+=( "${hash_gpu[@]}" )
local units='mhs' # hashes units
# A/R shares by pool
local ac=$(get_miner_shares_ac)
local rj=$(get_miner_shares_rj)

stats=$(jq -nc \
--argjson hash "$(echo ${hash[*]} | tr " " "\n" | jq -cs '.')" \
--argjson busid "$json_busid" \
--arg units "$units" \
--arg ac "$ac" --arg inv "0" --arg rj "$rj" \
--arg miner_version "$CUSTOM_VERSION" \
--arg miner_name "$CUSTOM_NAME" \
'{$busid, $hash, $units, air: [$ac, $inv, $rj], miner_name: $miner_name, miner_version: $miner_version}')
# total hashrate in khs
echo $stats
}
get_miner_stats $GPU_COUNT $LOG_FILE

0 comments on commit 2470496

Please sign in to comment.