|
|
@@ -163,6 +163,7 @@ static const char *SICK = "Sick";
|
|
|
static const char *NOSTART = "NoStart";
|
|
|
static const char *DISABLED = "Disabled";
|
|
|
static const char *ALIVE = "Alive";
|
|
|
+static const char *UNKNOWN = "Unknown";
|
|
|
#define _DYNAMIC "D"
|
|
|
static const char *DYNAMIC = _DYNAMIC;
|
|
|
|
|
|
@@ -770,156 +771,103 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
|
|
|
strcat(io_buffer, buf);
|
|
|
}
|
|
|
|
|
|
-static void gpustatus(int gpu, bool isjson)
|
|
|
+static const char*
|
|
|
+bool2str(bool b)
|
|
|
{
|
|
|
- char intensity[20];
|
|
|
- char buf[BUFSIZ];
|
|
|
- char *enabled;
|
|
|
- char *status;
|
|
|
- float gt, gv;
|
|
|
- int ga, gf, gp, gc, gm, pt;
|
|
|
-
|
|
|
- if (gpu >= 0 && gpu < nDevs) {
|
|
|
- struct cgpu_info *cgpu = &gpus[gpu];
|
|
|
-
|
|
|
- cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
|
-
|
|
|
-#ifdef HAVE_ADL
|
|
|
- if (!gpu_stats(gpu, >, &gc, &gm, &gv, &ga, &gf, &gp, &pt))
|
|
|
-#endif
|
|
|
- gt = gv = gm = gc = ga = gf = gp = pt = 0;
|
|
|
-
|
|
|
- if (cgpu->deven != DEV_DISABLED)
|
|
|
- enabled = (char *)YES;
|
|
|
- else
|
|
|
- enabled = (char *)NO;
|
|
|
-
|
|
|
- if (cgpu->status == LIFE_DEAD)
|
|
|
- status = (char *)DEAD;
|
|
|
- else if (cgpu->status == LIFE_SICK)
|
|
|
- status = (char *)SICK;
|
|
|
- else if (cgpu->status == LIFE_NOSTART)
|
|
|
- status = (char *)NOSTART;
|
|
|
- else
|
|
|
- status = (char *)ALIVE;
|
|
|
-
|
|
|
- if (cgpu->dynamic)
|
|
|
- strcpy(intensity, DYNAMIC);
|
|
|
- else
|
|
|
- sprintf(intensity, "%d", cgpu->intensity);
|
|
|
-
|
|
|
- if (isjson)
|
|
|
- sprintf(buf, "{\"GPU\":%d,\"Enabled\":\"%s\",\"Status\":\"%s\",\"Temperature\":%.2f,\"Fan Speed\":%d,\"Fan Percent\":%d,\"GPU Clock\":%d,\"Memory Clock\":%d,\"GPU Voltage\":%.3f,\"GPU Activity\":%d,\"Powertune\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Intensity\":\"%s\",\"Last Share Pool\":%d,\"Last Share Time\":%lu,\"Total MH\":%.4f}",
|
|
|
- gpu, enabled, status, gt, gf, gp, gc, gm, gv, ga, pt,
|
|
|
- cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
|
|
|
- cgpu->utility, intensity,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes);
|
|
|
- else
|
|
|
- sprintf(buf, "GPU=%d,Enabled=%s,Status=%s,Temperature=%.2f,Fan Speed=%d,Fan Percent=%d,GPU Clock=%d,Memory Clock=%d,GPU Voltage=%.3f,GPU Activity=%d,Powertune=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Intensity=%s,Last Share Pool=%d,Last Share Time=%lu,Total MH=%.4f%c",
|
|
|
- gpu, enabled, status, gt, gf, gp, gc, gm, gv, ga, pt,
|
|
|
- cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
|
|
|
- cgpu->utility, intensity,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes, SEPARATOR);
|
|
|
+ return b ? YES : NO;
|
|
|
+}
|
|
|
|
|
|
- strcat(io_buffer, buf);
|
|
|
+static const char*
|
|
|
+status2str(enum alive status)
|
|
|
+{
|
|
|
+ switch (status) {
|
|
|
+ case LIFE_WELL:
|
|
|
+ return ALIVE;
|
|
|
+ case LIFE_SICK:
|
|
|
+ return SICK;
|
|
|
+ case LIFE_DEAD:
|
|
|
+ return DEAD;
|
|
|
+ case LIFE_NOSTART:
|
|
|
+ return NOSTART;
|
|
|
+ default:
|
|
|
+ return UNKNOWN;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#if defined(USE_BITFORCE) || defined(USE_ICARUS)
|
|
|
-static void pgastatus(int pga, bool isjson)
|
|
|
+static void devstatus_an(char *buf, struct cgpu_info *cgpu, bool isjson)
|
|
|
{
|
|
|
- char buf[BUFSIZ];
|
|
|
- char *enabled;
|
|
|
- char *status;
|
|
|
- int numpga = numpgas();
|
|
|
-
|
|
|
- if (numpga > 0 && pga >= 0 && pga < numpga) {
|
|
|
- int dev = pgadevice(pga);
|
|
|
- if (dev < 0) // Should never happen
|
|
|
- return;
|
|
|
-
|
|
|
- struct cgpu_info *cgpu = devices[dev];
|
|
|
-
|
|
|
- cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
|
+ tailsprintf(buf, isjson
|
|
|
+ ? "{\"%s\":%d,\"Enabled\":\"%s\",\"Status\":\"%s\",\"Temperature\":%.2f,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Last Share Pool\":%d,\"Last Share Time\":%lu,\"Total MH\":%.4f,\"Driver\":\"%s\""
|
|
|
+ : "%s=%d,Enabled=%s,Status=%s,Temperature=%.2f,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Last Share Pool=%d,Last Share Time=%lu,Total MH=%.4f,Driver=%s",
|
|
|
+ cgpu->api->name, cgpu->device_id,
|
|
|
+ bool2str(cgpu->deven != DEV_DISABLED),
|
|
|
+ status2str(cgpu->status),
|
|
|
+ cgpu->temp,
|
|
|
+ cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
|
|
|
+ cgpu->accepted, cgpu->rejected, cgpu->hw_errors,
|
|
|
+ cgpu->utility,
|
|
|
+ ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
+ (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes,
|
|
|
+ cgpu->api->dname
|
|
|
+ );
|
|
|
+
|
|
|
+ if (cgpu->kname)
|
|
|
+ tailsprintf(buf, isjson ? ",\"Kernel\":\"%s\"" : ",Kernel=%s", cgpu->kname);
|
|
|
+ if (cgpu->name)
|
|
|
+ tailsprintf(buf, isjson ? ",\"Model\":\"%s\"" : ",Model=%s", cgpu->name);
|
|
|
+ if (cgpu->device_path)
|
|
|
+ tailsprintf(buf, isjson ? ",\"Device Path\":\"%s\"" : ",Device Path=%s", cgpu->device_path);
|
|
|
+
|
|
|
+ if (cgpu->api->get_extra_device_info) {
|
|
|
+ json_t *info = cgpu->api->get_extra_device_info(cgpu), *value;
|
|
|
+ const char *key, *tmpl = isjson ? ",\"%s\":%s" : ",%s=%s";
|
|
|
+ char *vdump;
|
|
|
+
|
|
|
+ json_object_foreach(info, key, value) {
|
|
|
+ if (isjson || !json_is_string(value))
|
|
|
+ vdump = json_dumps(value, JSON_COMPACT | JSON_ENCODE_ANY);
|
|
|
+ else
|
|
|
+ vdump = strdup(json_string_value(value));
|
|
|
+ tailsprintf(buf, tmpl, key, vdump);
|
|
|
+ free(vdump);
|
|
|
+ }
|
|
|
+ json_decref(info);
|
|
|
+ }
|
|
|
|
|
|
- if (cgpu->deven != DEV_DISABLED)
|
|
|
- enabled = (char *)YES;
|
|
|
- else
|
|
|
- enabled = (char *)NO;
|
|
|
-
|
|
|
- if (cgpu->status == LIFE_DEAD)
|
|
|
- status = (char *)DEAD;
|
|
|
- else if (cgpu->status == LIFE_SICK)
|
|
|
- status = (char *)SICK;
|
|
|
- else if (cgpu->status == LIFE_NOSTART)
|
|
|
- status = (char *)NOSTART;
|
|
|
- else
|
|
|
- status = (char *)ALIVE;
|
|
|
+ if (isjson)
|
|
|
+ tailsprintf(buf, "}");
|
|
|
+ else
|
|
|
+ tailsprintf(buf, "%c", SEPARATOR);
|
|
|
+}
|
|
|
|
|
|
- if (isjson)
|
|
|
- sprintf(buf, "{\"PGA\":%d,\"Name\":\"%s\",\"ID\":%d,\"Enabled\":\"%s\",\"Status\":\"%s\",\"Temperature\":%.2f,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Last Share Pool\":%d,\"Last Share Time\":%lu,\"Total MH\":%.4f}",
|
|
|
- pga, cgpu->api->name, cgpu->device_id,
|
|
|
- enabled, status, cgpu->temp,
|
|
|
- cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors, cgpu->utility,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes);
|
|
|
- else
|
|
|
- sprintf(buf, "PGA=%d,Name=%s,ID=%d,Enabled=%s,Status=%s,Temperature=%.2f,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Last Share Pool=%d,Last Share Time=%lu,Total MH=%.4f%c",
|
|
|
- pga, cgpu->api->name, cgpu->device_id,
|
|
|
- enabled, status, cgpu->temp,
|
|
|
- cgpu->total_mhashes / total_secs, opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected, cgpu->hw_errors, cgpu->utility,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes, SEPARATOR);
|
|
|
+static void gpustatus(int gpu, bool isjson)
|
|
|
+{
|
|
|
+ if (gpu < 0 || gpu >= nDevs)
|
|
|
+ return;
|
|
|
+ devstatus_an(io_buffer, &gpus[gpu], isjson);
|
|
|
+}
|
|
|
|
|
|
- strcat(io_buffer, buf);
|
|
|
- }
|
|
|
+static void pgastatus(int pga, bool isjson)
|
|
|
+{
|
|
|
+ int dev = pgadevice(pga);
|
|
|
+ if (dev < 0) // Should never happen
|
|
|
+ return;
|
|
|
+ devstatus_an(io_buffer, devices[dev], isjson);
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
-#ifdef WANT_CPUMINE
|
|
|
static void cpustatus(int cpu, bool isjson)
|
|
|
{
|
|
|
- char buf[BUFSIZ];
|
|
|
-
|
|
|
- if (opt_n_threads > 0 && cpu >= 0 && cpu < num_processors) {
|
|
|
- struct cgpu_info *cgpu = &cpus[cpu];
|
|
|
-
|
|
|
- cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
|
-
|
|
|
- if (isjson)
|
|
|
- sprintf(buf, "{\"CPU\":%d,\"MHS av\":%.2f,\"MHS %ds\":%.2f,\"Accepted\":%d,\"Rejected\":%d,\"Utility\":%.2f,\"Last Share Pool\":%d,\"Last Share Time\":%lu,\"Total MH\":%.4f}",
|
|
|
- cpu, cgpu->total_mhashes / total_secs,
|
|
|
- opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected,
|
|
|
- cgpu->utility,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes);
|
|
|
- else
|
|
|
- sprintf(buf, "CPU=%d,MHS av=%.2f,MHS %ds=%.2f,Accepted=%d,Rejected=%d,Utility=%.2f,Last Share Pool=%d,Last Share Time=%lu,Total MH=%.4f%c",
|
|
|
- cpu, cgpu->total_mhashes / total_secs,
|
|
|
- opt_log_interval, cgpu->rolling,
|
|
|
- cgpu->accepted, cgpu->rejected,
|
|
|
- cgpu->utility,
|
|
|
- ((unsigned long)(cgpu->last_share_pool_time) > 0) ? cgpu->last_share_pool : -1,
|
|
|
- (unsigned long)(cgpu->last_share_pool_time), cgpu->total_mhashes, SEPARATOR);
|
|
|
-
|
|
|
- strcat(io_buffer, buf);
|
|
|
- }
|
|
|
+ if (opt_n_threads <= 0 || cpu < 0 || cpu >= num_processors)
|
|
|
+ return;
|
|
|
+ devstatus_an(io_buffer, &cpus[cpu], isjson);
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
static void devstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
|
|
|
{
|
|
|
int devcount = 0;
|
|
|
int i;
|
|
|
|
|
|
- if (nDevs == 0 && opt_n_threads == 0) {
|
|
|
+ if (total_devices == 0) {
|
|
|
strcpy(io_buffer, message(MSG_NODEVS, 0, NULL, isjson));
|
|
|
return;
|
|
|
}
|