mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-24 21:44:38 +00:00
Pools: add RollTime info to API 'stats' and 'Stats' button in miner.php
This commit is contained in:
parent
fee870b5d1
commit
d5f485c517
11
API-README
11
API-README
@ -339,6 +339,17 @@ miner.php - an example web page to access the API
|
|||||||
Feature Changelog for external applications using 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)
|
API V1.17 (cgminer v2.7.1)
|
||||||
|
|
||||||
Added API commands:
|
Added API commands:
|
||||||
|
7
api.c
7
api.c
@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
|
|||||||
#define SEPSTR "|"
|
#define SEPSTR "|"
|
||||||
static const char GPUSEP = ',';
|
static const char GPUSEP = ',';
|
||||||
|
|
||||||
static const char *APIVERSION = "1.17";
|
static const char *APIVERSION = "1.18";
|
||||||
static const char *DEAD = "Dead";
|
static const char *DEAD = "Dead";
|
||||||
static const char *SICK = "Sick";
|
static const char *SICK = "Sick";
|
||||||
static const char *NOSTART = "NoStart";
|
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, "Device Code", DEVICECODE, false);
|
||||||
root = api_add_const(root, "OS", OSINFO, false);
|
root = api_add_const(root, "OS", OSINFO, false);
|
||||||
root = api_add_bool(root, "Failover-Only", &opt_fail_only, 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);
|
root = print_data(root, buf, isjson);
|
||||||
if (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 Max", &(pool_stats->getwork_wait_max), false);
|
||||||
root = api_add_timeval(root, "Pool Min", &(pool_stats->getwork_wait_min), 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_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)
|
if (extra)
|
||||||
|
4
miner.h
4
miner.h
@ -307,6 +307,10 @@ struct cgminer_pool_stats {
|
|||||||
struct timeval getwork_wait_max;
|
struct timeval getwork_wait_max;
|
||||||
struct timeval getwork_wait_min;
|
struct timeval getwork_wait_min;
|
||||||
double getwork_wait_rolling;
|
double getwork_wait_rolling;
|
||||||
|
bool hadrolltime;
|
||||||
|
bool canroll;
|
||||||
|
bool hadexpire;
|
||||||
|
uint32_t rolltime;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cgpu_info {
|
struct cgpu_info {
|
||||||
|
18
miner.php
18
miner.php
@ -84,8 +84,24 @@ $mobilesum = array(
|
|||||||
'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected', 'DEVS.Utility'),
|
'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected', 'DEVS.Utility'),
|
||||||
'POOL' => array('Accepted', 'Rejected'));
|
'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 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'];
|
$here = $_SERVER['PHP_SELF'];
|
||||||
#
|
#
|
||||||
|
17
util.c
17
util.c
@ -58,6 +58,9 @@ struct header_info {
|
|||||||
char *lp_path;
|
char *lp_path;
|
||||||
int rolltime;
|
int rolltime;
|
||||||
char *reason;
|
char *reason;
|
||||||
|
bool hadrolltime;
|
||||||
|
bool canroll;
|
||||||
|
bool hadexpire;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tq_ent {
|
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);
|
applog(LOG_DEBUG, "HTTP hdr(%s): %s", key, val);
|
||||||
|
|
||||||
if (!strcasecmp("X-Roll-Ntime", key)) {
|
if (!strcasecmp("X-Roll-Ntime", key)) {
|
||||||
|
hi->hadrolltime = true;
|
||||||
if (!strncasecmp("N", val, 1))
|
if (!strncasecmp("N", val, 1))
|
||||||
applog(LOG_DEBUG, "X-Roll-Ntime: N found");
|
applog(LOG_DEBUG, "X-Roll-Ntime: N found");
|
||||||
else {
|
else {
|
||||||
|
hi->canroll = true;
|
||||||
|
|
||||||
/* Check to see if expire= is supported and if not, set
|
/* Check to see if expire= is supported and if not, set
|
||||||
* the rolltime to the default scantime */
|
* 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);
|
sscanf(val + 7, "%d", &hi->rolltime);
|
||||||
else
|
hi->hadexpire = true;
|
||||||
|
} else
|
||||||
hi->rolltime = opt_scantime;
|
hi->rolltime = opt_scantime;
|
||||||
applog(LOG_DEBUG, "X-Roll-Ntime expiry set to %d", hi->rolltime);
|
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;
|
long timeout = longpoll ? (60 * 60) : 60;
|
||||||
struct data_buffer all_data = {NULL, 0};
|
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 len_hdr[64], user_agent_hdr[128];
|
||||||
char curl_err_str[CURL_ERROR_SIZE];
|
char curl_err_str[CURL_ERROR_SIZE];
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
@ -388,6 +395,10 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*rolltime = hi.rolltime;
|
*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);
|
val = JSON_LOADS(all_data.buf, &err);
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user