Advertisement
Guest User

Untitled

a guest
May 22nd, 2020
170
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>miner-stats</title>
  6. <link rel="stylesheet" href="../css/cascade.css">
  7. <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
  8. </head>
  9. <body>
  10. <div id="menubar" style="background-color: #0a2b40;">
  11. <div class="hostinfo" style="float: left; with: 500px;">
  12. <img src="../images/antminer_logo.png" width="92" height="50" alt="" title="" border="0">
  13. </div>
  14. <div class="clear"></div>
  15. </div>
  16. <div id="maincontainer">
  17. <div id="tabmenu">
  18. <div class="tabmenu1">
  19. <ul class="tabmenu l1">
  20. <li class="tabmenu-item-status"><a href="/index.html">System</a></li>
  21. <li class="tabmenu-item-system"><a href="/cgi-bin/minerConfiguration.cgi">Miner Configuration</a></li>
  22. <li class="tabmenu-item-network active"><a href="/cgi-bin/minerStatus.cgi">Miner Status</a></li>
  23. <li class="tabmenu-item-system"><a href="/network.html">Network</a></li>
  24. </ul>
  25. <br style="clear: both">
  26. </div>
  27. </div>
  28. <div id="maincontent">
  29. <h2 style="padding-bottom:10px;">
  30. <a id="content" name="content">Miner Status</a>
  31. </h2>
  32.  
  33. <div class="cbi-map" id="cbi-bmminerstatus">
  34. <!-- tblsection -->
  35. <fieldset class="cbi-section" id="cbi-table-table">
  36. <legend>Summary</legend>
  37. <div class="cbi-section-descr"></div>
  38. <div class="cbi-section-node">
  39. <table class="cbi-section-table J-summary-table">
  40. <tbody>
  41. <tr class="cbi-section-table-titles">
  42. <th class="cbi-section-table-cell">Elapsed</th>
  43. <th class="cbi-section-table-cell">GH/S(RT)</th>
  44. <th class="cbi-section-table-cell">GH/S(avg)</th>
  45. <th class="cbi-section-table-cell">FoundBlocks</th>
  46. <th class="cbi-section-table-cell">LocalWork</th>
  47. <th class="cbi-section-table-cell">Utility</th>
  48.  
  49. <th class="cbi-section-table-cell">WU</th>
  50. <th class="cbi-section-table-cell">BestShare</th>
  51. </tr>
  52. <tr class="cbi-section-table-descr">
  53. <th class="cbi-section-table-cell"></th>
  54. <th class="cbi-section-table-cell"></th>
  55. <th class="cbi-section-table-cell"></th>
  56. <th class="cbi-section-table-cell"></th>
  57. <th class="cbi-section-table-cell"></th>
  58. <th class="cbi-section-table-cell"></th>
  59. <th class="cbi-section-table-cell"></th>
  60. <th class="cbi-section-table-cell"></th>
  61. </tr>
  62. </tbody>
  63. </table>
  64. </div>
  65. </fieldset>
  66. <!-- /tblsection -->
  67. <!-- tblsection -->
  68. <fieldset class="cbi-section" id="cbi-table-table">
  69. <legend>Pools</legend>
  70. <div class="cbi-section-descr"></div>
  71. <div class="cbi-section-node">
  72. <table id="ant_pools" class="cbi-section-table J-pools-table">
  73. <thead>
  74. <tr class="cbi-section-table-titles">
  75. <th class="cbi-section-table-cell">Pool</th>
  76. <th class="cbi-section-table-cell">URL</th>
  77. <th class="cbi-section-table-cell">User</th>
  78. <th class="cbi-section-table-cell">Status</th>
  79. <th class="cbi-section-table-cell">Diff</th>
  80. <th class="cbi-section-table-cell">GetWorks</th>
  81. <th class="cbi-section-table-cell">Priority</th>
  82. <th class="cbi-section-table-cell">Accepted</th>
  83. <th class="cbi-section-table-cell">Diff1#</th>
  84. <th class="cbi-section-table-cell">DiffA#</th>
  85. <th class="cbi-section-table-cell">DiffR#</th>
  86. <th class="cbi-section-table-cell">DiffS#</th>
  87. <th class="cbi-section-table-cell">Rejected</th>
  88. <th class="cbi-section-table-cell">Discarded</th>
  89. <th class="cbi-section-table-cell">Stale</th>
  90. <th class="cbi-section-table-cell">LSDiff</th>
  91. <th class="cbi-section-table-cell">LSTime</th>
  92. </tr>
  93. <tr class="cbi-section-table-descr">
  94. <th class="cbi-section-table-cell"></th>
  95. <th class="cbi-section-table-cell"></th>
  96. <th class="cbi-section-table-cell"></th>
  97. <th class="cbi-section-table-cell"></th>
  98. <th class="cbi-section-table-cell"></th>
  99. <th class="cbi-section-table-cell"></th>
  100. <th class="cbi-section-table-cell"></th>
  101. <th class="cbi-section-table-cell"></th>
  102. <th class="cbi-section-table-cell"></th>
  103. <th class="cbi-section-table-cell"></th>
  104. <th class="cbi-section-table-cell"></th>
  105. <th class="cbi-section-table-cell"></th>
  106. <th class="cbi-section-table-cell"></th>
  107. <th class="cbi-section-table-cell"></th>
  108. <th class="cbi-section-table-cell"></th>
  109. <th class="cbi-section-table-cell"></th>
  110. <th class="cbi-section-table-cell"></th>
  111. </tr>
  112. </thead>
  113. <tbody></tbody>
  114. <tfoot>
  115. </tfoot>
  116. </table>
  117.  
  118. </div>
  119. </fieldset>
  120. <!-- /tblsection -->
  121. <!-- tblsection -->
  122. <fieldset class="cbi-section" id="cbi-table-table">
  123. <legend>AntMiner</legend>
  124. <div class="cbi-section-descr"></div>
  125. <div class="cbi-section-node">
  126. <table id="ant_devs" class="cbi-section-table">
  127. <thead>
  128. <tr class="cbi-section-table-titles">
  129. <th class="cbi-section-table-cell">Chain#</th>
  130. <th class="cbi-section-table-cell">ASIC#</th>
  131. <th class="cbi-section-table-cell">Frequency</th>
  132. <th class="cbi-section-table-cell">GH/S(RT)</th>
  133. <th class="cbi-section-table-cell">HW</th>
  134. <th class="cbi-section-table-cell">Temp(PCB)</th>
  135. <th class="cbi-section-table-cell">Temp(Chip)</th>
  136. <th class="cbi-section-table-cell">ASIC status</th>
  137. </tr>
  138. <tr class="cbi-section-table-descr">
  139. <th class="cbi-section-table-cell"></th>
  140. <th class="cbi-section-table-cell"></th>
  141. <th class="cbi-section-table-cell"></th>
  142. <th class="cbi-section-table-cell"></th>
  143. <th class="cbi-section-table-cell"></th>
  144. <th class="cbi-section-table-cell"></th>
  145. <th class="cbi-section-table-cell"></th>
  146. </tr>
  147. </thead>
  148. <tbody>
  149. </tbody>
  150. </table>
  151. </div>
  152. <div class="cbi-section-node" style="margin-top:8px;">
  153. <table id="ant_fans" class="cbi-section-table">
  154. <tbody>
  155. </tbody>
  156. </table>
  157. </div>
  158. </fieldset>
  159. <!-- /tblsection -->
  160. </div>
  161. </div>
  162.  
  163. <script>
  164. $(function(){
  165.  
  166. getAjaxData("/cgi-bin/miner_summary.cgi",setSummary);//处理summary table
  167. getAjaxData("/cgi-bin/miner_pools.cgi",setPools);//处理pools table
  168. getAjaxData("/cgi-bin/miner_stats.cgi",setAntMiner);//处理antminer table
  169.  
  170. //获取数据
  171. function getAjaxData(url,backFun){
  172. $.ajax({
  173. type: "GET",
  174. url: url,
  175. dataType: "json",
  176. async: false,
  177. success:function(data){
  178. backFun(data);
  179. },
  180. error: function(){
  181. //alert("error");
  182. }
  183. });
  184. };
  185. /*
  186. **处理summary table 数据
  187. **.J-summary-table 要填充表格自定义样式仅供js使用
  188. **summaryData.SUMMARY 数据项
  189. **summaryData.id trè¡Œid eg:cbi-table-1
  190. */
  191. function setSummary(summaryData){
  192. var rtnStr = '';
  193. if(summaryData.SUMMARY.length > 0 ){
  194. $.each(summaryData.SUMMARY,function(i,v){
  195. var elapsed = v.Elapsed ==0 ? '' : formatDateTime(v.Elapsed);
  196. //拼接tr 数据行
  197. rtnStr += '<tr class="cbi-section-table-row cbi-rowstyle-'+summaryData.id+'" id="cbi-table-'+summaryData.id+'">\
  198. <td class="cbi-value-field">\
  199. <div id="ant_elapsed">'+elapsed+'</div>\
  200. <div id="cbip-table-'+summaryData.id+'-elapsed"></div>\
  201. </td>\
  202. <td class="cbi-value-field">\
  203. <div id="ant_ghs5s">'+v['GHS 5s']+'</div>\
  204. <div id="cbip-table-'+summaryData.id+'-ghs5s"></div>\
  205. </td>\
  206. <td class="cbi-value-field">\
  207. <div id="ant_ghsav">'+v['GHS av']+'</div>\
  208. <div id="cbip-table-'+summaryData.id+'-ghsav"></div>\
  209. </td>\
  210. <td class="cbi-value-field">\
  211. <div id="ant_foundblocks">'+v['Found Blocks']+'</div>\
  212. <div id="cbip-table-'+summaryData.id+'-foundblocks"></div>\
  213. </td>\
  214. <td class="cbi-value-field">\
  215. <div id="ant_localwork">'+v['Local Work']+'</div>\
  216. <div id="cbip-table-'+summaryData.id+'-localwork"></div>\
  217. </td>\
  218. <td class="cbi-value-field">\
  219. <div id="ant_utility">'+v['Utility']+'</div>\
  220. <div id="cbip-table-'+summaryData.id+'-utility"></div>\
  221. </td>\
  222. <td class="cbi-value-field">\
  223. <div id="ant_wu">'+v['Work Utility']+'</div>\
  224. <div id="cbip-table-'+summaryData.id+'-wu"></div>\
  225. </td>\
  226. <td class="cbi-value-field">\
  227. <div id="ant_bestshare">'+v['Best Share']+'</div>\
  228. <div id="cbip-table-'+summaryData.id+'-bestshare"></div>\
  229. </td>\
  230. <td class="cbi-value-field" style="display:none">\
  231. <div id="ant_hardwarerrors">'+v['Hardware Errors']+'</div>\
  232. <div id="cbip-table-'+summaryData.id+'-hardwarerrors"></div>\
  233. </td>\
  234. </tr>';
  235. });
  236. $(".J-summary-table").append(rtnStr);
  237. }else{
  238. return;
  239. }
  240. };
  241. /*
  242. **处理pools table 数据
  243. **.J-pools-table 要填充表格自定义样式仅供js使用
  244. **poolsData.SUMMARY 数据项
  245. */
  246. function setPools(poolsData){
  247. var rtnStr = [];
  248. var totalObj = {};
  249. var totalGetWorks = 0;
  250. var totalPriority = 0;
  251. var totalAccepted = 0;
  252. var totalDiff1 = 0;
  253. var totalDiffA = 0;
  254. var totalDiffR = 0;
  255. var totalDiffS = 0;
  256. var totalRejected = 0;
  257. var totalDiscarded = 0;
  258. var totalStale = 0;
  259. var hwUrl = $("#ant_hardwarerrors").text();
  260. var hwDiffA = 0;
  261.  
  262. if(poolsData.POOLS.length > 0 ){
  263. $.each(poolsData.POOLS, function(i,v){
  264. //拼接数据行
  265. rtnStr += '<tr class="cbi-section-table-row cbi-rowstyle-'+poolsData.id+'" id="cbi-table-'+poolsData.id+'">\
  266. <td class="cbi-value-field">\
  267. <div id="cbi-table-'+poolsData.id+'-pool">'+v['POOL']+'</div>\
  268. <div id="cbip-table-'+poolsData.id+'-pool"></div>\
  269. </td>\
  270. <td class="cbi-value-field">\
  271. <div id="cbi-table-'+poolsData.id+'-url">'+v['URL']+'</div>\
  272. <div id="cbip-table-'+poolsData.id+'-url"></div>\
  273. </td>\
  274. <td class="cbi-value-field">\
  275. <div id="cbi-table-'+poolsData.id+'-user">'+v['User']+'</div>\
  276. <div id="cbip-table-'+poolsData.id+'-user"></div>\
  277. </td>\
  278. <td class="cbi-value-field">\
  279. <div id="cbi-table-'+poolsData.id+'-status">'+v['Status']+'</div>\
  280. <div id="cbip-table-'+poolsData.id+'-status"></div>\
  281. </td>\
  282. <td class="cbi-value-field">\
  283. <div id="cbi-table-'+poolsData.id+'-diff">'+v['Diff']+'</div>\
  284. <div id="cbip-table-'+poolsData.id+'-diff"></div>\
  285. </td>\
  286. <td class="cbi-value-field">\
  287. <div id="cbi-table-'+poolsData.id+'-getworks">'+v['Getworks']+'</div>\
  288. <div id="cbip-table-'+poolsData.id+'-getworks"></div>\
  289. </td>\
  290. <td class="cbi-value-field">\
  291. <div id="cbi-table-'+poolsData.id+'-priority">'+v['Priority']+'</div>\
  292. <div id="cbip-table-'+poolsData.id+'-priority"></div>\
  293. </td>\
  294. <td class="cbi-value-field">\
  295. <div id="cbi-table-'+poolsData.id+'-accepted">'+v['Accepted']+'</div>\
  296. <div id="cbip-table-'+poolsData.id+'-accepted"></div>\
  297. </td>\
  298. <td class="cbi-value-field">\
  299. <div id="cbi-table-'+poolsData.id+'-diff1shares">'+v['Diff1 Shares']+'</div>\
  300. <div id="cbip-table-'+poolsData.id+'-diff1shares"></div>\
  301. </td>\
  302. <td class="cbi-value-field">\
  303. <div id="cbi-table-'+poolsData.id+'-diffaccepted">'+v['Difficulty Accepted']+'</div>\
  304. <div id="cbip-table-'+poolsData.id+'-diffaccepted"></div>\
  305. </td>\
  306. <td class="cbi-value-field">\
  307. <div id="cbi-table-'+poolsData.id+'-diffrejected">'+v['Difficulty Rejected']+'</div>\
  308. <div id="cbip-table-'+poolsData.id+'-diffrejected"></div>\
  309. </td>\
  310. <td class="cbi-value-field">\
  311. <div id="cbi-table-'+poolsData.id+'-diffstale">'+v['Difficulty Stale']+'</div>\
  312. <div id="cbip-table-'+poolsData.id+'-diffstale"></div>\
  313. </td>\
  314. <td class="cbi-value-field">\
  315. <div id="cbi-table-'+poolsData.id+'-rejected">'+v['Rejected']+'</div>\
  316. <div id="cbip-table-'+poolsData.id+'-rejected"></div>\
  317. </td>\
  318. <td class="cbi-value-field">\
  319. <div id="cbi-table-'+poolsData.id+'-discarded">'+v['Discarded']+'</div>\
  320. <div id="cbip-table-'+poolsData.id+'-discarded"></div>\
  321. </td>\
  322. <td class="cbi-value-field">\
  323. <div id="cbi-table-'+poolsData.id+'-stale">'+v['Stale']+'</div>\
  324. <div id="cbip-table-'+poolsData.id+'-stale"></div>\
  325. </td>\
  326. <td class="cbi-value-field">\
  327. <div id="cbi-table-'+poolsData.id+'-lastsharedifficulty">'+v['Last Share Difficulty']+'</div>\
  328. <div id="cbip-table-'+poolsData.id+'-lastsharedifficulty"></div>\
  329. </td>\
  330. <td class="cbi-value-field">\
  331. <div id="cbi-table-'+poolsData.id+'-lastsharetime">'+v['Last Share Time']+'</div>\
  332. <div id="cbip-table-'+poolsData.id+'-lastsharetime"></div>\
  333. </td>\
  334. </tr>';
  335. //计算total 总数据
  336. totalGetWorks += v['Getworks'];
  337. totalPriority += v['Priority'];
  338. totalAccepted += v['Accepted'];
  339. totalDiff1 += v['Diff1 Shares'];
  340. totalDiffA += v['Difficulty Accepted'];
  341. totalDiffR += v['Difficulty Rejected'];
  342. totalDiffS += v['Difficulty Stale'];
  343. totalRejected += v['Rejected'];
  344. totalDiscarded += v['Discarded'];
  345. totalStale += v['Stale'];
  346. });
  347. //计算HW数据
  348. hwDiffA = (hwUrl/totalDiffA*100).toFixed(4) + "%";
  349. //填充数据
  350. var tfootStr = '<tr class="cbi-section-table-row cbi-rowstyle-1" id="cbi-table-1">\
  351. <td class="cbi-value-field">\
  352. <div id="cbi-table-1-pool">total</div>\
  353. <div id="cbip-table-1-pool"></div>\
  354. </td>\
  355. <td class="cbi-value-field">\
  356. <div id="cbi-table-1-url"></div>\
  357. <div id="cbip-table-1-url"></div>\
  358. </td>\
  359. <td class="cbi-value-field">\
  360. <div id="cbi-table-1-user"></div>\
  361. <div id="cbip-table-1-user"></div>\
  362. </td>\
  363. <td class="cbi-value-field">\
  364. <div id="cbi-table-1-status"></div>\
  365. <div id="cbip-table-1-status"></div>\
  366. </td>\
  367. <td class="cbi-value-field">\
  368. <div id="cbi-table-1-diff"></div>\
  369. <div id="cbip-table-1-diff"></div>\
  370. </td>\
  371. <td class="cbi-value-field">\
  372. <div id="cbi-table-1-getworks">'+totalGetWorks+'</div>\
  373. <div id="cbip-table-1-getworks"></div>\
  374. </td>\
  375. <td class="cbi-value-field">\
  376. <div id="cbi-table-1-priority">'+totalPriority+'</div>\
  377. <div id="cbip-table-1-priority"></div>\
  378. </td>\
  379. <td class="cbi-value-field">\
  380. <div id="cbi-table-1-accepted">'+totalAccepted+'</div>\
  381. <div id="cbip-table-1-accepted"></div>\
  382. </td>\
  383. <td class="cbi-value-field">\
  384. <div id="cbi-table-1-diff1shares">'+totalDiff1+'</div>\
  385. <div id="cbip-table-1-diff1shares"></div>\
  386. </td>\
  387. <td class="cbi-value-field">\
  388. <div id="cbi-table-1-diffaccepted">'+totalDiffA+'</div>\
  389. <div id="cbip-table-1-diffaccepted"></div>\
  390. </td>\
  391. <td class="cbi-value-field">\
  392. <div id="cbi-table-1-diffrejected">'+totalDiffR+'</div>\
  393. <div id="cbip-table-1-diffrejected"></div>\
  394. </td>\
  395. <td class="cbi-value-field">\
  396. <div id="cbi-table-1-diffstale">'+totalDiffS+'</div>\
  397. <div id="cbip-table-1-diffstale"></div>\
  398. </td>\
  399. <td class="cbi-value-field">\
  400. <div id="cbi-table-1-rejected">'+totalRejected+'</div>\
  401. <div id="cbip-table-1-rejected"></div>\
  402. </td>\
  403. <td class="cbi-value-field">\
  404. <div id="cbi-table-1-discarded">'+totalDiscarded+'</div>\
  405. <div id="cbip-table-1-discarded"></div>\
  406. </td>\
  407. <td class="cbi-value-field">\
  408. <div id="cbi-table-1-stale">'+totalStale+'</div>\
  409. <div id="cbip-table-1-stale"></div>\
  410. </td>\
  411. <td class="cbi-value-field">\
  412. <div id="cbi-table-1-lastsharedifficulty"></div>\
  413. <div id="cbip-table-1-lastsharedifficulty"></div>\
  414. </td>\
  415. <td class="cbi-value-field">\
  416. <div id="cbi-table-1-lastsharetime"></div>\
  417. <div id="cbip-table-1-lastsharetime"></div>\
  418. </td>\
  419. </tr>\
  420. <tr class="cbi-section-table-row cbi-rowstyle-1" id="cbi-table-1">\
  421. <td class="cbi-value-field">\
  422. <div id="cbi-table-1-pool">HW</div>\
  423. <div id="cbip-table-1-pool"></div>\
  424. </td>\
  425. <td class="cbi-value-field">\
  426. <div id="cbi-table-1-url">'+hwUrl+'</div>\
  427. <div id="cbip-table-1-url"></div>\
  428. </td>\
  429. <td class="cbi-value-field">\
  430. <div id="cbi-table-1-user"></div>\
  431. <div id="cbip-table-1-user"></div>\
  432. </td>\
  433. <td class="cbi-value-field">\
  434. <div id="cbi-table-1-status"></div>\
  435. <div id="cbip-table-1-status"></div>\
  436. </td>\
  437. <td class="cbi-value-field">\
  438. <div id="cbi-table-1-diff"></div>\
  439. <div id="cbip-table-1-diff"></div>\
  440. </td>\
  441. <td class="cbi-value-field">\
  442. <div id="cbi-table-1-getworks"></div>\
  443. <div id="cbip-table-1-getworks"></div>\
  444. </td>\
  445. <td class="cbi-value-field">\
  446. <div id="cbi-table-1-priority"></div>\
  447. <div id="cbip-table-1-priority"></div>\
  448. </td>\
  449. <td class="cbi-value-field">\
  450. <div id="cbi-table-1-accepted"></div>\
  451. <div id="cbip-table-1-accepted"></div>\
  452. </td>\
  453. <td class="cbi-value-field">\
  454. <div id="cbi-table-1-diff1shares"></div>\
  455. <div id="cbip-table-1-diff1shares"></div>\
  456. </td>\
  457. <td class="cbi-value-field">\
  458. <div id="cbi-table-1-diffaccepted">'+hwDiffA+'</div>\
  459. <div id="cbip-table-1-diffaccepted"></div>\
  460. </td>\
  461. <td class="cbi-value-field">\
  462. <div id="cbi-table-1-diffrejected"></div>\
  463. <div id="cbip-table-1-diffrejected"></div>\
  464. </td>\
  465. <td class="cbi-value-field">\
  466. <div id="cbi-table-1-diffstale"></div>\
  467. <div id="cbip-table-1-diffstale"></div>\
  468. </td>\
  469. <td class="cbi-value-field">\
  470. <div id="cbi-table-1-rejected"></div>\
  471. <div id="cbip-table-1-rejected"></div>\
  472. </td>\
  473. <td class="cbi-value-field">\
  474. <div id="cbi-table-1-discarded"></div>\
  475. <div id="cbip-table-1-discarded"></div>\
  476. </td>\
  477. <td class="cbi-value-field">\
  478. <div id="cbi-table-1-stale"></div>\
  479. <div id="cbip-table-1-stale"></div>\
  480. </td>\
  481. <td class="cbi-value-field">\
  482. <div id="cbi-table-1-lastsharedifficulty"></div>\
  483. <div id="cbip-table-1-lastsharedifficulty"></div>\
  484. </td>\
  485. <td class="cbi-value-field">\
  486. <div id="cbi-table-1-lastsharetime"></div>\
  487. <div id="cbip-table-1-lastsharetime"></div>\
  488. </td>\
  489. </tr>';
  490. $(".J-pools-table tbody").append(rtnStr);
  491. $(".J-pools-table tfoot").append(tfootStr);
  492. }
  493. };
  494. /*
  495. **处理antminer table 数据
  496. **.J-antminer-table 要填充表格自定义样式仅供js使用
  497. **antMinerData.STATS[1] 数据项
  498. */
  499. function setAntMiner(antMinerData){
  500. var rtnStr = '';
  501. var str1 = "chain_rate";
  502. var chain_rate = {};
  503. var chain_acn = {};
  504. var chain_acs = {};
  505. var chain_hw = {};
  506. var temp_pcb ={};
  507. var temp_chip ={};
  508. var chainId = [];
  509. var fanArr = {};
  510. var frequency = '';
  511. var chain_freq = {};
  512. if(antMinerData.STATS.length > 0 ){
  513. var data = antMinerData.STATS[1];
  514. frequency = data.frequency;
  515. $.each(data,function(i,v){
  516.  
  517. if( i.indexOf("chain_rate") > -1){
  518. chain_rate[i] = v;
  519. }
  520. if( i.indexOf("chain_acn") > -1){
  521. chain_acn[i] = v;
  522. if(v > 0){
  523. var chai_id = Number(i.split("_acn")[1]);
  524. chainId.push(chai_id);
  525. }
  526. }
  527. if( i.indexOf("chain_hw") > -1) {
  528. chain_hw[i] = v;
  529. }
  530. if( i.indexOf("freq") > -1) {
  531. chain_freq[i] = v;
  532. }
  533. if( i.indexOf("temp_pcb") > -1){
  534. temp_pcb[i] = v;
  535. }
  536. if( i.indexOf("temp_chip") > -1){
  537. temp_chip[i] = v;
  538. }
  539. if( i.indexOf("chain_acs") > -1){
  540. chain_acs[i] = v;
  541. }
  542. if( i.indexOf("fan") > -1){
  543. fanArr[i] = v;
  544. }
  545. });
  546. }
  547.  
  548. var ChainIdUnique = uniqueArr(chainId);
  549. var chainIdSort = ChainIdUnique.sort(compare);
  550.  
  551. //根据chainId 循环输出数据行
  552. if(chainIdSort.length >0){
  553.  
  554. $.each(chainIdSort, function(i,v){
  555. rtnStr += '<tr class="cbi-section-table-row cbi-rowstyle-1">\
  556. <td class="cbi-value-field">\
  557. <div>'+v+'</div>\
  558. </td>\
  559. <td class="cbi-value-field">\
  560. <div>'+chain_acn['chain_acn'+v]+'</div>\
  561. </td>\
  562. <td class="cbi-value-field">\
  563. <div>'+chain_freq['freq'+v]+'</div>\
  564. </td>\
  565. <td class="cbi-value-field">\
  566. <div>'+chain_rate['chain_rate'+v]+'</div>\
  567. </td>\
  568. <td class="cbi-value-field">\
  569. <div>'+chain_hw['chain_hw'+v]+'</div>\
  570. </td>\
  571. <td class="cbi-value-field">\
  572. <div>'+temp_pcb['temp_pcb'+v]+'</div>\
  573. </td>\
  574. <td class="cbi-value-field">\
  575. <div>'+temp_chip['temp_chip'+v]+'</div>\
  576. </td>\
  577. <td class="cbi-value-field">\
  578. <div>'+chain_acs['chain_acs'+v]+'</div>\
  579. </td>\
  580. </tr>';
  581. });
  582. $("#ant_devs tbody").append(rtnStr);
  583. }else{
  584. $("#ant_devs tbody").append('<tr><td colspan="7">暂无数据!</td></tr>');
  585. }
  586.  
  587. //fan_num 根据fanArr 生成fan数据
  588. if(fanArr){
  589. var fanStr = '';
  590. var thStr = '<thead>\
  591. <tr class="cbi-section-table-titles">\
  592. <th class="cbi-section-table-cell" style="width:10%;">Fan#</th>';
  593. var tdStr = '</tr>\
  594. </thead><tbody><tr class="cbi-section-table-row"><td class="cbi-rowstyle-1 cbi-value-field">Speed (r/min)</td>';
  595. $.each(fanArr, function(i,v){
  596. if(i != "fan_num" && v != 0){
  597. thStr += '<th class="cbi-section-table-cell">'+i+'</th>';
  598. tdStr += '<td id="ant_'+i+'" class="cbi-rowstyle-1 cbi-value-field">'+v+'</td>';
  599. }
  600. });
  601. tdStr += '</tr></tbody>';
  602. $("#ant_fans").append(thStr, tdStr);
  603. }
  604.  
  605. };
  606. //数组去重
  607. function uniqueArr(arr){
  608. var res = [];
  609. var json = {};
  610. for(var i = 0; i < arr.length; i++){
  611. if(!json[arr[i]]){
  612. res.push(arr[i]);
  613. json[arr[i]] = 1;
  614. }
  615. }
  616. return res;
  617. }
  618. //数组排序
  619. function compare (x, y) {//比较函数
  620. if (x < y) {
  621. return -1;
  622. } else if (x > y) {
  623. return 1;
  624. } else {
  625. return 0;
  626. }
  627. }
  628.  
  629.  
  630. //处理时间函数
  631. function formatDateTime(inputTime) {
  632. /*var date = new Date(inputTime);
  633. var y = date.getFullYear();
  634. var m = date.getMonth() + 1;
  635. //m = m < 10 ? ('0' + m) : m;
  636. var d = date.getDate();
  637. //d = d < 10 ? ('0' + d) : d;
  638. var h = date.getHours();
  639. //h = h < 10 ? ('0' + h) : h;
  640. var minute = date.getMinutes();
  641. var second = date.getSeconds();
  642. //minute = minute < 10 ? ('0' + minute) : minute;
  643. //second = second < 10 ? ('0' + second) : second;
  644. return d+'d'+h+'h'+minute+'m'+second+'s'; */
  645. var d = parseInt(inputTime / 86400);
  646. var h = parseInt((inputTime-d*86400)/3600);
  647. var m = parseInt((inputTime - d*86400 - h*3600) / 60);
  648. var s = (inputTime - d*86400 - h*3600 - m*60);
  649.  
  650. var dStr = d==0 ? '' : d+'d';
  651. var hStr = h==0 ? '' : h+'h';
  652. var mStr = m==0 ? '' : m+'m';
  653. var sStr = s==0 ? '' : s+'s';
  654. return dStr + hStr + mStr + sStr;
  655. };
  656.  
  657. });
  658.  
  659. </script>
  660. </body>
  661. </html>
  662.  
  663. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  664. <meta http-equiv="Content-Script-Type" content="text/javascript" />
  665. <meta http-equiv="cache-control" content="no-cache" />
  666. <link rel="stylesheet" type="text/css" media="screen" href="/css/cascade.css" />
  667. <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" /><![endif]-->
  668. <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie7.css" /><![endif]-->
  669. <!--[if IE 8]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie8.css" /><![endif]-->
  670. <script type="text/javascript" src="/js/xhr.js"></script>
  671. <script type="text/javascript" src="/js/jquery-1.10.2.js"></script>
  672.  
  673. <script type="text/javascript">
  674.  
  675. function getAjaxData(url, backFun) {
  676. $.ajax({
  677. type: "GET",
  678. url: url,
  679. dataType: "json",
  680. async: false,
  681. success: function(data) {
  682. backFun(data);
  683. },
  684. error: function() {
  685. //alert("error");
  686. }
  687. });
  688. }
  689.  
  690. function getAjaxDataPlain(url, backFun) {
  691. $.ajax({
  692. type: "GET",
  693. url: url,
  694. dataType: "text",
  695. async: false,
  696. success: function(data) {
  697. backFun(data);
  698. },
  699. error: function() {
  700. //alert("error");
  701. }
  702. });
  703. }
  704.  
  705. function detectQuality() {
  706. var miner_type = "";
  707. var averageGH = 0;
  708. var hwError = 0;
  709. var frequency = 0;
  710. var miner_count = 0;
  711. var asic_count = 0;
  712. var elapsed = 0;
  713. var realtimeGH = 0;
  714.  
  715. var idealGH = 0;
  716. var idealHwError = 0.05;
  717. var idealFanSpeed = 1600;
  718.  
  719. var isGHOk = true;
  720. var isFanOk = true;
  721. var isHwErrorOk = true;
  722.  
  723. var expectedContent = "<tr><th width='50%'>GH Target</th><th width='39%'>Fan Speed</th><th width='40%'>HW</th></tr>";
  724. var tableContent = "<tr><th width='38%'>GH Avg</th><th width='39%'>Fan Speed</th><th width='40%'>HW</th></tr>";
  725. var fanContent = "";
  726. var ghBgColor = "greeen";
  727. var hwBgColor = "gren";
  728. var fanBgColor = "greeen";
  729. function setAntMiner(antMinerData) {
  730. if (antMinerData.STATS.length > 0) {
  731. var data0 = antMinerData.STATS[0];
  732. miner_type = data0.Type;
  733.  
  734. var data1 = antMinerData.STATS[1];
  735. frequency = data1.frequency;
  736. $.each(data1,
  737. function(i, v) {
  738. if (i.indexOf("Elapsed") > -1) {
  739. elapsed = v;
  740. }
  741. if (i.indexOf("Hardware") > -1) {
  742. hwError = v;
  743. }
  744. if (i.indexOf("GHS av") > -1) {
  745. averageGH = v;
  746. }
  747. if (i.indexOf("GHS 5s") > -1) {
  748. realtimeGH = v;
  749. }
  750. if (i.indexOf("miner_count") > -1) {
  751. miner_count = v;
  752. }
  753. if (i.indexOf("chain_acn") > -1) {
  754. if (v > 0) {
  755. asic_count = v;
  756. }
  757. }
  758. if (i.indexOf("fan_num") < 0 && i.indexOf("fan") > -1) {
  759. if (v > 0) {
  760. fanContent += (v + "/");
  761. if (v <= idealFanSpeed) {
  762. isFanOk = false;
  763. fanBgColor = "red";
  764. }
  765. }
  766. }
  767.  
  768. });
  769. }
  770. if (miner_type.indexOf("15") > -1) {
  771. idealFanSpeed = 4400;
  772. idealGH = frequency * 256 * asic_count * miner_count * 0.98 / 1000;
  773. if (idealGH > averageGH) {
  774. isGHOk = false;
  775. ghBgColor = "red";
  776. }
  777. }
  778. if (miner_type.indexOf("17") > -1) {
  779. idealFanSpeed = 5400;
  780. idealGH = frequency * 675 * asic_count * miner_count * 0.98 / 1000;
  781. if (idealGH > averageGH) {
  782. isGHOk = false;
  783. ghBgColor = "red";
  784. }
  785. }
  786. if ( realtimeGH <= 0 ){
  787. isGHOk = false;
  788. ghBgColor = "red";
  789. }
  790. if (hwError >= idealHwError) {
  791. isHwErrorOk = false;
  792. hwBgColor = "red";
  793. }
  794. fanContent = fanContent.substring(0, fanContent.length - 1);
  795. tableContent += "<tr><td " + "bgcolor=" + ghBgColor + ">" + averageGH + "</td><td "
  796. + "bgcolor=" + fanBgColor + ">" + fanContent + "</td><td "
  797. + "bgcolor=" + hwBgColor + ">" + hwError + "</td></tr>";
  798. var content = "";
  799. if ( realtimeGH <= 0 ) {
  800. content = "<span style='color:red; font-size:36px'>FAIL</span><br /><br />";
  801. } else if (elapsed < 600) {
  802. content = "<span style='font-size:24px'>Total time test is 600s, Elapsed..." + elapsed + "</span>" ;
  803. } else {
  804. if (isGHOk && isFanOk) {
  805. content = "<span style='color:green; font-size:36px'>Tune is OK</span>";
  806. } else {
  807. content = "<span style='color:red; font-size:36px'>FAIL,</span><br /><br />";
  808. if (!isGHOk) {
  809. content += "<span style='color:red; font-size:36px'>Need add more Voltage</span><br /><br />";
  810. }
  811. //if (!isHwErrorOk) {
  812. // content += "<span style='color:red; font-size:36px'>Hw error, hashboard defective or need more voltage</span><br /><br />";
  813. //}
  814. if (!isFanOk) {
  815. content += "<span style='color:red; font-size:36px'>Fan low speed, need replace</span><br /><br />";
  816. }
  817. }
  818. }
  819. expectedContent += "<tr><td>" + idealGH + "</td><td>" + idealFanSpeed
  820. + "</td><td>" + idealHwError + "</td>";
  821. $("#expectValueTable").html(expectedContent);
  822. $("#currentValueTable").html(tableContent);
  823. $("#result").html(content);
  824. }
  825.  
  826. function setGHErrorCode(rateData) {
  827. $("#errorCodeSpan").text(rateData);
  828. document.getElementById("errorCodeDiv").style.display = "";
  829. }
  830.  
  831. getAjaxData("/cgi-bin/miner_stats.cgi", setAntMiner);
  832.  
  833. if (realtimeGH <= 0.00) {
  834. getAjaxDataPlain("/cgi-bin/miner_rate.cgi", setGHErrorCode);
  835. }
  836. }
  837.  
  838. $(function() {
  839. detectQuality();
  840. setInterval(detectQuality, 2000);
  841. });
  842.  
  843. </script>
  844. </head>
  845.  
  846. <body class="lang_en">
  847. <p class="skiplink">
  848. <span id="skiplink1"><a href="#navigation">Skip to navigation</a></span>
  849. <span id="skiplink2"><a href="#content">Skip to content</a></span>
  850. </p>
  851. <div id="menubar">
  852. <h2 class="navigation"><a id="navigation" name="navigation">Navigation</a></h2>
  853. <div class="clear"></div>
  854. </div>
  855. <div id="menubar" style="background-color: #0a2b40;">
  856. <div class="hostinfo" style="float: left; with: 500px;">
  857. <br style="clear: both" />
  858. </div>
  859. </div>
  860. <div id="maincontent">
  861. <div id="expectValue">
  862. <label>--------------------Expect status--------------------</label>
  863. <table id="expectValueTable" border="5"></table>
  864. </div>
  865. <br />
  866. <div id="currentValue">
  867. <label>Actual status:</label>
  868. <table id="currentValueTable" border="1"></table>
  869. </div>
  870. <br />
  871. <div id="errorCodeDiv" style="display: none;">
  872. <label>Error Code: </label><span id="errorCodeSpan"></span>
  873. </div>
  874. <br />
  875. <div id="result"></div>
  876. </div>
  877. </div>
  878. </body>
  879. </html>
Advertisement
RAW Paste Data Copied
Advertisement