API-README 54 KB

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