hi .. can u add Json API with CORS ENABLED ?
i want make client tool for monitoring but my skill only web development and angular to make mobile app
what i need
sound warning if ethminer crashed
temperature
speed etc
thank u ..
CORS is a HTTP feature, the current JSON-API is RAW TCP, so no CORS
there is documentation for using RAW TCP (basic) ?
Send one of the following commands to the port
Restart only works if API is in RW mode. (positive port number)
Get stats: {"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}
Restart mining {"id":0,"jsonrpc":"2.0","method":"miner_restart"}
Thank you .. I will try
where can one find the documentation for that? the available api commands? the response data????
@skaldesh
for the miner_getstat1 request
{"id":0,"jsonrpc":"2.0","result":["0.13.0.dev0","5296","195423;15228;3","24415;24415;24450;24415;24450;24415;24450;24415","0;0;0","off;off;off;off;off;off;off;off","63;50; 53;50; 61;50; 63;50; 62;50; 61;50; 59;50; 58;50","eu1.ethermine.org:4444","0;0;0;0"]}
well, these numbers are totally meaningless to me, I did not develop this application...
I helped myself and inspected the source code, but man, some documentation would not hurt
"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.
ethminer api uses the same api as claymore, execpt the DCR stuff is always empty, due to no dualmining with ethminer.
With netcat:
echo '{"id":17,"jsonrpc":"2.0","method":"miner_getstat1"}' | netcat localhost 3000
With telnet:
$ telnet localhost 3000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
{"id":17,"jsonrpc":"2.0","method":"miner_getstat1"}
{"id":17,"jsonrpc":"2.0","result":["0.12.0","25","35763;15;0","35763","0;0;0","off","50;50","","0;0;0;0"]}
This output format is probably one of the worst Ive seen. You are requiring a json input, but your output is one big array, not key-value pairs that are easily read. I am certain this is low on the priority list, but please consider proper JSON output in the future of your API. Here is an example from BMiner (no affiliation, they just have a well made and documented product):
{
"stratum": {
"accepted_shares": 1,
"rejected_shares": 0,
"accepted_share_rate": 0.01,
"rejected_share_rate": 0
},
"miners": {
"0": {
"solver": {
"solution_rate": 535.6,
"nonce_rate": 287.07
},
"device": {
"temperature": 45,
"power": 255,
"global_memory_used": 828,
"utilization": {
"gpu": 100,
"memory": 84
},
"clocks": {
"core": 1885,
"memory": 5005
},
"pci": {
"bar1_used": 2,
"rx_throughput": 22,
"tx_throughput": 6
}
}
}
},
"version": "v5.1.0-6b8803e",
"start_time": 1516502494
}
Thanks! Lily
Lily, you are so right!
And add some proper documentation to this list!
I can not believe how you can offer a JSON API and mention it NOWHERE. I discovered it only because I googled a lot and ended up in one of the issues here, when it should simply be stated in the README file of the front page...
The idea was to make the API Claymore compatible, which it is.
There are at least two tools available to monitor using the API, thats why i choose to go that route.
Perhaps another method that produces proper JSON output could be added, preferably a REST interface like BMiner or Optiminer instead of a socket, and you could still maintain compatibility with existing tools on the current interface. Please consider adding this to your project.
Thanks! Lily
@starlilyth yea, the plan was to support multiple interfaces in the future.
Feel free to contribute
I wold love to write API interfaces for every miner, it certainly would make my job integrating all of them into PIMP and miner.farm vastly easier :) Unfortunately those projects take all of my time, so I can only ask for better implementations.
Thanks! Lily
well if you implemented claymore it works 1:1 with ethminer
Correct, and as I stated at the beginning of this conversation - its one of the worst output formats Ive seen. It is difficult to interpret and provides very little data. It would not be hard to do much better with very little effort, IMHO. Best of luck!
@starlilyth How so? Suggestions?
Ah! Ok, I see one sample above. Your complaint is about the lack of detail? Or, the bad presentation?
Personally, I abhor all of these text based encoding schemes, due to their high transmission overhead, as well as formatting and parsing overheads. XML, JSON, REST, etc.. waste of resources as far as I'm concerned.
@starlilyth You can use that to make an http gateway https://github.com/cgarnier/ethminer-http-api
It s the same format.
I got a influx exporter too. https://github.com/cgarnier/ethminer-influx.
There is probably some other tools using this interface created by the community but i dont know them.
Here is how I did it: (using jsonrpc)
export default class Claymore {
method = ''
host = '127.0.0.1'
port = 3333
response = {}
constructor (method) {
this.method = method
}
socket () {
try {
const socket = require('net')
var s = socket.Socket()
s.setEncoding('ascii')
s.connect(this.port, this.host)
var response = new Promise((resolve, reject) => {
s.on('data', d => {
var array = []
JSON.parse(d).result.forEach(function (d) {
array.push(d.split(';'))
})
resolve(array)
})
})
response.then((result) => {
s.end()
this.formatResponse(result)
})
s.write('{"id":0,"jsonrpc":"2.0","method":"' + this.method + '"}')
} catch (error) {
throw new Error(error)
}
}
formatResponse (data) {
var response = {}
var values = data
var temperatures = []
var hashrates = []
var fanSpeeds = []
var gpus = []
response.hashrate = values[2][0] / 1000
response.pool = values[7][0]
response.shares = {
valid: values[2][1],
invalid: values[2][2]
}
// Set GPU temperatures
values[6].forEach((data, i) => {
if (i % 2) fanSpeeds.push(data); else temperatures.push(data)
})
// Set GPU fan speed
values[3].forEach((data, i) => hashrates.push(data / 1000))
// Build response
temperatures.forEach((data, i) => {
var n = i
var gpu = {}
gpu.temperature = data
fanSpeeds.forEach((data, i) => { if (n === i) gpu.fanSpeed = data })
hashrates.forEach((data, i) => { if (n === i) gpu.hashrates = data })
gpus.push(gpu)
})
response.gpus = gpus
this.response = response
}
}
This snippet is not the best, but worked in my case. No more CORS errors.
Uage:
var c = new Claymore(miner_getstat)
c = c.socket() // opens the socket and sends request
console.log(c.response) // returns the object in a 'readable' format
Is it impossible to query current power usage via ethminer's API?
@gradinkov not to my knowledge. You could use nvidia-smi to get detailed GPU info, but I doubt the power usage is 100% correct. You should use an external hardware power meter.
atm, I am building an open source monitorig tool on top of Claymore/Ethminer. I will take a closer look at monitoring power usage and maybe implement it. (Ethminer is not implemented atm, claymore wll be used and installed together with the desktop application)
You can check the project here, but it is far from finished. Useable, but there are some known bugs that need to be fixed before I will relase it officially. Check back in a couple of weeks!!
use method miner_getstathr to get extended stats including powa
Oh, a new API call, very welcome addition, thank you!
You won't get the full power consumption with ethminer. There is
motherboard and CPU, risers... I use a dlink hs110 to get the power. It s a
WiFi counter.
Le 1 mars 2018 19:17, "gradinkov" notifications@github.com a écrit :
Oh, a new API call, very welcome addition, thank you!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ethereum-mining/ethminer/issues/295#issuecomment-369681911,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABMSpiNCVN8SRBeXkLjxfWxhQYbMR587ks5taDs1gaJpZM4PQrEZ
.
Yes, I know, but it's as close as it gets without extra hardware.
Most helpful comment
This output format is probably one of the worst Ive seen. You are requiring a json input, but your output is one big array, not key-value pairs that are easily read. I am certain this is low on the priority list, but please consider proper JSON output in the future of your API. Here is an example from BMiner (no affiliation, they just have a well made and documented product):
Thanks! Lily