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;