Bitcoin Forum
April 23, 2024, 07:45:00 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bmminer api json  (Read 222 times)
sergw (OP)
Member
**
Offline Offline

Activity: 159
Merit: 12


View Profile
October 25, 2018, 03:39:36 PM
Last edit: October 26, 2018, 11:28:28 AM by frodocooper
 #1

Hi, im trying to get stats from s9 using php script, but cannot get it, i'm using following code:

Code:
$data = '{"id":1,"jsonrpc":"2.0","command":"summary"}';

$ch = curl_init('10.10.10.12:4028');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data))
);
print curl_exec($ch);

as result  i'm getting:

Code:
STATUS=E,When=1540481771,Code=14,Msg=Invalid command,Description=bmminer 1.0.0|

please help to get it worked.
1713858300
Hero Member
*
Offline Offline

Posts: 1713858300

View Profile Personal Message (Offline)

Ignore
1713858300
Reply with quote  #2

1713858300
Report to moderator
1713858300
Hero Member
*
Offline Offline

Posts: 1713858300

View Profile Personal Message (Offline)

Ignore
1713858300
Reply with quote  #2

1713858300
Report to moderator
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713858300
Hero Member
*
Offline Offline

Posts: 1713858300

View Profile Personal Message (Offline)

Ignore
1713858300
Reply with quote  #2

1713858300
Report to moderator
1713858300
Hero Member
*
Offline Offline

Posts: 1713858300

View Profile Personal Message (Offline)

Ignore
1713858300
Reply with quote  #2

1713858300
Report to moderator
1713858300
Hero Member
*
Offline Offline

Posts: 1713858300

View Profile Personal Message (Offline)

Ignore
1713858300
Reply with quote  #2

1713858300
Report to moderator
tim-bc
Full Member
***
Offline Offline

Activity: 538
Merit: 175


View Profile
October 26, 2018, 03:34:10 AM
Last edit: October 27, 2018, 03:43:05 AM by frodocooper
 #2

The API does not return perfect JSON. I don't remember exactly where the issue is but I know there's a missing comma or bracket or something.

Ignore scammers on Skype, Telegram, etc. I will only ever contact you via forum PMs. See profile for fingerprint.
sergw (OP)
Member
**
Offline Offline

Activity: 159
Merit: 12


View Profile
October 26, 2018, 09:31:31 PM
Last edit: October 27, 2018, 03:43:26 AM by frodocooper
 #3

The API does not return perfect JSON. I don't remember exactly where the issue is but I know there's a missing comma or bracket or something.

it looks like, i incorrectly pass $data using curl, as it cannot recognize the command. i cannot find working example using curl function..
tim-bc
Full Member
***
Offline Offline

Activity: 538
Merit: 175


View Profile
October 27, 2018, 03:57:14 PM
Last edit: October 27, 2018, 09:18:02 PM by frodocooper
Merited by frodocooper (2)
 #4

it looks like, i incorrectly pass $data using curl, as it cannot recognize the command. i cannot find working example using curl function..

I don't think this is a RESTful API, so you probably can't use curl. You should be able to use netcat or a similar program though. And if you are looking for stats I would use "command":"stats" instead of summary.

