mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-10 14:57:53 +00:00
api: add scanlog command to monitor scan ranges
will be used for external debugging...
This commit is contained in:
parent
1dfbe6dfb5
commit
dc5d1b112d
28
api.cpp
28
api.cpp
@ -284,7 +284,7 @@ static char *gethwinfos(char *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last 20 scans stats (not the same as shares)
|
* Returns the last 50 scans stats
|
||||||
* optional param thread id (default all)
|
* optional param thread id (default all)
|
||||||
*/
|
*/
|
||||||
static char *gethistory(char *params)
|
static char *gethistory(char *params)
|
||||||
@ -304,6 +304,25 @@ static char *gethistory(char *params)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the job scans ranges (debug purpose)
|
||||||
|
*/
|
||||||
|
static char *getscanlog(char *params)
|
||||||
|
{
|
||||||
|
struct hashlog_data data[50];
|
||||||
|
char *p = buffer;
|
||||||
|
int records = hashlog_get_history(data, ARRAY_SIZE(data));
|
||||||
|
*buffer = '\0';
|
||||||
|
for (int i = 0; i < records; i++) {
|
||||||
|
time_t ts = data[i].tm_upd;
|
||||||
|
p += sprintf(p, "H=%u;JOB=%u;N=%u;FROM=0x%x;SCANTO=0x%x;"
|
||||||
|
"COUNT=0x%x;FOUND=%u;TS=%u|",
|
||||||
|
data[i].height, data[i].njobid, data[i].nonce, data[i].scanned_from, data[i].scanned_to,
|
||||||
|
(data[i].scanned_to - data[i].scanned_from), data[i].tm_sent ? 1 : 0, (uint32_t)ts);
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some debug infos about memory usage
|
* Some debug infos about memory usage
|
||||||
*/
|
*/
|
||||||
@ -331,6 +350,7 @@ struct CMDS {
|
|||||||
{ "summary", getsummary },
|
{ "summary", getsummary },
|
||||||
{ "threads", getthreads },
|
{ "threads", getthreads },
|
||||||
{ "histo", gethistory },
|
{ "histo", gethistory },
|
||||||
|
{ "scanlog", getscanlog },
|
||||||
{ "meminfo", getmeminfo },
|
{ "meminfo", getmeminfo },
|
||||||
{ "hwinfo", gethwinfos },
|
{ "hwinfo", gethwinfos },
|
||||||
/* keep it the last */
|
/* keep it the last */
|
||||||
@ -344,9 +364,11 @@ static char *gethelp(char *params)
|
|||||||
char * p = buffer;
|
char * p = buffer;
|
||||||
for (int i = 0; i < CMDMAX-1; i++)
|
for (int i = 0; i < CMDMAX-1; i++)
|
||||||
p += sprintf(p, "%s\n", cmds[i].name);
|
p += sprintf(p, "%s\n", cmds[i].name);
|
||||||
|
sprintf(p, "|");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static int send_result(SOCKETTYPE c, char *result)
|
static int send_result(SOCKETTYPE c, char *result)
|
||||||
{
|
{
|
||||||
@ -620,10 +642,10 @@ static void api()
|
|||||||
*(params++) = '\0';
|
*(params++) = '\0';
|
||||||
|
|
||||||
if (opt_debug && opt_protocol && n > 0)
|
if (opt_debug && opt_protocol && n > 0)
|
||||||
applog(LOG_DEBUG, "API: exec command %s(%s)", buf, params);
|
applog(LOG_DEBUG, "API: exec command %s(%s)", buf, params ? params : "");
|
||||||
|
|
||||||
for (i = 0; i < CMDMAX; i++) {
|
for (i = 0; i < CMDMAX; i++) {
|
||||||
if (strcmp(buf, cmds[i].name) == 0) {
|
if (strcmp(buf, cmds[i].name) == 0 && strlen(buf)) {
|
||||||
result = (cmds[i].func)(params);
|
result = (cmds[i].func)(params);
|
||||||
send_result(c, result);
|
send_result(c, result);
|
||||||
break;
|
break;
|
||||||
|
26
hashlog.cpp
26
hashlog.cpp
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Hash log of submitted job nonces
|
* Hash log of submitted job nonces
|
||||||
* Prevent duplicate shares and could be used for RPC stats later
|
* Prevent duplicate shares
|
||||||
*
|
*
|
||||||
* Note: this source is C++ (requires std::map)
|
* (to be merged later with stats)
|
||||||
*
|
*
|
||||||
* tpruvot@github 2014
|
* tpruvot@github 2014
|
||||||
*/
|
*/
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#define LO_DWORD(u64) ((uint32_t) u64)
|
#define LO_DWORD(u64) ((uint32_t) u64)
|
||||||
#define MK_HI64(u32) (0x100000000ULL * u32)
|
#define MK_HI64(u32) (0x100000000ULL * u32)
|
||||||
|
|
||||||
|
/* from miner.h
|
||||||
struct hashlog_data {
|
struct hashlog_data {
|
||||||
uint32_t tm_sent;
|
uint32_t tm_sent;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
@ -25,6 +26,7 @@ struct hashlog_data {
|
|||||||
uint32_t tm_add;
|
uint32_t tm_add;
|
||||||
uint32_t tm_upd;
|
uint32_t tm_upd;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
static std::map<uint64_t, hashlog_data> tlastshares;
|
static std::map<uint64_t, hashlog_data> tlastshares;
|
||||||
|
|
||||||
@ -71,6 +73,7 @@ void hashlog_remember_submit(struct work* work, uint32_t nonce)
|
|||||||
data.scanned_from = work->scanned_from;
|
data.scanned_from = work->scanned_from;
|
||||||
data.scanned_to = nonce;
|
data.scanned_to = nonce;
|
||||||
data.height = work->height;
|
data.height = work->height;
|
||||||
|
data.njobid = (uint32_t) njobid;
|
||||||
data.tm_add = data.tm_upd = data.tm_sent = (uint32_t) time(NULL);
|
data.tm_add = data.tm_upd = data.tm_sent = (uint32_t) time(NULL);
|
||||||
tlastshares[key] = data;
|
tlastshares[key] = data;
|
||||||
}
|
}
|
||||||
@ -89,6 +92,7 @@ void hashlog_remember_scan_range(struct work* work)
|
|||||||
data = tlastshares[key];
|
data = tlastshares[key];
|
||||||
if (range == 0) {
|
if (range == 0) {
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.njobid = njobid;
|
||||||
} else {
|
} else {
|
||||||
// get min and max from all sent records
|
// get min and max from all sent records
|
||||||
data.scanned_from = LO_DWORD(range);
|
data.scanned_from = LO_DWORD(range);
|
||||||
@ -164,6 +168,24 @@ uint32_t hashlog_get_last_sent(char* jobid)
|
|||||||
return nonce;
|
return nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export data for api calls
|
||||||
|
*/
|
||||||
|
int hashlog_get_history(struct hashlog_data *data, int max_records)
|
||||||
|
{
|
||||||
|
int records = 0;
|
||||||
|
|
||||||
|
std::map<uint64_t, hashlog_data>::reverse_iterator it = tlastshares.rbegin();
|
||||||
|
while (it != tlastshares.rend() && records < max_records) {
|
||||||
|
memcpy(&data[records], &(it->second), sizeof(struct hashlog_data));
|
||||||
|
data[records].nonce = LO_DWORD(it->first);
|
||||||
|
data[records].njobid = (uint32_t) HI_DWORD(it->first);
|
||||||
|
records++;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove entries of a job...
|
* Remove entries of a job...
|
||||||
*/
|
*/
|
||||||
|
38
miner.h
38
miner.h
@ -399,6 +399,31 @@ struct thr_api {
|
|||||||
pthread_t pth;
|
pthread_t pth;
|
||||||
struct thread_q *q;
|
struct thread_q *q;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct stats_data {
|
||||||
|
uint32_t tm_stat;
|
||||||
|
uint32_t hashcount;
|
||||||
|
uint32_t height;
|
||||||
|
double difficulty;
|
||||||
|
double hashrate;
|
||||||
|
uint8_t thr_id;
|
||||||
|
uint8_t gpu_id;
|
||||||
|
uint8_t hashfound;
|
||||||
|
uint8_t ignored;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hashlog_data {
|
||||||
|
uint32_t tm_sent;
|
||||||
|
uint32_t height;
|
||||||
|
uint32_t njobid;
|
||||||
|
uint32_t nonce;
|
||||||
|
uint32_t scanned_from;
|
||||||
|
uint32_t scanned_to;
|
||||||
|
uint32_t last_from;
|
||||||
|
uint32_t tm_add;
|
||||||
|
uint32_t tm_upd;
|
||||||
|
};
|
||||||
|
|
||||||
/* end of api */
|
/* end of api */
|
||||||
|
|
||||||
struct thr_info {
|
struct thr_info {
|
||||||
@ -544,18 +569,6 @@ struct work {
|
|||||||
uint32_t scanned_to;
|
uint32_t scanned_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stats_data {
|
|
||||||
uint32_t tm_stat;
|
|
||||||
uint32_t hashcount;
|
|
||||||
uint32_t height;
|
|
||||||
double difficulty;
|
|
||||||
double hashrate;
|
|
||||||
uint8_t thr_id;
|
|
||||||
uint8_t gpu_id;
|
|
||||||
uint8_t hashfound;
|
|
||||||
uint8_t ignored;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool stratum_socket_full(struct stratum_ctx *sctx, int timeout);
|
bool stratum_socket_full(struct stratum_ctx *sctx, int timeout);
|
||||||
bool stratum_send_line(struct stratum_ctx *sctx, char *s);
|
bool stratum_send_line(struct stratum_ctx *sctx, char *s);
|
||||||
char *stratum_recv_line(struct stratum_ctx *sctx);
|
char *stratum_recv_line(struct stratum_ctx *sctx);
|
||||||
@ -570,6 +583,7 @@ void hashlog_remember_scan_range(struct work* work);
|
|||||||
uint32_t hashlog_already_submittted(char* jobid, uint32_t nounce);
|
uint32_t hashlog_already_submittted(char* jobid, uint32_t nounce);
|
||||||
uint32_t hashlog_get_last_sent(char* jobid);
|
uint32_t hashlog_get_last_sent(char* jobid);
|
||||||
uint64_t hashlog_get_scan_range(char* jobid);
|
uint64_t hashlog_get_scan_range(char* jobid);
|
||||||
|
int hashlog_get_history(struct hashlog_data *data, int max_records);
|
||||||
void hashlog_purge_old(void);
|
void hashlog_purge_old(void);
|
||||||
void hashlog_purge_job(char* jobid);
|
void hashlog_purge_job(char* jobid);
|
||||||
void hashlog_purge_all(void);
|
void hashlog_purge_all(void);
|
||||||
|
@ -90,11 +90,13 @@ double stats_get_speed(int thr_id, double def_speed)
|
|||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export data for api calls
|
||||||
|
*/
|
||||||
int stats_get_history(int thr_id, struct stats_data *data, int max_records)
|
int stats_get_history(int thr_id, struct stats_data *data, int max_records)
|
||||||
{
|
{
|
||||||
const uint64_t gpu = device_map[thr_id];
|
const uint64_t gpu = device_map[thr_id];
|
||||||
const uint64_t keymsk = 0xffULL; // last u8 is the gpu
|
const uint64_t keymsk = 0xffULL; // last u8 is the gpu
|
||||||
double speed = 0.0;
|
|
||||||
int records = 0;
|
int records = 0;
|
||||||
|
|
||||||
std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
|
std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
#define HWMON_ALT \
|
#define HWMON_ALT \
|
||||||
"/sys/class/hwmon/hwmon0/temp1_input"
|
"/sys/class/hwmon/hwmon0/temp1_input"
|
||||||
|
|
||||||
static float linux_cputemp(int core)
|
static double linux_cputemp(int core)
|
||||||
{
|
{
|
||||||
float tc = 0.0;
|
double tc = 0.0;
|
||||||
FILE *fd = fopen(HWMON_PATH, "r");
|
FILE *fd = fopen(HWMON_PATH, "r");
|
||||||
uint32_t val = 0;
|
uint32_t val = 0;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ static float linux_cputemp(int core)
|
|||||||
return tc;
|
return tc;
|
||||||
|
|
||||||
if (fscanf(fd, "%d", &val))
|
if (fscanf(fd, "%d", &val))
|
||||||
tc = val / 1000.0;
|
tc = (double)val / 1000.0;
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
return tc;
|
return tc;
|
||||||
@ -74,7 +74,7 @@ float cpu_temp(int core)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
return win32_cputemp(core);
|
return win32_cputemp(core);
|
||||||
#else
|
#else
|
||||||
return linux_cputemp(core);
|
return (float) linux_cputemp(core);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user