Use normalize for load average values.

This commit is contained in:
XMRig 2019-12-04 10:25:26 +07:00
parent 901f1a7ab1
commit a4d35065d9
No known key found for this signature in database
GPG key ID: 446A53638BE94409
4 changed files with 26 additions and 11 deletions

View file

@ -31,10 +31,11 @@
#endif
#include "3rdparty/http-parser/http_parser.h"
#include "base/api/Api.h"
#include "3rdparty/http-parser/http_parser.h"
#include "base/api/interfaces/IApiListener.h"
#include "base/api/requests/HttpApiRequest.h"
#include "base/io/json/Json.h"
#include "base/kernel/Base.h"
#include "base/tools/Buffer.h"
#include "base/tools/Chrono.h"
@ -73,9 +74,10 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
double loadavg[3] = { 0.0 };
uv_loadavg(loadavg);
load_average.PushBack(loadavg[0], allocator);
load_average.PushBack(loadavg[1], allocator);
load_average.PushBack(loadavg[2], allocator);
for (double value : loadavg) {
load_average.PushBack(Json::normalize(value, true), allocator);
}
out.AddMember("memory", memory, allocator);
out.AddMember("load_average", load_average, allocator);
@ -182,6 +184,9 @@ void xmrig::Api::exec(IApiRequest &request)
# endif
# ifdef XMRIG_FEATURE_OPENCL
features.PushBack("opencl", allocator);
# endif
# ifdef XMRIG_FEATURE_CUDA
features.PushBack("cuda", allocator);
# endif
reply.AddMember("features", features, allocator);
}