From f2a3ee90c7cfb0df152e49b5573ad9231e90e97c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 12 Dec 2016 15:14:28 +1100 Subject: [PATCH] Implement get_uptime in stratifier. --- src/stratifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index 67e52290..93acf3d8 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -4082,6 +4082,17 @@ static void get_poolstats(sdata_t *sdata, int *sockd) _Close(sockd); } +static void get_uptime(sdata_t *sdata, int *sockd) +{ + time_t now_t = time(NULL); + int uptime = sdata->stats.start_time.tv_sec - now_t; + json_t *val; + + JSON_CPACK(val, "{si}", "uptime", uptime); + send_api_response(val, *sockd); + _Close(sockd); +} + static void srecv_process(ckpool_t *ckp, json_t *val); /* For emergency use only, flushes all pending ckdbq messages */ @@ -4215,6 +4226,10 @@ retry: user_clientinfo(sdata, buf + 7, &umsg->sockd); goto retry; } + if (cmdmatch(buf,"uptime")) { + get_uptime(sdata, &umsg->sockd); + goto retry; + } if (cmdmatch(buf, "wcinfo")) { worker_clientinfo(sdata, buf + 7, &umsg->sockd); goto retry;