mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-30 08:24:16 +00:00
api: changes in data, global stuff in summary
PS: still under dev, wait the final 1.4.8 ;)
This commit is contained in:
parent
f58b2d3d21
commit
11a4bb1797
36
api.c
36
api.c
@ -91,7 +91,7 @@ static struct IP4ACCESS *ipaccess = NULL;
|
|||||||
static const char *localaddr = LOCAL_ADDR_V4;
|
static const char *localaddr = LOCAL_ADDR_V4;
|
||||||
static const char *UNAVAILABLE = " - API will not be available";
|
static const char *UNAVAILABLE = " - API will not be available";
|
||||||
static char *buffer = NULL;
|
static char *buffer = NULL;
|
||||||
|
static time_t startup = 0;
|
||||||
static int bye = 0;
|
static int bye = 0;
|
||||||
|
|
||||||
extern int opt_intensity;
|
extern int opt_intensity;
|
||||||
@ -111,17 +111,13 @@ extern void get_currentalgo(char* buf, int sz);
|
|||||||
|
|
||||||
static void gpustatus(int thr_id)
|
static void gpustatus(int thr_id)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[MYBUFSIZ];
|
||||||
float gt;
|
float gt;
|
||||||
int gf, gp;
|
int gf, gp;
|
||||||
|
|
||||||
|
|
||||||
if (thr_id >= 0 && thr_id < gpu_threads) {
|
if (thr_id >= 0 && thr_id < gpu_threads) {
|
||||||
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
|
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
|
||||||
|
|
||||||
int total_secs = 1; // todo
|
|
||||||
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
||||||
|
|
||||||
#ifdef HAVE_HWMONITORING
|
#ifdef HAVE_HWMONITORING
|
||||||
// todo
|
// todo
|
||||||
if (gpu->has_monitoring) {
|
if (gpu->has_monitoring) {
|
||||||
@ -153,10 +149,9 @@ static void gpustatus(int thr_id)
|
|||||||
cgpu->khashes = stats_get_speed(thr_id) / 1000.0;
|
cgpu->khashes = stats_get_speed(thr_id) / 1000.0;
|
||||||
|
|
||||||
sprintf(buf, "GPU=%d;TEMP=%.1f;FAN=%d;FANP=%d;KHS=%.2f;"
|
sprintf(buf, "GPU=%d;TEMP=%.1f;FAN=%d;FANP=%d;KHS=%.2f;"
|
||||||
"ACC=%d;REJ=%d;HWF=%d;U=%.2f;I=%d|",
|
"HWF=%d;I=%d|",
|
||||||
thr_id, gt, gf, gp, cgpu->khashes,
|
thr_id, gt, gf, gp, cgpu->khashes,
|
||||||
cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
|
cgpu->hw_errors, cgpu->intensity);
|
||||||
cgpu->utility, cgpu->intensity);
|
|
||||||
|
|
||||||
strcat(buffer, buf);
|
strcat(buffer, buf);
|
||||||
}
|
}
|
||||||
@ -167,12 +162,18 @@ static void gpustatus(int thr_id)
|
|||||||
static char *getsummary(char *params)
|
static char *getsummary(char *params)
|
||||||
{
|
{
|
||||||
char algo[64] = "";
|
char algo[64] = "";
|
||||||
|
int uptime = (time(NULL) - startup);
|
||||||
|
double accps = (60.0 * accepted_count) / (uptime ? uptime : 1.0);
|
||||||
|
|
||||||
get_currentalgo(algo, sizeof(algo));
|
get_currentalgo(algo, sizeof(algo));
|
||||||
|
|
||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
|
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
|
||||||
"ALGO=%s;KHS=%.2f|",
|
"ALGO=%s;KHS=%.2f;ACC=%d;REJ=%d;ACCMN=%.3f;UPTIME=%d|",
|
||||||
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
|
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
|
||||||
algo, (double)global_hashrate / 1000.0);
|
algo, (double)global_hashrate / 1000.0,
|
||||||
|
accepted_count, rejected_count,
|
||||||
|
accps, uptime);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,18 +225,13 @@ static void setup_ipaccess()
|
|||||||
proper_exit(1);//, "Failed to malloc ipaccess buf");
|
proper_exit(1);//, "Failed to malloc ipaccess buf");
|
||||||
|
|
||||||
strcpy(buf, opt_api_allow);
|
strcpy(buf, opt_api_allow);
|
||||||
|
|
||||||
ipcount = 1;
|
ipcount = 1;
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
while (*ptr) if (*(ptr++) == ',')
|
while (*ptr) if (*(ptr++) == ',')
|
||||||
ipcount++;
|
ipcount++;
|
||||||
|
|
||||||
// possibly more than needed, but never less
|
// possibly more than needed, but never less
|
||||||
#ifdef _MSC_VER
|
ipaccess = (struct IP4ACCESS *) calloc(ipcount, sizeof(struct IP4ACCESS));
|
||||||
ipaccess = (IP4ACCESS *) calloc(ipcount, sizeof(struct IP4ACCESS));
|
|
||||||
#else
|
|
||||||
ipaccess = calloc(ipcount, sizeof(struct IP4ACCESS));
|
|
||||||
#endif
|
|
||||||
if (unlikely(!ipaccess))
|
if (unlikely(!ipaccess))
|
||||||
proper_exit(1);//, "Failed to calloc ipaccess");
|
proper_exit(1);//, "Failed to calloc ipaccess");
|
||||||
|
|
||||||
@ -338,7 +334,7 @@ static void api()
|
|||||||
{
|
{
|
||||||
const char *addr = localaddr;
|
const char *addr = localaddr;
|
||||||
short int port = opt_api_listen; // 4068
|
short int port = opt_api_listen; // 4068
|
||||||
char buf[BUFSIZ];
|
char buf[MYBUFSIZ];
|
||||||
int c, n, bound;
|
int c, n, bound;
|
||||||
char *connectaddr;
|
char *connectaddr;
|
||||||
char *binderror;
|
char *binderror;
|
||||||
@ -453,7 +449,7 @@ static void api()
|
|||||||
connectaddr, addrok ? "Accepted" : "Ignored");
|
connectaddr, addrok ? "Accepted" : "Ignored");
|
||||||
|
|
||||||
if (addrok) {
|
if (addrok) {
|
||||||
n = recv(c, &buf[0], BUFSIZ - 1, 0);
|
n = recv(c, &buf[0], MYBUFSIZ - 1, 0);
|
||||||
// applog(LOG_DEBUG, "API: recv command: (%d) '%s'", n, buf);
|
// applog(LOG_DEBUG, "API: recv command: (%d) '%s'", n, buf);
|
||||||
if (!SOCKETFAIL(n)) {
|
if (!SOCKETFAIL(n)) {
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
@ -478,10 +474,12 @@ static void api()
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* external access */
|
||||||
void *api_thread(void *userdata)
|
void *api_thread(void *userdata)
|
||||||
{
|
{
|
||||||
struct thr_info *mythr = (struct thr_info*)userdata;
|
struct thr_info *mythr = (struct thr_info*)userdata;
|
||||||
|
|
||||||
|
startup = time(NULL);
|
||||||
api();
|
api();
|
||||||
|
|
||||||
tq_freeze(mythr->q);
|
tq_freeze(mythr->q);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user