Pools: add RollTime info to API 'stats' and 'Stats' button in miner.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
diff --git a/API-README b/API-README
index d4efaf6..ff48a3c 100644
--- a/API-README
+++ b/API-README
@@ -339,6 +339,17 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
+API V1.18
+
+Modified API commands:
+ 'stats' - add 'Work Had Roll Time', 'Work Can Roll', 'Work Had Expire',
+ 'Work Roll Time' to the pool stats
+
+Modified API commands:
+ 'config' - include 'ScanTime'
+
+----------
+
API V1.17 (cgminer v2.7.1)
Added API commands:
diff --git a/api.c b/api.c
index 05d7d3e..ca1b942 100644
--- a/api.c
+++ b/api.c
@@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
#define SEPSTR "|"
static const char GPUSEP = ',';
-static const char *APIVERSION = "1.17";
+static const char *APIVERSION = "1.18";
static const char *DEAD = "Dead";
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
@@ -1256,6 +1256,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
root = api_add_const(root, "Device Code", DEVICECODE, false);
root = api_add_const(root, "OS", OSINFO, false);
root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
+ root = api_add_int(root, "ScanTime", &opt_scantime, false);
root = print_data(root, buf, isjson);
if (isjson)
@@ -2676,6 +2677,10 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine
root = api_add_timeval(root, "Pool Max", &(pool_stats->getwork_wait_max), false);
root = api_add_timeval(root, "Pool Min", &(pool_stats->getwork_wait_min), false);
root = api_add_double(root, "Pool Av", &(pool_stats->getwork_wait_rolling), false);
+ root = api_add_bool(root, "Work Had Roll Time", &(pool_stats->hadrolltime), false);
+ root = api_add_bool(root, "Work Can Roll", &(pool_stats->canroll), false);
+ root = api_add_bool(root, "Work Had Expire", &(pool_stats->hadexpire), false);
+ root = api_add_uint32(root, "Work Roll Time", &(pool_stats->rolltime), false);
}
if (extra)
diff --git a/miner.h b/miner.h
index 91fe7ce..4f7b1d7 100644
--- a/miner.h
+++ b/miner.h
@@ -307,6 +307,10 @@ struct cgminer_pool_stats {
struct timeval getwork_wait_max;
struct timeval getwork_wait_min;
double getwork_wait_rolling;
+ bool hadrolltime;
+ bool canroll;
+ bool hadexpire;
+ uint32_t rolltime;
};
struct cgpu_info {
diff --git a/miner.php b/miner.php
index 198f0cf..9c6f694 100644
--- a/miner.php
+++ b/miner.php
@@ -84,8 +84,24 @@ $mobilesum = array(
'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected', 'DEVS.Utility'),
'POOL' => array('Accepted', 'Rejected'));
#
+$statspage = array(
+ 'DATE' => null,
+ 'RIGS' => null,
+ 'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks',
+ 'Accepted', 'Rejected=Rej', 'Utility',
+ 'Hardware Errors=HW Errs', 'Network Blocks=Net Blks',
+ 'Work Utility'),
+ 'COIN' => array('*'),
+ 'STATS' => array('*'));
+#
+$statssum = array(
+ 'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted',
+ 'Rejected', 'Utility', 'Hardware Errors',
+ 'Work Utility'));
+#
# customsummarypages is an array of these Custom Summary Pages
-$customsummarypages = array('Mobile' => array($mobilepage, $mobilesum));
+$customsummarypages = array('Mobile' => array($mobilepage, $mobilesum),
+ 'Stats' => array($statspage, $statssum));
#
$here = $_SERVER['PHP_SELF'];
#
diff --git a/util.c b/util.c
index b104d8a..724ffa9 100644
--- a/util.c
+++ b/util.c
@@ -58,6 +58,9 @@ struct header_info {
char *lp_path;
int rolltime;
char *reason;
+ bool hadrolltime;
+ bool canroll;
+ bool hadexpire;
};
struct tq_ent {
@@ -157,14 +160,18 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
applog(LOG_DEBUG, "HTTP hdr(%s): %s", key, val);
if (!strcasecmp("X-Roll-Ntime", key)) {
+ hi->hadrolltime = true;
if (!strncasecmp("N", val, 1))
applog(LOG_DEBUG, "X-Roll-Ntime: N found");
else {
+ hi->canroll = true;
+
/* Check to see if expire= is supported and if not, set
* the rolltime to the default scantime */
- if (strlen(val) > 7 && !strncasecmp("expire=", val, 7))
+ if (strlen(val) > 7 && !strncasecmp("expire=", val, 7)) {
sscanf(val + 7, "%d", &hi->rolltime);
- else
+ hi->hadexpire = true;
+ } else
hi->rolltime = opt_scantime;
applog(LOG_DEBUG, "X-Roll-Ntime expiry set to %d", hi->rolltime);
}
@@ -258,7 +265,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
{
long timeout = longpoll ? (60 * 60) : 60;
struct data_buffer all_data = {NULL, 0};
- struct header_info hi = {NULL, 0, NULL};
+ struct header_info hi = {NULL, 0, NULL, false, false, false};
char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE];
struct curl_slist *headers = NULL;
@@ -388,6 +395,10 @@ json_t *json_rpc_call(CURL *curl, const char *url,
}
*rolltime = hi.rolltime;
+ pool->cgminer_pool_stats.rolltime = hi.rolltime;
+ pool->cgminer_pool_stats.hadrolltime = hi.hadrolltime;
+ pool->cgminer_pool_stats.canroll = hi.canroll;
+ pool->cgminer_pool_stats.hadexpire = hi.hadexpire;
val = JSON_LOADS(all_data.buf, &err);
if (!val) {