Skip to content

Instantly share code, notes, and snippets.

@mraaroncruz
Last active July 20, 2021 17:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraaroncruz/f9c850b138fdb6a915b729ffa897d3cf to your computer and use it in GitHub Desktop.
Save mraaroncruz/f9c850b138fdb6a915b729ffa897d3cf to your computer and use it in GitHub Desktop.
Ethminer API Docs (lol) and some other miner APIs

EthMan uses raw TCP/IP connections (not HTTP) for remote management and statistics. Optionally, "psw" field is added to requests is the password for remote management is set for miner. The following commands are available (JSON format):


REQUEST: {"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}

RESPONSE:

{"result": ["9.3 - ETH", "21", "182724;51;0", "30502;30457;30297;30481;30479;30505", "0;0;0", "off;off;off;off;off;off", "53;71;57;67;61;72;55;70;59;71;61;70", "eth-eu1.nanopool.org:9999", "0;0;0;0"]}
"9.3 - ETH"				- miner version.
"21"					- running time, in minutes.
"182724"				- total ETH hashrate in MH/s, number of ETH shares, number of ETH rejected shares.
"30502;30457;30297;30481;30479;30505"	- detailed ETH hashrate for all GPUs.
"0;0;0"					- total DCR hashrate in MH/s, number of DCR shares, number of DCR rejected shares.
"off;off;off;off;off;off"		- detailed DCR hashrate for all GPUs.
"53;71;57;67;61;72;55;70;59;71;61;70"	- Temperature and Fan speed(%) pairs for all GPUs.
"eth-eu1.nanopool.org:9999"		- current mining pool. For dual mode, there will be two pools here.
"0;0;0;0"				- number of ETH invalid shares, number of ETH pool switches, number of DCR invalid shares, number of DCR pool switches.

COMMENTS: Gets current statistics.


REQUEST:

{"id":0,"jsonrpc":"2.0","method":"miner_restart"}

RESPONSE: none.

COMMENTS: Restarts miner.


REQUEST: {"id":0,"jsonrpc":"2.0","method":"miner_reboot"}

RESPONSE: none.

COMMENTS: Calls "reboot.bat" for Windows, or "reboot.bash" (or "reboot.sh") for Linux.


REQUEST: {"id":0,"jsonrpc":"2.0","method":"control_gpu", "params":[0, 1]}

RESPONSE: none.

COMMENTS: first number - GPU index, or "-1" for all GPUs. Second number - new GPU state, 0 - disabled, 1 - ETH-only mode, 2 - dual mode.

Taken from ethereum-mining/ethminer#253

This is a Work in Progress - PR

This PR aims to add a claymore miner compatible api to ethminer. Values not -yet- supported will return non-intrusive dummy values.

Please provide feedback.

How to test:

  • Build with -DAPICORE=ON
  • Start with --api-port 3333 (port <= 0 will disable the api)

Tested myself:

  • Win10: RX580 and GTX1080, single and mixed
  • Linux: 7x GTX1070

Features:

  • miner_getstat1 method Support to show current hashrate and other use-full informations. Since Dual-Mining is not supported it will be displayed as "off" Since Fan and Temperatures are not shown, 50% and 50°C Will be displayed
  • miner_restart method Stops all miner threads and Starts them again with last config. In Stratum Mode, also reconnects, to get new work.

Todos:

  • Password support (Not possible, password is sent in invalid spec jsonrpc, cant be read by current implementation)
  • Show current mining pool for stats (Not sure about that, i do not really found a clean way getting that to the api)
  • To be discussed: Add support for miner_reboot

Code Notes: I separated Api and ApiServer to possible add different API Modes in the future (JSON-RPC now, maybe HTTP Later) I included parts of the libjson-rpc-cpp Library, the tcpserversocket stuff to be correct, because while its possible to enable the server in the cmake file, it does not compile at least on windows due to MSVC.

Samples: Json RPC raw messages:

{"method": "miner_getstat1", "jsonrpc": "2.0", "id": 5 } and {"method": "miner_restart", "jsonrpc": "2.0", "id": 5 }

via Netcat: echo '{"method": "miner_getstat1", "jsonrpc": "2.0", "id": 5 }' | nc x.x.x.x 3333 via CURL: echo '{"method": "miner_getstat1", "jsonrpc": "2.0", "id": 5 }' | curl telnet://x.x.x.x:3333

Results

"9.3 - ETH"				- miner version.
"21"					- running time, in minutes.
"182724"				- total ETH hashrate in MH/s, number of ETH shares, number of ETH rejected shares.
"30502;30457;30297;30481;30479;30505"	- detailed ETH hashrate for all GPUs.
"0;0;0"					- total DCR hashrate in MH/s, number of DCR shares, number of DCR rejected shares.
"off;off;off;off;off;off"		- detailed DCR hashrate for all GPUs.
"53;71;57;67;61;72;55;70;59;71;61;70"	- Temperature and Fan speed(%) pairs for all GPUs.
"eth-eu1.nanopool.org:9999"		- current mining pool. For dual mode, there will be two pools here.
"0;0;0;0"				- number of ETH invalid shares, number of ETH pool switches, number of DCR invalid shares, number of DCR pool switches.

curl 127.0.0.1:42000 -X '{"id":"0", "method":"getstat"}'

{"id":0, "method":"getstat", "error":null, "result":[{"gpuid":0,
"cudaid":0, "busid":"0000:01:00.0", "gpu_status":2, "solver":0,
"temperature":79, "gpu_power_usage":157, "speed_sps":256,
"accepted_shares":5559, "rejected_shares":22}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment