Browse Source

Log combined per worker stats in a workers subdirectory

master
Con Kolivas 10 years ago
parent
commit
87336835f6
  1. 6
      src/ckpool.c
  2. 29
      src/stratifier.c

6
src/ckpool.c

@ -1259,6 +1259,12 @@ int main(int argc, char **argv)
if (ret && errno != EEXIST) if (ret && errno != EEXIST)
quit(1, "Failed to make log directory %s", ckp.logdir); quit(1, "Failed to make log directory %s", ckp.logdir);
/* Create the workers logdir */
sprintf(buf, "%s/workers", ckp.logdir);
ret = mkdir(buf, 0750);
if (ret && errno != EEXIST)
quit(1, "Failed to make workers log directory %s", buf);
/* Create the user logdir */ /* Create the user logdir */
sprintf(buf, "%s/users", ckp.logdir); sprintf(buf, "%s/users", ckp.logdir);
ret = mkdir(buf, 0750); ret = mkdir(buf, 0750);

29
src/stratifier.c

@ -228,6 +228,8 @@ static user_instance_t *user_instances;
/* Combined data from workers with the same workername */ /* Combined data from workers with the same workername */
struct worker_instance { struct worker_instance {
char *workername;
worker_instance_t *next; worker_instance_t *next;
worker_instance_t *prev; worker_instance_t *prev;
@ -1513,6 +1515,7 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client,
* same name */ * same name */
if (!client->worker_instance) { if (!client->worker_instance) {
client->worker_instance = ckzalloc(sizeof(worker_instance_t)); client->worker_instance = ckzalloc(sizeof(worker_instance_t));
client->worker_instance->workername = strdup(workername);
DL_APPEND(instance->worker_instances, client->worker_instance); DL_APPEND(instance->worker_instances, client->worker_instance);
} }
DL_APPEND(instance->instances, client); DL_APPEND(instance->instances, client);
@ -2910,6 +2913,32 @@ static void *statsupdate(void *arg)
decay_time(&worker->dsps60, 0, tdiff, 3600); decay_time(&worker->dsps60, 0, tdiff, 3600);
decay_time(&worker->dsps1440, 0, tdiff, 86400); decay_time(&worker->dsps1440, 0, tdiff, 86400);
} }
ghs = worker->dsps1 * nonces;
suffix_string(ghs, suffix1, 16, 0);
ghs = worker->dsps5 * nonces;
suffix_string(ghs, suffix5, 16, 0);
ghs = worker->dsps60 * nonces;
suffix_string(ghs, suffix60, 16, 0);
ghs = worker->dsps1440 * nonces;
suffix_string(ghs, suffix1440, 16, 0);
JSON_CPACK(val, "{ss,ss,ss,ss}",
"hashrate1m", suffix1,
"hashrate5m", suffix5,
"hashrate1hr", suffix60,
"hashrate1d", suffix1440);
snprintf(fname, 511, "%s/workers/%s", ckp->logdir, worker->workername);
fp = fopen(fname, "we");
if (unlikely(!fp)) {
LOGERR("Failed to fopen %s", fname);
continue;
}
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER);
fprintf(fp, "%s\n", s);
dealloc(s);
json_decref(val);
fclose(fp);
} }
/* Decay times per user */ /* Decay times per user */

Loading…
Cancel
Save