From 1f89a868923a53a7eb5265a54a55a594029774ed Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 24 Oct 2019 11:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EgetWorkThreadsLoad=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 3209b439..6a040011 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -45,6 +45,7 @@ #include "Util/MD5.h" #include "WebApi.h" #include "WebHook.h" +#include "Thread/WorkThreadPool.h" #if !defined(_WIN32) #include "FFmpegSource.h" @@ -281,6 +282,23 @@ void installWebApi() { }); }); + //获取后台工作线程负载 + //测试url http://127.0.0.1/index/api/getWorkThreadsLoad + API_REGIST_INVOKER(api, getWorkThreadsLoad, { + WorkThreadPool::Instance().getExecutorDelay([invoker, headerOut](const vector &vecDelay) { + Value val; + auto vec = WorkThreadPool::Instance().getExecutorLoad(); + int i = 0; + for (auto load : vec) { + Value obj(objectValue); + obj["load"] = load; + obj["delay"] = vecDelay[i++]; + val["data"].append(obj); + } + invoker("200 OK", headerOut, val.toStyledString()); + }); + }); + //获取服务器配置 //测试url http://127.0.0.1/index/api/getServerConfig API_REGIST(api, getServerConfig, {