Untitled


SUBMITTED BY: Guest

DATE: Dec. 11, 2013, 8:25 p.m.

FORMAT: Text only

SIZE: 63.1 kB

HITS: 21349

  1. This README contains details about the BFGMiner RPC API
  2. It also includes some detailed information at the end,
  3. about using miner.php
  4. If you start BFGMiner with the "--api-listen" option, it will listen on a
  5. simple TCP/IP socket for single string API requests from the same machine
  6. running BFGMiner and reply with a string and then close the socket each time
  7. If you add the "--api-network" option, it will accept API requests from any
  8. network attached computer.
  9. You can only access the commands that reply with data in this mode.
  10. By default, you cannot access any privileged command that affects the miner -
  11. you will receive an access denied status message instead. See --api-allow below
  12. for more details.
  13. You can specify IP addresses/prefixes that are only allowed to access the API
  14. with the "--api-allow" option, e.g. --api-allow W:192.168.0.1,10.0.0/24
  15. will allow 192.168.0.1 or any address matching 10.0.0.*, but nothing else.
  16. IP addresses are automatically padded with extra '.0's as needed
  17. Without a /prefix is the same as specifying /32.
  18. 0/0 means all IP addresses.
  19. The 'W:' on the front gives that address/subnet privileged access to commands
  20. that modify BFGMiner (thus all API commands).
  21. Without it those commands return an access denied status.
  22. See --api-groups below to define other groups like W:
  23. Privileged access is checked in the order the IP addresses were supplied to
  24. "--api-allow"
  25. The first match determines the privilege level.
  26. Using the "--api-allow" option overrides the "--api-network" option if they
  27. are both specified
  28. With "--api-allow", 127.0.0.1 is not by default given access unless specified
  29. If you start BFGMiner also with the "--api-mcast" option, it will listen for
  30. a multicast message and reply to it with a message containing it's API port
  31. number, but only if the IP address of the sender is allowed API access.
  32. More groups (like the privileged group W:) can be defined using the
  33. --api-groups command
  34. Valid groups are only the letters A-Z (except R & W are predefined) and are
  35. not case sensitive.
  36. The R: group is the same as not privileged access.
  37. The W: group is (as stated) privileged access (thus all API commands).
  38. To give an IP address/subnet access to a group you use the group letter
  39. in front of the IP address instead of W: e.g. P:192.168.0/32
  40. An IP address/subnet can only be a member of one group.
  41. A sample API group would be:
  42. --api-groups
  43. P:switchpool:enablepool:addpool:disablepool:removepool:poolpriority:*
  44. This would create a group 'P' that can do all current pool commands and all
  45. non-privileged commands - the '*' means all non-privileged commands.
  46. Without the '*' the group would only have access to the pool commands.
  47. Defining multiple groups example:
  48. --api-groups Q:quit:restart:*,S:save
  49. This would define 2 groups:
  50. Q: that can 'quit' and 'restart' as well as all non-privileged commands.
  51. S: that can only 'save' and no other commands.
  52. The RPC API request can be either simple text or JSON.
  53. If the request is JSON (starts with '{'), it will reply with a JSON formatted
  54. response, otherwise it replies with text formatted as described further below.
  55. The JSON request format required is '{"command":"CMD","parameter":"PARAM"}'
  56. (though of course parameter is not required for all requests)
  57. where "CMD" is from the "Request" column below and "PARAM" would be e.g.
  58. the CPU/GPU number if required.
  59. An example request in both formats to set GPU 0 fan to 80%:
  60. gpufan|0,80
  61. {"command":"gpufan","parameter":"0,80"}
  62. The format of each reply (unless stated otherwise) is a STATUS section
  63. followed by an optional detail section.
  64. From API version 1.7 onwards, reply strings in JSON and Text have the
  65. necessary escaping as required to avoid ambiguity - they didn't before 1.7.
  66. For JSON the 2 characters '"' and '\' are escaped with a '\' before them.
  67. For Text the 4 characters '|' ',' '=' and '\' are escaped the same way.
  68. Only user entered information will contain characters that require being
  69. escaped, such as Pool URL, User and Password or the Config save filename,
  70. when they are returned in messages or as their values by the API.
  71. For API version 1.4 and later:
  72. The STATUS section is:
  73. STATUS=X,When=NNN,Code=N,Msg=string,Description=string|
  74. STATUS=X Where X is one of:
  75. W - Warning
  76. I - Informational
  77. S - Success
  78. E - Error
  79. F - Fatal (code bug)
  80. When=NNN
  81. Standard long time of request in seconds.
  82. Code=N
  83. Each unique reply has a unique Code (See api.c - #define MSG_NNNNNN).
  84. Msg=string
  85. Message matching the Code value N.
  86. Description=string
  87. This defaults to the BFGMiner version but is the value of --api-description
  88. if it was specified at runtime.
  89. For API version 1.10 and later:
  90. The list of requests - a (*) means it requires privileged access - and replies:
  91. Request Reply Section Details
  92. ------- ------------- -------
  93. version VERSION CGMiner=BFGMiner version
  94. API=API version
  95. config CONFIG Some miner configuration information:
  96. GPU Count=N, <- the number of GPUs
  97. PGA Count=N, <- the number of PGAs
  98. CPU Count=N, <- the number of CPUs
  99. Pool Count=N, <- the number of Pools
  100. ADL=X, <- Y or N if ADL is compiled in the code
  101. ADL in use=X, <- Y or N if any GPU has ADL
  102. Strategy=Name, <- the current pool strategy
  103. Log Interval=N, <- log interval (--log N)
  104. Device Code=GPU ICA , <- spaced list of compiled
  105. device drivers
  106. OS=Linux/Apple/..., <- operating System
  107. Failover-Only=true/false, <- failover-only setting
  108. ScanTime=N, <- --scan-time setting
  109. Queue=N, <- --queue setting
  110. Expiry=N| <- --expiry setting
  111. summary SUMMARY The status summary of the miner
  112. e.g. Elapsed=NNN,Found Blocks=N,Getworks=N,...|
  113. pools POOLS The status of each pool e.g.
  114. Pool=0,URL=http://pool.com:6311,Status=Alive,...|
  115. devs DEVS Each available GPU, PGA and CPU with their status
  116. e.g. GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
  117. Last Share Time=NNN, <- standard long time in sec
  118. (or 0 if none) of last accepted share
  119. Last Share Pool=N, <- pool number (or -1 if none)
  120. Last Valid Work=NNN, <- standand long time in sec
  121. of last work returned that wasn't an HW:
  122. Will not report PGAs if PGA mining is disabled
  123. Will not report CPUs if CPU mining is disabled
  124. procs DEVS The details of each processor in the same format
  125. and details as for DEVS
  126. devscan|info DEVS Probes for a device specified by info, which is
  127. the same format as the --scan-serial command line
  128. option
  129. gpu|N GPU The details of a single GPU number N in the same
  130. format and details as for DEVS
  131. pga|N PGA The details of a single PGA number N in the same
  132. format and details as for DEVS
  133. This is only available if PGA mining is enabled
  134. Use 'pgacount' or 'config' first to see if there
  135. are any
  136. proc|N PGA The details of a single processor number N in the
  137. same format and details as for DEVS
  138. cpu|N CPU The details of a single CPU number N in the same
  139. format and details as for DEVS
  140. This is only available if CPU mining is enabled
  141. Use 'cpucount' or 'config' first to see if there are any
  142. gpucount GPUS Count=N| <- the number of GPUs
  143. pgacount PGAS Count=N| <- the number of PGAs
  144. Always returns 0 if PGA mining is disabled
  145. proccount PGAS Count=N| <- the number of processors
  146. cpucount CPUS Count=N| <- the number of CPUs
  147. Always returns 0 if CPU mining is disabled
  148. switchpool|N (*)
  149. none There is no reply section just the STATUS section
  150. stating the results of switching pool N to the
  151. highest priority (the pool is also enabled)
  152. The Msg includes the pool URL
  153. enablepool|N (*)
  154. none There is no reply section just the STATUS section
  155. stating the results of enabling pool N
  156. The Msg includes the pool URL
  157. addpool|URL,USR,PASS (*)
  158. none There is no reply section just the STATUS section
  159. stating the results of attempting to add pool N
  160. The Msg includes the pool URL
  161. Use '\\' to get a '\' and '\,' to include a comma
  162. inside URL, USR or PASS
  163. poolpriority|N,... (*)
  164. none There is no reply section just the STATUS section
  165. stating the results of changing pool priorities
  166. See usage below
  167. poolquota|N,Q (*)
  168. none There is no reply section just the STATUS section
  169. stating the results of changing pool quota to Q
  170. disablepool|N (*)
  171. none There is no reply section just the STATUS section
  172. stating the results of disabling pool N
  173. The Msg includes the pool URL
  174. removepool|N (*)
  175. none There is no reply section just the STATUS section
  176. stating the results of removing pool N
  177. The Msg includes the pool URL
  178. N.B. all details for the pool will be lost
  179. cpuenable|N (*)
  180. none There is no reply section just the STATUS section
  181. stating the results of the enable request
  182. cpudisable|N (*)
  183. none There is no reply section just the STATUS section
  184. stating the results of the disable request
  185. cpurestart|N (*)
  186. none There is no reply section just the STATUS section
  187. stating the results of the restart request
  188. gpuenable|N (*)
  189. none There is no reply section just the STATUS section
  190. stating the results of the enable request
  191. gpudisable|N (*)
  192. none There is no reply section just the STATUS section
  193. stating the results of the disable request
  194. gpurestart|N (*)
  195. none There is no reply section just the STATUS section
  196. stating the results of the restart request
  197. gpuintensity|N,I (*)
  198. none There is no reply section just the STATUS section
  199. stating the results of setting GPU N intensity
  200. to I
  201. gpumem|N,V (*)
  202. none There is no reply section just the STATUS section
  203. stating the results of setting GPU N memoryclock
  204. to V MHz
  205. gpuengine|N,V (*)
  206. none There is no reply section just the STATUS section
  207. stating the results of setting GPU N clock
  208. to V MHz
  209. gpufan|N,V (*)
  210. none There is no reply section just the STATUS section
  211. stating the results of setting GPU N fan speed
  212. to V%
  213. gpuvddc|N,V (*)
  214. none There is no reply section just the STATUS section
  215. stating the results of setting GPU N vddc to V
  216. save|filename (*)
  217. none There is no reply section just the STATUS section
  218. stating success or failure saving the BFGMiner
  219. config to filename
  220. The filename is optional and will use the BFGMiner
  221. default if not specified
  222. quit (*) none There is no status section but just a single "BYE"
  223. reply before BFGMiner quits
  224. notify NOTIFY The last status and history count of each devices
  225. problem
  226. e.g. NOTIFY=0,Name=PGA,ID=0,ProcID=0,Last Well=1332432290,...|
  227. privileged (*)
  228. none There is no reply section just the STATUS section
  229. stating an error if you do not have privileged
  230. access to the API and success if you do have
  231. privilege
  232. The command doesn't change anything in BFGMiner
  233. pgaenable|N (*)
  234. none There is no reply section just the STATUS section
  235. stating the results of the enable request
  236. You cannot enable a PGA if its status is not WELL
  237. This is only available if PGA mining is enabled
  238. pgadisable|N (*)
  239. none There is no reply section just the STATUS section
  240. stating the results of the disable request
  241. This is only available if PGA mining is enabled
  242. pgaidentify|N (*)
  243. none This is equivalent to PROCIDENTIFY on the first
  244. processor of any given device
  245. This is only available if PGA mining is enabled
  246. procenable|N (*)
  247. none There is no reply section just the STATUS section
  248. stating the results of the enable request
  249. procdisable|N (*)
  250. none There is no reply section just the STATUS section
  251. stating the results of the disable request
  252. procidentify|N (*)
  253. none There is no reply section just the STATUS section
  254. stating the results of the identify request
  255. On most supported devices, it will flash the led
  256. for approximately 4s
  257. All unsupported devices, it will return a warning
  258. status message stating that they don't support it
  259. For BFL, this adds a 4s delay to the share being
  260. processed so you may get a message stating that
  261. processing took longer than 7000ms if the request
  262. was sent towards the end of the timing of any work
  263. being worked on
  264. e.g.: BFL0: took 8438ms - longer than 7000ms
  265. You should ignore this
  266. devdetails DEVDETAILS Each device with a list of their static details
  267. This lists all devices including those not
  268. supported by the 'devs' command
  269. e.g. DEVDETAILS=0,Name=BFL,ID=0,ProcID=0,Driver=bitforce,...|
  270. restart (*) none There is no status section but just a single
  271. "RESTART" reply before BFGMiner restarts
  272. stats STATS Each device or pool that has 1 or more getworks
  273. with a list of stats regarding getwork times
  274. The values returned by stats may change in future
  275. versions thus would not normally be displayed
  276. Device drivers are also able to add stats to the
  277. end of the details returned
  278. check|cmd COMMAND Exists=Y/N, <- 'cmd' exists in this version
  279. Access=Y/N| <- you have access to use 'cmd'
  280. failover-only|true/false (*)
  281. none There is no reply section just the STATUS section
  282. stating what failover-only was set to
  283. coin COIN Coin mining information:
  284. Hash Method=sha256/scrypt,
  285. Current Block Time=N.N, <- 0 means none
  286. Current Block Hash=XXXX..., <- blank if none
  287. LP=true/false, <- LP is in use on at least 1 pool
  288. Network Difficulty=NN.NN|
  289. debug|setting (*)
  290. DEBUG Debug settings
  291. The optional commands for 'setting' are the same
  292. as the screen curses debug settings
  293. You can only specify one setting
  294. Only the first character is checked - case
  295. insensitive:
  296. Silent, Quiet, Verbose, Debug, RPCProto,
  297. PerDevice, WorkTime, Normal
  298. The output fields are (as above):
  299. Silent=true/false,
  300. Quiet=true/false,
  301. Verbose=true/false,
  302. Debug=true/false,
  303. RPCProto=true/false,
  304. PerDevice=true/false,
  305. WorkTime=true/false|
  306. setconfig|name,value (*)
  307. none There is no reply section just the STATUS section
  308. stating the results of setting 'name'
  309. The valid values for name are currently:
  310. queue, scantime, expiry (integer in the range
  311. 0 to 9999)
  312. coinbase-sig (string)
  313. pgaset|N,opt[,val] (*)
  314. none This is equivalent to PROCSET on the first
  315. processor of any given device
  316. This is only available if PGA mining is enabled
  317. procset|N,opt[,val] (*)
  318. none There is no reply section just the STATUS section
  319. stating the results of setting processor N with
  320. opt[,val]
  321. If the processor does not support any set options,
  322. it will always return a WARN stating pgaset isn't
  323. supported
  324. If opt=help it will return an INFO status with a
  325. help message about the options available
  326. The current options are:
  327. MMQ opt=clock val=2 to 250 (a multiple of 2)
  328. XBS opt=clock val=2 to 250 (a multiple of 2)
  329. zero|Which,true/false (*)
  330. none There is no reply section just the STATUS section
  331. stating that the zero, and optional summary, was
  332. done
  333. If Which='all', all normal BFGMiner and API
  334. statistics will be zeroed other than the numbers
  335. displayed by the stats command
  336. If Which='bestshare', only the 'Best Share' values
  337. are zeroed for each pool and the global
  338. 'Best Share'
  339. The true/false option determines if a full summary
  340. is shown on the BFGMiner display like is normally
  341. displayed on exit.
  342. When you enable, disable or restart a GPU or PGA, you will also get Thread
  343. messages in the BFGMiner status window.
  344. The 'poolpriority' command can be used to reset the priority order of multiple
  345. pools with a single command - 'switchpool' only sets a single pool to first
  346. priority. Each pool should be listed by id number in order of preference (first
  347. = most preferred). Any pools not listed will be prioritised after the ones that
  348. are listed, in the priority order they were originally If the priority change
  349. affects the miner's preference for mining, it may switch immediately.
  350. When you switch to a different pool to the current one (including by priority
  351. change), you will get a 'Switching to URL' message in the BFGMiner status
  352. windows.
  353. Obviously, the JSON format is simply just the names as given before the '='
  354. with the values after the '='.
  355. If you enable BFGMiner debug (--debug or using RPC), you will also get messages
  356. showing some details of the requests received and the replies.
  357. There are included 5 program examples for accessing the API:
  358. api-example.php - a PHP script to access the API.
  359. usage: php api-example.php command
  360. by default it sends a 'summary' request to the miner at 127.0.0.1:4028
  361. If you specify a command it will send that request instead.
  362. You must modify the line "$socket = getsock('127.0.0.1', 4028);" at the
  363. beginning of "function request($cmd)" to change where it looks for BFGMiner.
  364. api-example.c - a 'C' program to access the API (with source code).
  365. usage: api-example [command [ip/host [port]]]
  366. again, as above, missing or blank parameters are replaced as if you entered:
  367. api-example summary 127.0.0.1 4028
  368. miner.php - an example web page to access the API.
  369. This includes buttons and inputs to attempt access to the privileged commands.
  370. See the end of this README.RPC for details of how to tune the display
  371. and also to use the option to display a multi-rig summary.
  372. api-example.py - a Python script to access the API.
  373. usage: python api-example.py [--host HOST] [--port PORT] [command] [parameter]
  374. by default it sends a 'summary' request to the miner at 127.0.0.1:4028
  375. If you specify a command it will send that request instead.
  376. ----------
  377. Feature Changelog for external applications using the API:
  378. API V2.3 (BFGMiner v3.7.0)
  379. Modified API command:
  380. 'devdetails' - Add 'Processors', 'Manufacturer', 'Product', 'Serial',
  381. 'Target Temperature', 'Cutoff Temperature'
  382. 'procdetails' - Add 'Manufacturer', 'Product', 'Serial', 'Target Temperature',
  383. 'Cutoff Temperature'
  384. ---------
  385. API V2.2 (BFGMiner v3.6.0)
  386. Modified API command:
  387. 'pools' - add 'Works'
  388. ---------
  389. API V2.1 (BFGMiner v3.4.0)
  390. Added API command:
  391. 'poolquota' - Set pool quota for load-balance strategy.
  392. Modified API command:
  393. 'devs', 'gpu', 'pga', 'procs' and 'asc' - add 'Device Elapsed', 'Stale',
  394. 'Work Utility', 'Difficulty Stale'
  395. 'pools' - add 'Quota'
  396. 'summary' - add 'Diff1 Work', 'MHS %ds' (where %d is the log interval)
  397. ---------
  398. API V2.0 (BFGMiner v3.3.0)
  399. Removed API commands:
  400. 'devdetail' - Use newer 'devdetails' for same information.
  401. Modified API commands:
  402. 'devs' - display status of each full device only (not processors)
  403. 'pga' - lookup and display device by device (not processor) number
  404. 'pgacount' - count only full devices (not processors)
  405. 'pgaenable' - enable all processors for a numbered full device
  406. 'pgadisable' - disable all processors for a numbered full device
  407. 'pgaidentify' - choose first processor of numbered full device
  408. 'pgaset' - choose first processor of numbered full device
  409. Added API commands:
  410. 'procs'
  411. 'proc'
  412. 'proccount'
  413. 'procenable'
  414. 'procdisable'
  415. 'procidentify'
  416. 'procset'
  417. ----------
  418. API V1.25.3 (BFGMiner v3.2.0)
  419. Modified API commands:
  420. 'devs', 'pga', 'gpu' - add 'Device Hardware%' and 'Device Rejected%'
  421. 'pools' - add 'Pool Rejected%' and 'Pool Stale%'
  422. 'setconfig' - add 'http-port' number
  423. 'summary' - add 'Device Hardware%', 'Device Rejected%', 'Pool Rejected%',
  424. 'Pool Stale%'
  425. Removed output limitation:
  426. All replies can now be longer than the previous limitation of 64k, and will
  427. only be truncated on a 50ms timeout sending.
  428. Basic support for cgminer-compatible multicast RPC detection added.
  429. ----------
  430. API V1.25.2 (BFGMiner v3.1.4)
  431. Modified API commands:
  432. 'pgaset' - added: XBS opt=clock val=2 to 250 (and a multiple of 2)
  433. ----------
  434. API V1.25.1 (BFGMiner v3.1.2)
  435. Added API commands:
  436. 'devscan'
  437. ----------
  438. API V1.25 (BFGMiner v3.0.1)
  439. Modified API commands:
  440. 'devs' 'gpu' and 'pga' - add 'Last Valid Work'
  441. ----------
  442. API V1.24.1 (BFGMiner v3.0.0)
  443. Modified API commands:
  444. 'cpustatus' - add 'ProcID'
  445. 'gpustatus' - add 'ProcID'
  446. 'pgastatus' - add 'ProcID'
  447. 'devstatus' - add 'ProcID'
  448. 'notify' - add 'ProcID'
  449. 'devdetails' - add 'ProcID'
  450. 'devdetail' - add 'Name', 'ID', and 'ProcID'
  451. 'pools' - add 'Message'
  452. 'coin' - add 'Network Difficulty'
  453. Pretty much updated every method returning 'Name' and 'ID' to also return
  454. 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.
  455. ----------
  456. API V1.24 (BFGMiner v2.10.3)
  457. Added API commands:
  458. 'zero'
  459. Modified API commands:
  460. 'pools' - add 'Best Share'
  461. 'stats' - rename 'Bytes Sent' and 'Bytes Recv' to 'Net Bytes Sent' and
  462. 'Net Bytes Recv'
  463. ----------
  464. API V1.23 (BFGMiner v2.10.1)
  465. Added API commands:
  466. 'pgaset' - with: MMQ opt=clock val=2 to 230 (and a multiple of 2)
  467. ----------
  468. API V1.22 (not released)
  469. Enforced output limitation:
  470. all extra records beyond the output limit of the API (~64k) are ignored and
  471. chopped off at the record boundary before the limit is reached however, JSON
  472. brackets will be correctly closed and the JSON id will be set to 0 (instead
  473. of 1) if any data was truncated.
  474. Modified API commands:
  475. 'stats' - add 'Times Sent', 'Bytes Sent', 'Times Recv', 'Bytes Recv'
  476. ----------
  477. API V1.21 (BFGMiner v2.10.0)
  478. Modified API commands:
  479. 'summary' - add 'Best Share'
  480. ----------
  481. API V1.20b (BFGMiner v2.9.1)
  482. Support for the X6500 FPGA was added.
  483. ----------
  484. API V1.20 (BFGMiner v2.9.0)
  485. Modified API commands:
  486. 'pools' - add 'Has Stratum', 'Stratum Active', 'Stratum URL'
  487. ----------
  488. API V1.19b (BFGMiner v2.8.1)
  489. Added API commands:
  490. 'pgaidentify|N' (only works for BitForce Singles so far)
  491. Modified API commands:
  492. Change pool field name back from 'Diff1 Work' to 'Diff1 Shares'
  493. 'devs' - add 'Difficulty Accepted', 'Difficulty Rejected',
  494. 'Last Share Difficulty' to all devices
  495. 'gpu|N' - add 'Difficulty Accepted', 'Difficulty Rejected',
  496. 'Last Share Difficulty'
  497. 'pga|N' - add 'Difficulty Accepted', 'Difficulty Rejected',
  498. 'Last Share Difficulty'
  499. 'notify' - add '*Dev Throttle' (for BitForce Singles)
  500. 'pools' - add 'Difficulty Accepted', 'Difficulty Rejected',
  501. 'Difficulty Stale', 'Last Share Difficulty'
  502. 'stats' - add 'Work Diff', 'Min Diff', 'Max Diff', 'Min Diff Count',
  503. 'Max Diff Count' to the pool stats
  504. 'setconfig|name,value' - add 'Coinbase-Sig' string
  505. ----------
  506. API V1.19 (BFGMiner v2.8.0)
  507. Added API commands:
  508. 'debug'
  509. 'setconfig|name,N'
  510. Modified API commands:
  511. Change pool field name 'Diff1 Shares' to 'Diff1 Work'
  512. 'devs' - add 'Diff1 Work' to all devices
  513. 'gpu|N' - add 'Diff1 Work'
  514. 'pga|N' - add 'Diff1 Work'
  515. 'pools' - add 'Proxy'
  516. 'config' - add 'Queue', 'Expiry'
  517. ----------
  518. API V1.18 (BFGMiner v2.7.4)
  519. Modified API commands:
  520. 'stats' - add 'Work Had Roll Time', 'Work Can Roll', 'Work Had Expire',
  521. and 'Work Roll Time' to the pool stats
  522. 'config' - include 'ScanTime'
  523. ----------
  524. API V1.17b (BFGMiner v2.7.1)
  525. Modified API commands:
  526. 'summary' - add 'Work Utility'
  527. 'pools' - add 'Diff1 Shares'
  528. ----------
  529. API V1.17 (BFGMiner v2.6.5)
  530. Added API commands:
  531. 'coin'
  532. ----------
  533. API V1.16 (BFGMiner v2.6.5)
  534. Added API commands:
  535. 'failover-only'
  536. Modified API commands:
  537. 'config' - include failover-only state
  538. ----------
  539. API V1.15 (BFGMiner v2.5.2)
  540. Added API commands:
  541. 'poolpriority'
  542. ----------
  543. API V1.14 (BFGMiner v2.5.0)
  544. Modified API commands:
  545. 'stats' - more Icarus timing stats added
  546. 'notify' - include new device comms error counter
  547. The internal code for handling data was rewritten (~25% of the code)
  548. Completely backward compatible
  549. ----------
  550. API V1.13 (BFGMiner v2.4.4)
  551. Added API commands:
  552. 'check'
  553. Support was added to BFGMiner for API access groups with the --api-groups option
  554. It's 100% backward compatible with previous --api-access commands
  555. ----------
  556. API V1.12 (BFGMiner v2.4.3)
  557. Modified API commands:
  558. 'stats' - more pool stats added
  559. Support for the ModMiner FPGA was added
  560. ----------
  561. API V1.11 (BFGMiner v2.4.2)
  562. Modified API commands:
  563. 'save' no longer requires a filename (use default if not specified)
  564. 'save' incorrectly returned status E (error) on success before.
  565. It now correctly returns S (success)
  566. ----------
  567. API V1.10 (BFGMiner v2.4.1)
  568. Added API commands:
  569. 'stats'
  570. N.B. the 'stats' command can change at any time so any specific content
  571. present should not be relied upon.
  572. The data content is mainly used for debugging purposes or hidden options
  573. in BFGMiner and can change as development work requires.
  574. Modified API commands:
  575. 'pools' added "Last Share Time"
  576. ----------
  577. API V1.9 (BFGMiner v2.4.0)
  578. Added API commands:
  579. 'restart'
  580. Modified API commands:
  581. 'notify' corrected invalid JSON
  582. ----------
  583. API V1.8 (BFGMiner v2.3.5)
  584. Added API commands:
  585. 'devdetails'
  586. Support for the ZTEX FPGA was added.
  587. ----------
  588. API V1.8-pre (BFGMiner v2.3.4)
  589. Added API commands:
  590. 'devdetail'
  591. ----------
  592. API V1.7 (BFGMiner v2.3.4)
  593. Added API commands:
  594. 'removepool'
  595. Modified API commands:
  596. 'pools' added "User"
  597. From API version 1.7 onwards, reply strings in JSON and Text have the
  598. necessary escaping as required to avoid ambiguity.
  599. For JSON the 2 characters '"' and '\' are escaped with a '\' before them.
  600. For Text the 4 characters '|' ',' '=' and '\' are escaped the same way.
  601. ----------
  602. API V1.6 (cgminer v2.3.2)
  603. Added API commands:
  604. 'pga'
  605. 'pgaenable'
  606. 'pgadisable'
  607. 'pgacount'
  608. Modified API commands:
  609. 'devs' now includes Icarus and BitForce FPGA devices.
  610. 'notify' added "*" to the front of the name of all numeric error fields.
  611. 'config' correct "Log Interval" to use numeric (not text) type for JSON.
  612. Support for Icarus and BitForce FPGAs was added.
  613. ----------
  614. API V1.5 was not released
  615. ----------
  616. API V1.4 (Kano's interim release of cgminer v2.3.1)
  617. Added API commands:
  618. 'notify'
  619. Modified API commands:
  620. 'config' added "Device Code" and "OS"
  621. Added "When" to the STATUS reply section of all commands.
  622. ----------
  623. API V1.3 (cgminer v2.3.1-2)
  624. Added API commands:
  625. 'addpool'
  626. Modified API commands:
  627. 'devs'/'gpu' added "Total MH" for each device
  628. 'summary' added "Total MH"
  629. ----------
  630. API V1.2 (cgminer v2.3.0)
  631. Added API commands:
  632. 'enablepool'
  633. 'disablepool'
  634. 'privileged'
  635. Modified API commands:
  636. 'config' added "Log Interval"
  637. Starting with API V1.2, any attempt to access a command that requires
  638. privileged security, from an IP address that does not have privileged
  639. security, will return an "Access denied" Error Status.
  640. ----------
  641. API V1.1 (cgminer v2.2.4)
  642. There were no changes to the API commands in cgminer v2.2.4,
  643. however support was added to cgminer for IP address restrictions
  644. with the --api-allow option.
  645. ----------
  646. API V1.1 (cgminer v2.2.2)
  647. Prior to V1.1, devs/gpu incorrectly reported GPU0 Intensity for all GPUs.
  648. Modified API commands:
  649. 'devs'/'gpu' added "Last Share Pool" and "Last Share Time" for each device
  650. ----------
  651. API V1.0 (cgminer v2.2.0)
  652. Remove default CPU support.
  653. Added API commands:
  654. 'config'
  655. 'gpucount'
  656. 'cpucount'
  657. 'switchpool'
  658. 'gpuintensity'
  659. 'gpumem'
  660. 'gpuengine'
  661. 'gpufan'
  662. 'gpuvddc'
  663. 'save'
  664. ----------
  665. API V0.7 (cgminer v2.1.0)
  666. Initial release of the API in the main cgminer git
  667. Commands:
  668. 'version'
  669. 'devs'
  670. 'pools'
  671. 'summary'
  672. 'gpuenable'
  673. 'gpudisable'
  674. 'gpurestart'
  675. 'gpu'
  676. 'cpu'
  677. 'gpucount'
  678. 'cpucount'
  679. 'quit'
  680. ----------------------------------------
  681. miner.php
  682. =========
  683. miner.php is a PHP based interface to the BFGMiner RPC API
  684. (referred to simply as the API below).
  685. It can show rig details, summaries and input fields to allow you to change
  686. BFGMiner.
  687. You can also create custom summary pages with it
  688. It has two levels to the security:
  689. 1) BFGMiner can be configured to allow or disallow API access and access level
  690. security for miner.php
  691. 2) miner.php can be configured to allow or disallow privileged BFGMiner
  692. access, if BFGMiner is configured to allow privileged access for miner.php
  693. ---------
  694. To use miner.php requires a web server with PHP.
  695. Basics: On Xubuntu 11.04, to install Apache and PHP, the commands are:
  696. sudo apt-get install apache2
  697. sudo apt-get install php5
  698. sudo /etc/init.d/apache2 reload
  699. On Fedora 17:
  700. yum install httpd php
  701. systemctl restart httpd.service
  702. systemctl enable httpd.service --system
  703. On windows there are a few options.
  704. Try one of these (apparently the first one is easiest - thanks jborkl)
  705. http://www.easyphp.org/
  706. http://www.apachefriends.org/en/xampp.html
  707. http://www.wampserver.com/en/
  708. ---------
  709. The basic BFGMiner option to enable the API is:
  710. --api-listen
  711. or in your bfgminer.conf:
  712. "api-listen" : true,
  713. (without the ',' on the end if it is the last item.)
  714. If the web server is running on the BFGMiner computer, the above
  715. is the only change required to give miner.php basic access to
  716. the BFGMiner API.
  717. -
  718. If the web server runs on a different computer to BFGMiner,
  719. you will also need to tell BFGMiner to allow the web server
  720. to access BFGMiner's API and tell miner.php where BFGMiner is.
  721. Assuming a.b.c.d is the IP address of the web server, you
  722. would add the following to BFGMiner:
  723. --api-listen --api-allow a.b.c.d
  724. or in your bfgminer.conf:
  725. "api-listen" : true,
  726. "api-allow" : "a.b.c.d",
  727. to tell BFGMiner to give the web server read access to the API.
  728. You also need to tell miner.php where BFGMiner is.
  729. Assuming BFGMiner is at IP address e.f.g.h, then you would
  730. edit miner.php and change the line:
  731. $rigs = array('127.0.0.1:4028');
  732. to
  733. $rigs = array('e.f.g.h:4028');
  734. See --api-network or --api-allow for more access details
  735. and how to give write access.
  736. You can however, also tell miner.php to find your mining rigs automatically
  737. on the local subnet.
  738. Add the following to each BFGMiner:
  739. --api-mcast
  740. or in your bfgminer.conf:
  741. "api-mcast" : true,
  742. And in miner.php set $mcast = true;
  743. This will ignore the value of $rigs and overwrite it with the list of zero or
  744. more rigs found on the network in the timeout specified.
  745. A rig will not reply if the API settings would mean it would also ignore an
  746. API request from the web server running miner.php
  747. ---------
  748. Once you have a web server with PHP running:
  749. copy your miner.php to the main web folder
  750. On Xubuntu 11.04:
  751. /var/www/
  752. On Fedora 17:
  753. /var/www/html/
  754. On Windows:
  755. Please check your windows Web/PHP documentation.
  756. Assuming the IP address of the web server is a.b.c.d
  757. Then in your web browser go to:
  758. http://a.b.c.d/miner.php
  759. Done :)
  760. ---------
  761. The rest of this documentation deals with the more complex
  762. functions of miner.php, using myminer.php, creating custom
  763. summaries and displaying multiple BFGMiner rigs.
  764. ---------
  765. If you create a file called myminer.php in the same web folder
  766. where you put miner.php, miner.php will load it when it runs.
  767. This is useful, to put any changes you need to make to miner.php
  768. instead of changing miner.php.
  769. Thus if you update/get a new miner.php, you won't lose the changes
  770. you have made if you put all your changes in myminer.php
  771. (and haven't changed miner.php at all)
  772. A simple example myminer.php that defines 2 rigs
  773. (that I will keep referring to further below) is:
  774. <?php
  775. #
  776. $rigs = array('192.168.0.100:4028:A', '192.168.0.102:4028:B');
  777. #
  778. ?>
  779. Changes in myminer.php supersede what is in miner.php
  780. However, this is only valid for variables in miner.php before the
  781. 2 lines where myminer.php is included by miner.php:
  782. if (file_exists('myminer.php'))
  783. include_once('myminer.php');
  784. Every variable in miner.php above those 2 lines, can be changed by
  785. simply defining them in your myminer.php
  786. So although miner.php originally contains the line:
  787. $rigs = array('127.0.0.1:4028');
  788. if you created the example myminer.php given above, it would actually
  789. change the value of $rigs that is used when miner.php is running.
  790. i.e. you don't have to remove or comment out the $rigs line in miner.php
  791. It will be superseded by myminer.php
  792. ---------
  793. The example myminer.php above also shows how to define more that one rig
  794. to be shown my miner.php:
  795. Each rig string is 2 or 3 values separated by colons ':'
  796. They are simply an IP address or hostname, followed by the
  797. port number (usually 4028) and an optional Name string.
  798. miner.php displays rig buttons that will show the details of a single
  799. rig when you click on it - the button shows either the rig number,
  800. or the 'Name' string if you provide it.
  801. PHP arrays contain each string separated by a comma, but no comma after
  802. the last one.
  803. So an example for 3 rigs would be:
  804. $rigs = array('192.168.0.100:4028:A', '192.168.0.102:4028:B',
  805. '192.168.0.110:4028:C');
  806. Of course each of the rigs listed would also have to have the API
  807. running and be set to allow the web server to access the API - as
  808. covered earlier in this document.
  809. ---------
  810. So basically, any variable explained below can be put in myminer.php if you want
  811. to set it to something different to its default value and did not want to change
  812. miner.php itself every time you update it.
  813. Below is a list of the variables that can be changed and an explanation of each.
  814. ---------
  815. Default:
  816. $dfmt = 'H:i:s j-M-Y \U\T\CP';
  817. Define the date format used to print full length dates.
  818. If you get the string 'UTCP' on the end of your dates shown, that
  819. means you are using an older version of PHP and you can instead use:
  820. $dfmt = 'H:i:s j-M-Y \U\T\CO';
  821. The PHP documentation on the date format is here:
  822. http://us.php.net/manual/en/function.date.php
  823. ---------
  824. Default:
  825. $title = 'Mine';
  826. Web page title.
  827. If you know PHP you can of course use code to define it e.g.
  828. $title = 'My Rig at: '.date($dfmt);
  829. Which would set the web page title to something like:
  830. My Rig at: 10:34:00 22-Aug-2012 UTC+10:00
  831. ---------
  832. Default:
  833. $readonly = false;
  834. Set $readonly to true to force miner.php to be readonly.
  835. This means it won't allow you to change BFGMiner even if the RPC API
  836. options allow it to.
  837. If you set $readonly to false then it will check BFGMiner 'privileged'
  838. and will show input fields and buttons on the single rig page,
  839. allowing you to change devices, pools and even quit or restart
  840. BFGMiner.
  841. However, if the 'privileged' test fails, the code will set $readonly to
  842. true.
  843. ---------
  844. Default:
  845. $userlist = null;
  846. Define password checking and default access null means there is no password
  847. checking.
  848. $userlist is an array of 3 arrays, e.g.
  849. $userlist = array('sys' => array('boss' => 'bpass'),
  850. 'usr' => array('user' => 'upass', 'pleb' => 'ppass'),
  851. 'def' => array('Pools'));
  852. 'sys' is an array of system users and passwords (full access).
  853. 'usr' is an array of user level users and passwords (readonly access).
  854. 'def' is an array of custompages that anyone not logged in can view.
  855. Any of the 3 can be null, meaning there are none of that item.
  856. All validated 'usr' users are given $readonly = true; access.
  857. All validated 'sys' users are given the $readonly access you defined.
  858. If 'def' has one or more values, and allowcustompages is true, then anyone
  859. without a password can see the list of custompage buttons given in 'def' and
  860. will see the first one when they go to the web page, with a login button at the
  861. top right.
  862. From the login page, if you login with no username or password, it will show
  863. the first 'def' custompage (if there are any).
  864. If you are logged in, it will show a logout button at the top right.
  865. ---------
  866. Default:
  867. $notify = true;
  868. Set $notify to false to NOT attempt to display the notify command table of data
  869. Set $notify to true to attempt to display the notify command on the single rig
  870. page.
  871. If your older version of BFGMiner returns an 'Invalid command' because it
  872. doesn't have notify - it just shows the error status table.
  873. ---------
  874. Default:
  875. $checklastshare = true;
  876. Set $checklastshare to true to do the following checks:
  877. If a device's last share is 12x expected ago then display as an error.
  878. If a device's last share is 8x expected ago then display as a warning.
  879. If either of the above is true, also display the whole line highlighted
  880. This assumes shares are 1 difficulty shares.
  881. Set $checklastshare to false to not do the above checks.
  882. 'expected' is calculated from the device Mh/s value.
  883. So for example, a device that hashes at 380Mh/s should (on average) find a
  884. share every 11.3s.
  885. If the last share was found more than 11.3 x 12 seconds (135.6s) ago, it is
  886. considered an error and highlighted.
  887. If the last share was found more than 11.3 x 8 seconds (90.4s) ago, it is
  888. considered a warning and highlighted.
  889. The default highlighting is very subtle, so change it if you want it to be more
  890. obvious.
  891. ---------
  892. Default:
  893. $poolinputs = false;
  894. Set $poolinputs to true to show the input fields for adding a pool and changing
  895. the pool priorities on a single rig page.
  896. However, if $readonly is true, it will not display them.
  897. ---------
  898. Default:
  899. $rigs = array('127.0.0.1:4028');
  900. Set $rigs to an array of your BFGMiner rigs that are running format: 'IP:Port'
  901. or 'Host:Port' or 'Host:Port:Name'.
  902. If you only have one rig, it will just show the detail of that rig.
  903. If you have more than one rig it will show a summary of all the rigs with
  904. buttons to show the details of each rig - the button contents will be 'Name'
  905. rather than rig number, if you specify 'Name'.
  906. e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi');
  907. ---------
  908. Default:
  909. $mcast = false;
  910. Set $mcast to true to look for your rigs and ignore $rigs.
  911. ---------
  912. Default:
  913. $mcastexpect = 0;
  914. The minimum number of rigs expected to be found when $mcast is true.
  915. If fewer are found, an error will be included at the top of the page.
  916. ---------
  917. Default:
  918. $mcastaddr = '224.0.0.75';
  919. API Multicast address all miners are listening on.
  920. ---------
  921. Default:
  922. $mcastport = 4028;
  923. API Multicast UDP port all miners are listening on.
  924. ---------
  925. Default:
  926. $mcastcode = 'FTW';
  927. The code all miners expect in the Multicast message sent.
  928. The message sent is "cgm-code-listport".
  929. Don't use the '-' character if you change it.
  930. ---------
  931. Default:
  932. $mcastlistport = 4027;
  933. UDP port number that is added to the broadcast message sent
  934. that specifies to the miners the port to reply on.
  935. ---------
  936. Default:
  937. $mcasttimeout = 1.5;
  938. Set $mcasttimeout to the number of seconds (floating point)
  939. to wait for replies to the Multicast message.
  940. N.B. the accuracy of the timing used to wait for the replies is
  941. ~0.1s so there's no point making it more than one decimal place.
  942. ---------
  943. Default:
  944. $mcastretries = 0;
  945. Set $mcastretries to the number of times to retry the multicast.
  946. If $mcastexpect is 0, this is simply the number of extra times
  947. that it will send the multicast request.
  948. N.B. BFGMiner doesn't listen for multicast requests for 1000ms after
  949. each one it hears.
  950. If $mcastexpect is > 0, it will stop looking for replies once it
  951. has found at least $mcastexpect rigs, but it only checks this rig
  952. limit each time it reaches the $mcasttimeout limit, thus it can find
  953. more than $mcastexpect rigs if more exist.
  954. It will send the multicast message up to $mcastretries extra times or
  955. until it has found at least $mcastexpect rigs.
  956. When using $mcastretries, it is however possible for it to sometimes
  957. ignore some rigs on the network if $mcastexpect is less than the
  958. number of rigs on the network and some rigs are too slow to reply.
  959. ---------
  960. Default:
  961. $allowgen = false;
  962. Set $allowgen to true to allow customsummarypages to use 'gen',
  963. false means ignore any 'gen' options.
  964. This is disabled by default due to the possible security risk
  965. of using it, please see the end of this document for an explanation.
  966. ---------
  967. Default:
  968. $rigipsecurity = true;
  969. Set $rigipsecurity to false to show the IP/Port of the rig in the socket error
  970. messages and also show the full socket message.
  971. ---------
  972. Default:
  973. $rigtotals = true;
  974. $forcerigtotals = false;
  975. Set $rigtotals to true to display totals on the single rig page, 'false' means
  976. no totals (and ignores $forcerigtotals).
  977. If $rigtotals is true, all data is also right aligned.
  978. With false, it's as before, left aligned.
  979. This option is just here to allow people to set it to false if they prefer the
  980. old non-total display when viewing a single rig.
  981. Also, if there is only one line shown in any section, then no total will be
  982. shown (to save screen space).
  983. You can force it to always show rig totals on the single rig page, even if
  984. there is only one line, by setting $forcerigtotals = true;
  985. ---------
  986. Default:
  987. $socksndtimeoutsec = 10;
  988. $sockrcvtimeoutsec = 40;
  989. The numbers are integer seconds.
  990. The defaults should be OK for most cases.
  991. However, the longer SND is, the longer you have to wait while PHP hangs if the
  992. target BFGMiner isn't running or listening.
  993. RCV should only ever be relevant if BFGMiner has hung but the API thread is
  994. still running, RCV would normally be >= SND.
  995. Feel free to increase SND if your network is very slow or decrease RCV if that
  996. happens often to you.
  997. Also, on some windows PHP, apparently the $usec is ignored (so usec can't be
  998. specified).
  999. ---------
  1000. Default:
  1001. $hidefields = array();
  1002. List of fields NOT to be displayed.
  1003. You can use this to hide data you don't want to see or don't want shown on a
  1004. public web page.
  1005. The list of sections are:
  1006. SUMMARY, POOL, PGA, GPU, NOTIFY, CONFIG, DEVDETAILS, DEVS
  1007. See the web page for the list of field names (the table headers).
  1008. It is an array of 'SECTION.Field Name' => 1
  1009. This example would hide the slightly more sensitive pool information:
  1010. Pool URL and pool username:
  1011. $hidefields = array('POOL.URL' => 1, 'POOL.User' => 1);
  1012. If you just want to hide the pool username:
  1013. $hidefields = array('POOL.User' => 1);
  1014. ---------
  1015. Default:
  1016. $ignorerefresh = false;
  1017. $changerefresh = true;
  1018. $autorefresh = 0;
  1019. Auto-refresh of the page (in seconds) - integers only.
  1020. $ignorerefresh = true/false always ignore refresh parameters.
  1021. $changerefresh = true/false show buttons to change the value.
  1022. $autorefresh = default value, 0 means don't auto-refresh.
  1023. ---------
  1024. Default:
  1025. $placebuttons = 'top';
  1026. Where to place the Refresh, Summary, Custom Pages, Quit, etc. buttons.
  1027. Valid values are: 'top' 'bot' 'both'
  1028. Anything else means don't show them. (case sensitive)
  1029. ---------
  1030. Default:
  1031. $miner_font_family = 'verdana,arial,sans';
  1032. $miner_font_size = '13pt';
  1033. Change these to set the font and font size used on the web page.
  1034. ---------
  1035. Default:
  1036. $colouroverride = array();
  1037. Use this to change the web page colour scheme.
  1038. See $colourtable in miner.php for the list of possible names to change.
  1039. Simply put in $colouroverride, just the colours you wish to change.
  1040. e.g. to change the colour of the header font and background
  1041. you could do the following:
  1042. $colouroverride = array(
  1043. 'td.h color' => 'green',
  1044. 'td.h background' => 'blue'
  1045. );
  1046. ---------
  1047. Default:
  1048. $allowcustompages = true;
  1049. Should we allow custom pages?
  1050. (or just completely ignore them and don't display the buttons.)
  1051. ---------
  1052. OK this part is more complex: Custom Summary Pages.
  1053. A custom summary page in an array of 'section' => array('FieldA','FieldB'...)
  1054. The section defines what data you want in the summary table and the Fields
  1055. define what data you want shown from that section.
  1056. Standard sections are:
  1057. SUMMARY, POOL, PGA, GPU, NOTIFY, CONFIG, DEVDETAILS, DEVS, STATS, COIN
  1058. Fields are the names as shown on the headers on the normal pages.
  1059. Fields can be 'name=new name' to display 'name' with a different heading
  1060. 'new name'.
  1061. There are also now joined sections:
  1062. SUMMARY+POOL, SUMMARY+DEVS, SUMMARY+CONFIG, DEVS+NOTIFY, DEVS+DEVDETAILS
  1063. SUMMARY+COIN
  1064. These sections are an SQL join of the two sections and the fields in them
  1065. are named section.field where 'section.' is the section the field comes from
  1066. See the example further down.
  1067. Also note:
  1068. - empty tables are not shown.
  1069. - empty columns (e.g. an unknown field) are not shown.
  1070. - missing field data shows as blank.
  1071. - the field name '*' matches all fields except in joined sections
  1072. (useful for STATS and COIN).
  1073. There are 2 hard coded sections:
  1074. DATE - displays a date table like at the start of 'Summary'.
  1075. RIGS - displays a rig table like at the start of 'Summary'.
  1076. Each custom summary requires a second array, that can be empty, listing fields
  1077. to be totalled for each section.
  1078. If there is no matching total data, no total will show.
  1079. ---------
  1080. Looking at the Mobile example:
  1081. $mobilepage = array(
  1082. 'DATE' => null,
  1083. 'RIGS' => null,
  1084. 'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks',
  1085. Accepted', 'Rejected=Rej', 'Utility'),
  1086. 'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.ProcID=Proc',
  1087. 'DEVS.Status=Status',
  1088. 'DEVS.Temperature=Temp', 'DEVS.MHS av=MHS av',
  1089. 'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
  1090. 'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
  1091. 'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected=Rej',
  1092. 'Last Share Time'));
  1093. $mobilesum = array(
  1094. 'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted', 'Rejected',
  1095. 'Utility'),
  1096. 'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected',
  1097. 'DEVS.Utility'),
  1098. 'POOL' => array('Accepted', 'Rejected'));
  1099. $customsummarypages = array('Mobile' => array($mobilepage, $mobilesum));
  1100. This will show 5 tables (according to $mobilepage).
  1101. Each table will have the chosen details for all the rigs specified in $rigs
  1102. DATE
  1103. A single box with the web server's current date and time.
  1104. RIGS
  1105. A table of the rigs: description, time, versions etc.
  1106. SUMMARY
  1107. This will use the API 'summary' command and show the selected fields:
  1108. Elapsed, MHS av, Found Blocks, Accepted, Rejected and Utility
  1109. However, 'Rejected=Rej' means that the header displayed for the 'Rejected'
  1110. field will be 'Rej', instead of 'Rejected' (to save space).
  1111. Same for 'Found Blocks=Blks' - to save space.
  1112. DEVS+NOTIFY
  1113. This will list each of the devices on each rig and display the list of
  1114. fields as shown.
  1115. It will also include the 'Last Not Well' field from the 'notify' command
  1116. so you know when the device was last not well.
  1117. You will notice that you need to rename each field e.g. 'DEVS.Name=Name'
  1118. since each field name in the join between DEVS and NOTIFY is actually
  1119. section.fieldname, not just fieldname.
  1120. The join code automatically adds 2 fields to each GPU device: 'Name', 'ID',
  1121. and 'ProcID'. They don't exist in the API 'devs' output but we can correctly
  1122. calculate them from the GPU device data. These two fields are used to join
  1123. DEVS to NOTIFY: i.e. find the NOTIFY record that has the same Name/ID/ProcID
  1124. as the DEVS record and join them.
  1125. POOL
  1126. This will use the API 'pools' command and show the selected fields:
  1127. POOL, Status, Accepted, Rejected, Last Share Time
  1128. Again, I renamed the 'Rejected' field using 'Rejected=Rej', to save space.
  1129. $mobilesum lists the sections and fields that should have a total.
  1130. You can't define them for 'DATE' or 'RIGS' since they are hard coded tables.
  1131. The example given:
  1132. SUMMARY
  1133. Show a total at the bottom of the columns for:
  1134. MHS av, Found Blocks, Accepted, Rejected, Utility
  1135. Firstly note that you use the original name i.e. for 'Rejected=Rej'
  1136. you use 'Rejected', not 'Rej' and not 'Rejected=Rej'.
  1137. Secondly note that it simply adds up the fields.
  1138. If you ask for a total of a string field you will get the numerical
  1139. sum of the string data.
  1140. DEVS+NOTIFY
  1141. Simply note in this join example that you must use the original field
  1142. names which are section.fieldname, not just fieldname.
  1143. POOL
  1144. Show a total at the bottom of the columns for:
  1145. Accepted and Rejected
  1146. Again remember to use the original field name 'Rejected'.
  1147. ---------
  1148. With BFGMiner 2.10.1 and later, miner.php includes an extension to the custom
  1149. pages that allows you to apply SQL style commands to the data: where, group,
  1150. and having
  1151. BFGMiner 3.4.0 also includes another option 'gen'.
  1152. As an example, miner.php includes a more complex custom page called 'Pools'
  1153. which includes the extension:
  1154. $poolsext = array(
  1155. 'POOL+STATS' => array(
  1156. 'where' => null,
  1157. 'group' => array('POOL.URL', 'POOL.Has Stratum',
  1158. 'POOL.Stratum Active'),
  1159. 'calc' => array('STATS.Bytes Sent' => 'sum',
  1160. 'STATS.Bytes Recv' => 'sum'),
  1161. 'gen' => array('AvShr', 'POOL.Difficulty Accepted/max(POOL.Accepted,1)),
  1162. 'having' => array(array('STATS.Bytes Recv', '>', 0)))
  1163. );
  1164. This allows you to group records together from one or more rigs.
  1165. In the example, you'll get each Pool (with the same URL+Stratum info) listed
  1166. once for all rigs and a sum of each of the fields listed in 'calc'.
  1167. 'where' and 'having' are an array of fields and restrictions to apply.
  1168. In the above example, it will only display the rows where it contains the
  1169. 'STATS.Bytes Recv' field with a value greater than zero.
  1170. If the row doesn't have the field, it will always be included.
  1171. All restrictions must be true in order for the row to be included.
  1172. Any restiction that is invalid or unknown is true.
  1173. An empty array, or null, means there are no restrictions.
  1174. A restriction is formatted as: array('Field', 'restriction', 'value')
  1175. Field is the simple field name as normally displayed, or SECTION.Field if it is
  1176. a joined section (as in this case 'POOL+STATS').
  1177. The list of restrictions are:
  1178. 'set' - true if the row contains the 'Field' ('value' is not required or used)
  1179. '=', '<', '<=', '>', '>' - a numerical comparison.
  1180. 'eq', 'lt', 'le', 'gt', 'ge' - a case insensitive string comparison.
  1181. You can have multiple restrictions on a 'Field' - but all must be true to
  1182. include the row containing the 'Field'.
  1183. e.g. a number range between 0 and 10 would be:
  1184. array('STATS.Bytes Recv', '>', 0), array('STATS.Bytes Recv', '<', 10)
  1185. The difference between 'where' and 'having' is that 'where' is applied to the
  1186. data before grouping it and 'having' is applied to the data after grouping it
  1187. - otherwise they work the same.
  1188. 'group' lists the fields to group over and 'calc' lists the function to apply
  1189. to other fields that are not part of 'group'.
  1190. You can only see fields listed in 'group' and 'calc'.
  1191. A 'calc' is formatted as: 'Field' => 'function'
  1192. The current list of operations available for 'calc' are:
  1193. 'sum', 'avg', 'min', 'max', 'lo', 'hi', 'count', 'any'
  1194. The first 4 are as expected - the numerical sum, average, minimum or maximum.
  1195. 'lo' is the first string of the list, sorted ignoring case.
  1196. 'hi' is the last string of the list, sorted ignoring case.
  1197. 'count' is the number of rows in the section specified in the calc e.g.
  1198. ('DEVS.Name' => 'count') would be the number of DEVS selected in the 'where'
  1199. of course any valid 'DEVS.Xyz' would give the same 'count' value.
  1200. 'any' is effectively random: the field value in the 1st row of the grouped data.
  1201. An unrecognised 'function' uses 'any'.
  1202. A 'gen' allows you to generate new fields from any php valid function of any
  1203. of the other fields.
  1204. e.g. 'gen' => array('AvShr', 'POOL.Difficulty Accepted/max(POOL.Accepted,1)),
  1205. will generate a new field called GEN.AvShr that is the function shown, which
  1206. in this case is the average difficulty of each share submitted.
  1207. THERE IS A SECURITY RISK WITH HOW GEN WORKS!
  1208. It simply replaces all the variables with their values and then requests PHP
  1209. to execute the formula - thus if a field value returned from a BFGMiner API
  1210. request contained PHP code, it could be executed by your web server.
  1211. Of course BFGMiner doesn't do this, but if you do not control the BFGMiner that
  1212. returns the data in the API calls, someone could modify BFGMiner to return a
  1213. PHP string in a field you use in 'gen'.
  1214. Thus use 'gen' at your own risk.
  1215. If someone feels the urge to write a mathematical interpreter in PHP to get
  1216. around this risk, feel free to write one and submit it to the API author for
  1217. consideration.

comments powered by Disqus