From 138465bf0c915f7a39220851b8aee535c1734fa9 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 13 Dec 2012 00:56:10 +1100 Subject: [PATCH 1/3] Pool store data transfer stats --- miner.h | 4 ++++ util.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/miner.h b/miner.h index bd8109ab..5fbe3712 100644 --- a/miner.h +++ b/miner.h @@ -352,6 +352,10 @@ struct cgminer_pool_stats { double last_diff; uint32_t min_diff_count; uint32_t max_diff_count; + uint64_t times_sent; + uint64_t bytes_sent; + uint64_t times_received; + uint64_t bytes_received; }; struct cgpu_info { diff --git a/util.c b/util.c index 4d9ee96e..abb5bcc6 100644 --- a/util.c +++ b/util.c @@ -275,6 +275,7 @@ json_t *json_rpc_call(CURL *curl, const char *url, struct upload_buffer upload_data; json_t *val, *err_val, *res_val; bool probing = false; + double byte_count; json_error_t err; int rc; @@ -384,6 +385,13 @@ json_t *json_rpc_call(CURL *curl, const char *url, goto err_out; } + pool->cgminer_pool_stats.times_sent++; + if (curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &byte_count) == CURLE_OK) + pool->cgminer_pool_stats.bytes_sent += byte_count; + pool->cgminer_pool_stats.times_received++; + if (curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &byte_count) == CURLE_OK) + pool->cgminer_pool_stats.bytes_received += byte_count; + if (probing) { pool->probed = true; /* If X-Long-Polling was found, activate long polling */ @@ -900,6 +908,8 @@ static bool __stratum_send(struct pool *pool, char *s, ssize_t len) len -= ssent; } + pool->cgminer_pool_stats.times_sent++; + pool->cgminer_pool_stats.bytes_sent += ssent; return true; } @@ -1000,6 +1010,9 @@ char *recv_line(struct pool *pool) memmove(pool->sockbuf, pool->sockbuf + len + 1, buflen - len + 1); else strcpy(pool->sockbuf, ""); + + pool->cgminer_pool_stats.times_received++; + pool->cgminer_pool_stats.bytes_received += len; out: if (!sret) clear_sock(pool); @@ -1311,6 +1324,7 @@ bool initiate_stratum(struct pool *pool) char curl_err_str[CURL_ERROR_SIZE]; char s[RBUFSIZE], *sret = NULL; CURL *curl = NULL; + double byte_count; json_error_t err; bool ret = false; @@ -1350,6 +1364,13 @@ bool initiate_stratum(struct pool *pool) curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, (long *)&pool->sock); keep_alive(curl, pool->sock); + pool->cgminer_pool_stats.times_sent++; + if (curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &byte_count) == CURLE_OK) + pool->cgminer_pool_stats.bytes_sent += byte_count; + pool->cgminer_pool_stats.times_received++; + if (curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &byte_count) == CURLE_OK) + pool->cgminer_pool_stats.bytes_received += byte_count; + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); if (!__stratum_send(pool, s, strlen(s))) { From 800ea016583b891a795941ca91323502682edd37 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 13 Dec 2012 01:09:03 +1100 Subject: [PATCH 2/3] API stats - display pool byte transfer stats --- API-README | 3 +++ api.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/API-README b/API-README index b5ec4536..5e41d9b9 100644 --- a/API-README +++ b/API-README @@ -394,6 +394,9 @@ Enforced output limitation: however, JSON brackets will be correctly closed and the JSON id will be set to 0 (instead of 1) if any data was truncated +Modified API commands: + 'stats' - add 'Times Sent', 'Bytes Sent', 'Times Recv', 'Bytes Recv' + ---------- API V1.21 (cgminer v2.10.0) diff --git a/api.c b/api.c index bfd7f69f..a993483b 100644 --- a/api.c +++ b/api.c @@ -2875,6 +2875,10 @@ static int itemstats(struct io_data *io_data, int i, char *id, struct cgminer_st root = api_add_diff(root, "Max Diff", &(pool_stats->max_diff), false); root = api_add_uint32(root, "Min Diff Count", &(pool_stats->min_diff_count), false); root = api_add_uint32(root, "Max Diff Count", &(pool_stats->max_diff_count), false); + root = api_add_uint64(root, "Times Sent", &(pool_stats->times_sent), false); + root = api_add_uint64(root, "Bytes Sent", &(pool_stats->bytes_sent), false); + root = api_add_uint64(root, "Times Recv", &(pool_stats->times_received), false); + root = api_add_uint64(root, "Bytes Recv", &(pool_stats->bytes_received), false); } if (extra) From 87e66ef7de046171341ff8fd107c9269cab1dc37 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 13 Dec 2012 10:21:23 +1100 Subject: [PATCH 3/3] miner.php - include windows easyphp link --- API-README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/API-README b/API-README index 5e41d9b9..1a686f52 100644 --- a/API-README +++ b/API-README @@ -714,7 +714,8 @@ On Fedora 17: systemctl enable httpd.service --system On windows there are a few options. -Try one of these (I've never used either one) +Try one of these (apparently the first one is easiest - thanks jborkl) + http://www.easyphp.org/ http://www.apachefriends.org/en/xampp.html http://www.wampserver.com/en/