Title: [Reference] May 2019 "Multi-Level" menu values
Post by: tim-bc on July 17, 2019, 07:39:34 PM
Disclaimer : 2019 firmware versions disable SSH access.So during my journey to automate configuration of miners using set_miner_conf.cgi rather than SSH, I found that the drop-down efficiency menu on the configuration page has some numerical values which you need to know in order to construct the data from scratch: 1 : Normal 228 : HashRate+2.0TH/S 227 : HashRate+1.5TH/S 226 : HashRate+1.0TH/S 225 : HashRate+0.5TH/S 250 : HashRate Unchanged-Lower Voltage 241 : HashRate-0.5TH/S 242 : HashRate-1.0TH/S 243 : HashRate-1.5TH/S 244 : HashRate-2.0TH/S 245 : HashRate-2.5TH/S 246 : HashRate-3.0TH/S 240 : Low Power Enhanced Mode So the data string to set to enhanced LPM (on default pools) would look something like this (*colons should be encoded as %3A* notice the 240 at the end): _ant_pool1url=stratum.antpool.com:3333&_ant_pool1user=antminer_1&_ant_pool1pw=123&_ant_pool2url=stratum.antpool.com:443&_ant_pool2user=antminer_1&_ant_pool2pw=123&_ant_pool3url=stratum.antpool.com:25&_ant_pool3user=antminer_1&_ant_pool3pw=123&_ant_nobeeper=false&_ant_notempoverctrl=false&_ant_fan_customize_switch=false&_ant_fan_customize_value=&_ant_freq=&_ant_asic_boost=false&_ant_low_vol_freq=false&_ant_economic_mode=false&_ant_multi_level=240 For example, in bash I can put this data into the $data variable, and send it to set_miner_conf.cgi like so (with $1 = ip and $2 = web password): curl --anyauth --user root:$2 -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST -d "$data" "http://$1/cgi-bin/set_miner_conf.cgi" Lastly, sometimes you may only want to change the efficiency mode without altering the pools. No need to hardcode the pools, you can get them from the miner even when API is down. By using mapfile, you will preserve empty fields, such as blank passwords or no third pool: $ mapfile -t pools < <(curl -s --anyauth --user root:$2 $1/cgi-bin/minerConfiguration.cgi | grep -e '"url' -e '"user' -e '"pass' | cut -d ":" -f2- | cut -d '"' -f2) $ printf '%s\n' "${pools[@]}"
stratum.antpool.com:3333 antminer_1 123 stratum.antpool.com:443 antminer_1 123 stratum.antpool.com:25 antminer_1 123
Title: Re: [Reference] May 2019 "Multi-Level" menu values
Post by: s3binator on August 03, 2019, 04:15:13 PM
So I wanted to contribute by showing how I did this using requests, but I have a little snag EDIT: FIXED. Everything works except for the working mode never updates. The config file that is loaded when loading the configuration page gives No matter what I place into the '_ant_multi_level' field, it's always blank, and this forces Working Mode to be set to Normal via the get_miner_conf javascript function. I unpacked the newest firmware, and found the set_miner_config.cgi file. It looks like this: #!/bin/sh #set -x
ant_pool1url= ant_pool1user= ant_pool1pw= ant_pool2url= ant_pool2user= ant_pool2pw= ant_pool3url= ant_pool3user= ant_pool3pw= ant_nobeeper= ant_notempoverctrl= ant_fan_customize_value= ant_fan_customize_switch= ant_freq= ant_voltage= ant_asic_boost= ant_low_vol_freq= ant_economic_mode= ant_low_vol=
ant_input=`cat /dev/stdin` ant_tmp=${ant_input//&/ } i=0 for ant_var in ${ant_tmp} do ant_var=${ant_var//+/ } ant_var=${ant_var//%23/#} ant_var=${ant_var//%24/$} ant_var=${ant_var//%25/%} ant_var=${ant_var//%26/&} ant_var=${ant_var//%2C/,} ant_var=${ant_var//%2B/+} ant_var=${ant_var//%3A/:} ant_var=${ant_var//%3B/;} ant_var=${ant_var//%3C/<} ant_var=${ant_var//%3D/=} ant_var=${ant_var//%3E/>} ant_var=${ant_var//%3F/?} ant_var=${ant_var//%40/@} ant_var=${ant_var//%5B/[} ant_var=${ant_var//%5D/]} ant_var=${ant_var//%5E/^} ant_var=${ant_var//%7B/\{} ant_var=${ant_var//%7C/|} ant_var=${ant_var//%7D/\}} ant_var=${ant_var//%2F/\/} #ant_var=${ant_var//%22/\"} #ant_var=${ant_var//%5C/\\} case ${i} in 0 ) ant_pool1url=${ant_var/_ant_pool1url=/} ;; 1 ) ant_pool1user=${ant_var/_ant_pool1user=/} ;; 2 ) ant_pool1pw=${ant_var/_ant_pool1pw=/} ;; 3 ) ant_pool2url=${ant_var/_ant_pool2url=/} ;; 4 ) ant_pool2user=${ant_var/_ant_pool2user=/} ;; 5 ) ant_pool2pw=${ant_var/_ant_pool2pw=/} ;; 6 ) ant_pool3url=${ant_var/_ant_pool3url=/} ;; 7 ) ant_pool3user=${ant_var/_ant_pool3user=/} ;; 8 ) ant_pool3pw=${ant_var/_ant_pool3pw=/} ;; 9 ) ant_nobeeper=${ant_var/_ant_nobeeper=/} ;; 10 ) ant_notempoverctrl=${ant_var/_ant_notempoverctrl=/} ;; 11 ) ant_fan_customize_switch=${ant_var/_ant_fan_customize_switch=/} ;; 12 ) ant_fan_customize_value=${ant_var/_ant_fan_customize_value=/} ;; 13 ) ant_freq=${ant_var/_ant_freq=/} ;; 14 ) ant_voltage=${ant_var/_ant_voltage=/} ;; 15 ) ant_asic_boost=${ant_var/_ant_asic_boost=/} ;; 16 ) ant_low_vol_freq=${ant_var/_ant_low_vol_freq=/} ;; 17 ) ant_economic_mode=${ant_var/_ant_economic_mode=/} ;; 18 ) ant_low_vol=${ant_var/_ant_multi_level=/} ;; esac i=`expr $i + 1` done
echo "{" > /config/bmminer.conf echo "\"pools\" : [" >> /config/bmminer.conf echo "{" >> /config/bmminer.conf echo "\"url\" : \"${ant_pool1url}\"," >> /config/bmminer.conf echo "\"user\" : \"${ant_pool1user}\"," >> /config/bmminer.conf echo "\"pass\" : \"${ant_pool1pw}\"" >> /config/bmminer.conf echo "}," >> /config/bmminer.conf echo "{" >> /config/bmminer.conf echo "\"url\" : \"${ant_pool2url}\"," >> /config/bmminer.conf echo "\"user\" : \"${ant_pool2user}\"," >> /config/bmminer.conf echo "\"pass\" : \"${ant_pool2pw}\"" >> /config/bmminer.conf echo "}," >> /config/bmminer.conf echo "{" >> /config/bmminer.conf echo "\"url\" : \"${ant_pool3url}\"," >> /config/bmminer.conf echo "\"user\" : \"${ant_pool3user}\"," >> /config/bmminer.conf echo "\"pass\" : \"${ant_pool3pw}\"" >> /config/bmminer.conf echo "}" >> /config/bmminer.conf echo "]" >> /config/bmminer.conf echo "," >> /config/bmminer.conf echo "\"api-listen\" : true," >> /config/bmminer.conf echo "\"api-network\" : true," >> /config/bmminer.conf echo "\"api-groups\" : \"A:stats:pools:devs:summary:version\"," >> /config/bmminer.conf echo "\"api-allow\" : \"A:0/0,W:*\"," >> /config/bmminer.conf if [ "${ant_nobeeper}" = "true" ]; then echo "\"bitmain-nobeeper\" : "true"," >> /config/bmminer.conf fi if [ "${ant_notempoverctrl}" = "true" ]; then echo "\"bitmain-notempoverctrl\" : "true"," >> /config/bmminer.conf fi
if [ "${ant_fan_customize_switch}" = "true" ]; then echo "\"bitmain-fan-ctrl\" : "true"," >> /config/bmminer.conf echo "\"bitmain-fan-pwm\" : \"${ant_fan_customize_value}\"," >> /config/bmminer.conf
fi echo "\"bitmain-use-vil\" : "true"," >> /config/bmminer.conf echo "\"bitmain-freq\" : \"${ant_freq}\"," >> /config/bmminer.conf #if [ "${ant_asic_boost}" = "true" ]; then # echo "\"bitmain-close-asic-boost\" : true," >> /config/bmminer.conf #fi if [ "${ant_low_vol_freq}" = "true" ]; then echo "\"bitmain-close-low-vol-freq\" : true," >> /config/bmminer.conf fi if [ "${ant_economic_mode}" = "true" ]; then echo "\"bitmain-economic-mode\" : true," >> /config/bmminer.conf fi
echo "\"bitmain-low-vol\" : \"${ant_low_vol}\"," >> /config/bmminer.conf
echo "\"bitmain-voltage\" : \"0706\"" >> /config/bmminer.conf echo "}" >> /config/bmminer.conf sync & sleep 1s
# cp /www/pages/cgi-bin/minerConfiguration2.cgi /www/pages/cgi-bin/minerConfiguration.cgi -f sync
/etc/init.d/bmminer.sh restart >/dev/null 2>&1
sleep 5s
echo "ok"
It seems like the code I provide below should work. Are there any suggestions or thoughts? Note: The URLEncode line below my dictionary converts the dictionary into the same format as Tim's data. EDIT: There was one field missing '_ant_voltage', in both Tim's and my data payload. This missing field caused the set_miner_conf.cgi bash script to improperly read what was sent after the '_ant_freq' field. I have updated the code below to working code, along with a working payload for curl.from requests.auth import HTTPDigestAuth import requests import urllib.parse
ip = 'ip' url = 'http://' + ip + '/cgi-bin/set_miner_conf.cgi' data = {} data['_ant_pool1url'] = 'url1' data['_ant_pool1user'] = 'user1' data['_ant_pool1pw'] = 'x' data['_ant_pool2url'] = 'url2' data['_ant_pool2user'] = 'user2' data['_ant_pool2pw'] = 'x' data['_ant_pool3url'] = 'url3' data['_ant_pool3user'] = 'user3' data['_ant_pool3pw'] = 'x' data['_ant_nobeeper'] = 'false' data['_ant_notempoverctrl'] = 'false' data['_ant_fan_customize_switch'] = 'false' data['_ant_fan_customize_value'] = '' data['_ant_freq'] = '' data['_ant_voltage'] = '' data['_ant_asic_boost'] = 'false' data['_ant_low_vol_freq'] = 'false' data['_ant_economic_mode'] = 'false' data['_ant_multi_level'] = '240' payload = urllib.parse.urlencode(data) r = requests.post(url, auth=HTTPDigestAuth('root', 'root'), data=payload)
The payload is the string: _ant_pool1url=url1&_ant_pool1user=user1&_ant_pool1pw=x&_ant_pool2url=url2&_ant_pool2user=user2&_ant_pool2pw=x&_ant_pool3url=url3&_ant_pool3user=user3&_ant_pool3pw=x&_ant_nobeeper=false&_ant_notempoverctrl=false&_ant_fan_customize_switch=false&_ant_fan_customize_value=&_ant_freq=&_ant_voltage=&_ant_asic_boost=false&_ant_low_vol_freq=true&_ant_economic_mode=false&_ant_multi_level=240
The above string can be used with curl, as shown by Tim in the original post.
Title: Re: [Reference] May 2019 "Multi-Level" menu values
Post by: tim-bc on August 21, 2019, 10:25:51 PM
updated the code below to working code, along with a working payload for curl.[/b] EDIT: There was one field missing '_ant_voltage'
Thanks for catching that! I actually discovered that I had left out _ant_voltage shortly after, at first I had tested changing from Enhanced -> Normal so I simply assumed everything worked. I should have posted back here earlier, but unfortunately I've had to take a break from mining for the moment, until we launch a new facility. To make up for it I'd like to share the bash script I've got for this so far. #!/bin/bash
# Antminer configuration via web portal
# Argument1 = IP Address # Argument2 = Web Password
if timeout 1 ping -c 1 $1 &> /dev/null then # Check firmware version version=$(curl -s --anyauth --user root:$2 $1/cgi-bin/get_system_info.cgi | jq '.system_filesystem_version') echo "Firmware Version: $version" # Get current pool settings names=(_ant_pool1url _ant_pool1user _ant_pool1pw _ant_pool2url _ant_pool2user _ant_pool2pw _ant_pool3url _ant_pool3user _ant_pool3pw _ant_nobeeper _ant_notempoverctrl _ant_fan_customize_switch _ant_fan_customize_value _ant_freq _ant_voltage _ant_asic_boost _ant_low_vol_freq _ant_economic_mode _ant_multi_level) mapfile -t pools < <(curl -s --anyauth --user root:$2 $1/cgi-bin/minerConfiguration.cgi | grep -e '"url' -e '"user' -e '"pass' | cut -d ":" -f2- | cut -d '"' -f2) pools+=('false') #nobeeper pools+=('false') #notempoverctrl pools+=('false') #fan_customize_switch pools+=('') #fan_customize_value pools+=('') #freq pools+=('0706') #voltage # Nov 2018 ends here pools+=('false') #asic_boost pools+=('false') #low_vol_freq pools+=('false') #economic_mode # Dec 2018 ends here pools+=('240') #multi_level # Set configuration data=$(for ((i=0; i< "${#names[@]}"; i++)) do printf "%s=%s&" "${names[$i]}" "${pools[$i]}"; done) data=$(echo "${data%?}" | sed 's/:/%3A/g') curl --anyauth --user root:$2 -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST -d "$data" "http://$1/cgi-bin/set_miner_conf.cgi" else echo "EXIT: Miner offline" fi
Also I'm wondering if anyone knows what "economic_mode" is and/or if it does anything. It is present in the Dec 2018 & May 2019 payloads and there's also a hidden checkbox for it on the configuration cgi page. Doesn't seem to do anything as far as I can tell.
|