From c90cfc0beeb70c6aeb3aa2cb4f1a72f49fb93e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 14 Apr 2018 06:12:54 +0300 Subject: [PATCH] MXS-1782: Add missing thread information The load averages and open/total file descriptor counts were missing from the REST API. --- Documentation/REST-API/Resources-MaxScale.md | 45 +++++++++++++++++--- server/core/worker.cc | 12 ++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Documentation/REST-API/Resources-MaxScale.md b/Documentation/REST-API/Resources-MaxScale.md index f2fee0fce..35ca0a076 100644 --- a/Documentation/REST-API/Resources-MaxScale.md +++ b/Documentation/REST-API/Resources-MaxScale.md @@ -124,7 +124,14 @@ GET /v1/maxscale/threads/:id "event_queue_length": 1, "max_event_queue_length": 1, "max_exec_time": 0, - "max_queue_time": 0 + "max_queue_time": 0, + "current_descriptors": 1, + "total_descriptors": 1, + "load": { + "last_second": 0, + "last_minute": 0, + "last_hour": 0 + } } }, "links": { @@ -166,7 +173,14 @@ GET /v1/maxscale/threads "event_queue_length": 1, "max_event_queue_length": 1, "max_exec_time": 0, - "max_queue_time": 0 + "max_queue_time": 0, + "current_descriptors": 1, + "total_descriptors": 1, + "load": { + "last_second": 0, + "last_minute": 0, + "last_hour": 0 + } } }, "links": { @@ -187,7 +201,14 @@ GET /v1/maxscale/threads "event_queue_length": 1, "max_event_queue_length": 1, "max_exec_time": 0, - "max_queue_time": 0 + "max_queue_time": 0, + "current_descriptors": 1, + "total_descriptors": 1, + "load": { + "last_second": 0, + "last_minute": 0, + "last_hour": 0 + } } }, "links": { @@ -208,7 +229,14 @@ GET /v1/maxscale/threads "event_queue_length": 1, "max_event_queue_length": 1, "max_exec_time": 0, - "max_queue_time": 0 + "max_queue_time": 0, + "current_descriptors": 1, + "total_descriptors": 1, + "load": { + "last_second": 0, + "last_minute": 0, + "last_hour": 0 + } } }, "links": { @@ -229,7 +257,14 @@ GET /v1/maxscale/threads "event_queue_length": 1, "max_event_queue_length": 1, "max_exec_time": 0, - "max_queue_time": 0 + "max_queue_time": 0, + "current_descriptors": 1, + "total_descriptors": 1, + "load": { + "last_second": 0, + "last_minute": 0, + "last_hour": 0 + } } }, "links": { diff --git a/server/core/worker.cc b/server/core/worker.cc index 5bd87526b..c8f380e9e 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -973,6 +973,18 @@ public: json_object_set_new(pStats, "max_exec_time", json_integer(s.maxexectime)); json_object_set_new(pStats, "max_queue_time", json_integer(s.maxqtime)); + uint32_t nCurrent; + uint64_t nTotal; + worker.get_descriptor_counts(&nCurrent, &nTotal); + json_object_set_new(pStats, "current_descriptors", json_integer(nCurrent)); + json_object_set_new(pStats, "total_descriptors", json_integer(nTotal)); + + json_t* load = json_object(); + json_object_set_new(load, "last_second", json_integer(worker.load(Worker::Load::ONE_SECOND))); + json_object_set_new(load, "last_minute", json_integer(worker.load(Worker::Load::ONE_MINUTE))); + json_object_set_new(load, "last_hour", json_integer(worker.load(Worker::Load::ONE_HOUR))); + json_object_set_new(pStats, "load", load); + json_t* pAttr = json_object(); json_object_set_new(pAttr, "stats", pStats);