Now, if you look for the }{ right near the start of the second line, you will find the missing comma that I was referring to:

Code:
{"STATUS":[{"STATUS":"S","When":1540655486,"Code":70,"Msg":"BMMiner stats","Description":"bmminer 1.0.0"}],"STATS":[{"BMMiner":"2.0.0","Miner":"16.8.1.3","CompileTime":"Fri Jul 13 10:46:43 CST 2018","Type":"Antminer S9j
S9j_V2.12"}{"STATS":0,"ID":"BC50","Elapsed":676738,"Calls":0,"Wait":0.000000,"Max":0.000000,"Min":99999999.000000,"GHS 5s":"16545.91","GHS av":16656.74,"miner_count":3,"frequency":"850","fan_num":2,"fan1":0,"fan2":0,"fan3":4560,"fan4":0,"fan5":0,"fan6":4440,"fan7":0,"fan8":0,"temp_num":3,"temp1":0,"temp2":0,"temp3":0,"temp4":0,"temp5":0,"temp6":59,"temp7":54,"temp8":57,"temp9":0,"temp10":0,"temp11":0,"temp12":0,"temp13":0,"temp14":0,"temp15":0,"temp16":0,"temp2_1":0,"temp2_2":0,"temp2_3":0,"temp2_4":0,"temp2_5":0,"temp2_6":81,"temp2_7":72,"temp2_8":74,"temp2_9":0,"temp2_10":0,"temp2_11":0,"temp2_12":0,"temp2_13":0,"temp2_14":0,"temp2_15":0,"temp2_16":0,"temp3_1":0,"temp3_2":0,"temp3_3":0,"temp3_4":0,"temp3_5":0,"temp3_6":0,"temp3_7":0,"temp3_8":0,"temp3_9":0,"temp3_10":0,"temp3_11":0,"temp3_12":0,"temp3_13":0,"temp3_14":0,"temp3_15":0,"temp3_16":0,"freq_avg1":0.00,"freq_avg2":0.00,"freq_avg3":0.00,"freq_avg4":0.00,"freq_avg5":0.00,"freq_avg6":850.00,"freq_avg7":850.00,"freq_avg8":850.00,"freq_avg9":0.00,"freq_avg10":0.00,"freq_avg11":0.00,"freq_avg12":0.00,"freq_avg13":0.00,"freq_avg14":0.00,"freq_avg15":0.00,"freq_avg16":0.00,"total_rateideal":18314.09,"total_freqavg":850.00,"total_acn":189,"total_rate":16545.90,"chain_rateideal1":0.00,"chain_rateideal2":0.00,"chain_rateideal3":0.00,"chain_rateideal4":0.00,"chain_rateideal5":0.00,"chain_rateideal6":6104.70,"chain_rateideal7":6104.70,"chain_rateideal8":6104.70,"chain_rateideal9":0.00,"chain_rateideal10":0.00,"chain_rateideal11":0.00,"chain_rateideal12":0.00,"chain_rateideal13":0.00,"chain_rateideal14":0.00,"chain_rateideal15":0.00,"chain_rateideal16":0.00,"temp_max":59,"Device Hardware%":0.0004,"no_matching_work":10764,"chain_acn1":0,"chain_acn2":0,"chain_acn3":0,"chain_acn4":0,"chain_acn5":0,"chain_acn6":63,"chain_acn7":63,"chain_acn8":63,"chain_acn9":0,"chain_acn10":0,"chain_acn11":0,"chain_acn12":0,"chain_acn13":0,"chain_acn14":0,"chain_acn15":0,"chain_acn16":0,"chain_acs1":"","chain_acs2":"","chain_acs3":"","chain_acs4":"","chain_acs5":"","chain_acs6":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs7":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs8":" oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo ooooooo","chain_acs9":"","chain_acs10":"","chain_acs11":"","chain_acs12":"","chain_acs13":"","chain_acs14":"","chain_acs15":"","chain_acs16":"","chain_hw1":0,"chain_hw2":0,"chain_hw3":0,"chain_hw4":0,"chain_hw5":0,"chain_hw6":10581,"chain_hw7":78,"chain_hw8":105,"chain_hw9":0,"chain_hw10":0,"chain_hw11":0,"chain_hw12":0,"chain_hw13":0,"chain_hw14":0,"chain_hw15":0,"chain_hw16":0,"chain_rate1":"","chain_rate2":"","chain_rate3":"","chain_rate4":"","chain_rate5":"","chain_rate6":"5773.27","chain_rate7":"4768.92","chain_rate8":"6003.71","chain_rate9":"","chain_rate10":"","chain_rate11":"","chain_rate12":"","chain_rate13":"","chain_rate14":"","chain_rate15":"","chain_rate16":"","chain_xtime6":"{X0=2,X1=2,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=2,X11=2,X12=2,X13=2,X14=3,X15=2,X16=2,X17=2,X18=2,X19=2,X20=2,X21=2,X22=2,X23=2,X24=2,X25=2,X26=2,X27=10,X28=2,X29=2,X30=2,X31=2,X32=2,X33=2,X34=2,X35=2,X36=2,X37=2,X38=2,X39=2,X40=2,X41=2,X42=2,X43=2,X44=2,X45=2,X46=2,X47=2,X48=2,X49=2,X50=2,X51=2,X52=2,X53=2,X54=2,X55=2,X56=5,X57=2,X58=2,X59=2,X60=2,X61=2,X62=2}","chain_xtime7":"{X0=2,X1=11,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=3557,X11=2,X12=2,X13=2,X14=2,X15=2,X16=5,X17=2,X18=2,X19=2,X20=4,X21=2,X22=4,X23=2,X24=2,X25=2,X26=4812,X27=2,X28=2,X29=2,X30=2,X31=2,X32=3,X33=2,X34=2,X35=2,X36=2,X37=2,X38=3,X39=5,X40=2,X41=2,X42=2,X43=2,X44=3,X45=2,X46=3,X47=2,X48=5,X49=2,X50=2,X51=2,X52=2,X53=2,X54=19,X55=2,X56=3,X57=2,X58=2,X59=4,X60=4,X61=2,X62=40}","chain_xtime8":"{X0=2,X1=2,X2=2,X3=2,X4=2,X5=2,X6=2,X7=2,X8=2,X9=2,X10=2,X11=2,X12=2,X13=2,X14=2,X15=2,X16=2,X17=2,X18=2,X19=2,X20=2,X21=2,X22=2,X23=2,X24=2,X25=2,X26=2,X27=2,X28=2,X29=2,X30=2,X31=2,X32=2,X33=2,X34=2,X35=2,X36=2,X37=2,X38=2,X39=2,X40=2,X41=2,X42=2,X43=2,X44=2,X45=2,X46=2,X47=2,X48=2,X49=2,X50=2,X51=2,X52=2,X53=2,X54=2,X55=2,X56=2,X57=2,X58=2,X59=2,X60=2,X61=2,X62=2}","chain_offside_6":"0","chain_offside_7":"0","chain_offside_8":"0","chain_opencore_6":"0","chain_opencore_7":"0","chain_opencore_8":"0","miner_version":"16.8.1.3"}],"id":1}

Ignore scammers on Skype, Telegram, etc. I will only ever contact you via forum PMs. See profile for fingerprint.
fanatic26_
Full Member
***
Offline Offline

Activity: 294
Merit: 129


View Profile
October 29, 2018, 04:35:45 PM
 #5

curl doesnt work properly but as Tim says netcat will work
sergw (OP)
Member
**
Offline Offline

Activity: 159
Merit: 12


View Profile
October 30, 2018, 05:02:10 PM
 #6

you are right, strange, something wrong with curl library or im using incorrect opts.

any way i got it working using fsockopen function:

Code:
$socket = fsockopen($ip, 4028, $err_code, $err_str);
$data = '{"id":1,"jsonrpc":"2.0","command": "summary"}' . "\r\n\r\n";
fputs($socket, $data);
$buffer = null;
while (!feof($socket)) { $buffer .= fgets($socket, 4028); }
if ($socket) {  fclose($socket); }
print $buffer;
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!