Added global uptime and extended connection information for API.
This commit is contained in:
parent
a000544fdc
commit
ffb282a11a
6 changed files with 45 additions and 15 deletions
|
@ -38,6 +38,7 @@
|
|||
#include "api/v1/ApiRouter.h"
|
||||
#include "base/kernel/Base.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "common/crypto/keccak.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
|
@ -53,7 +54,8 @@ xmrig::Api::Api(Base *base) :
|
|||
m_base(base),
|
||||
m_id(),
|
||||
m_workerId(),
|
||||
m_httpd(nullptr)
|
||||
m_httpd(nullptr),
|
||||
m_timestamp(Chrono::steadyMSecs())
|
||||
{
|
||||
base->addListener(this);
|
||||
|
||||
|
@ -118,9 +120,12 @@ void xmrig::Api::exec(IApiRequest &request)
|
|||
using namespace rapidjson;
|
||||
|
||||
if (request.method() == IApiRequest::METHOD_GET && (request.url() == "/1/summary" || request.url() == "/api.json")) {
|
||||
auto &allocator = request.doc().GetAllocator();
|
||||
|
||||
request.accept();
|
||||
request.reply().AddMember("id", StringRef(m_id), request.doc().GetAllocator());
|
||||
request.reply().AddMember("worker_id", StringRef(m_workerId), request.doc().GetAllocator());;
|
||||
request.reply().AddMember("id", StringRef(m_id), allocator);
|
||||
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
|
||||
request.reply().AddMember("uptime", (Chrono::steadyMSecs() - m_timestamp) / 1000, allocator);
|
||||
}
|
||||
|
||||
for (IApiListener *listener : m_listeners) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue