I have an antminer asic, and it has web interface. I could see temperature and hashrate through it.

Now i want to retrieve and store that data (from multiple asics), within another program on another device. Obvious but inefficient way is to send HTTP request and parse HTML responses.

But does asic has some way (for example JSON output via some GET/POST requests, or even custom TCP protocol) to get information in machine-friendly format?

How do such aggregated statistics monitoring and control usually implemented in big farms? Is there any existing software for solving this obvious control/monitoring task?

Most Antminers have a WebSocket API that connects to the built in CGMiner software on port 4028.

You can test this in a command prompt in Windows, Mac, or Linux with (nc is a program called netcat which you may need to install):

echo -n "stats" | nc IP_OF_MINER_GOES_HERE 4028

There may also be a way to do this with CURL instead of netcat, but I have not had a chance to test it yet.

Code Examples:

api-example.php - a php script to access the API usAge: php api-example.php command by default it sends a 'summary' request to the miner at 127.0.0.1:4028 If you specify a command it will send that request instead You must modify the line "$socket = getsock('127.0.0.1', 4028);" at the beginning of "function request($cmd)" to change where it looks for cgminer

api-example.rb - a Ruby script to access the API. usage: ruby api-example.rb command[:parameter] [HOST [PORT]] This script prints the parsed cgminer API response

API.java/API.class a java program to access the API (with source code) usAge is: java API command address port Any missing or blank parameters are replaced as if you entered: java API summary 127.0.0.1 4028

api-example.c - a 'C' program to access the API (with source code)
usAge: api-example [command [ip/host [port]]] again, as above, missing or blank parameters are replaced as if you entered:
api-example summary 127.0.0.1 4028

Java Example

C Example

PHP Example

Python Example

Ruby Example

I've built a small script for my personal miners which will not work for most environments (due to reliance on data from SlushPool), but it may be useful for some code snippets (C#): Here

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.