From 84fc182fd1021b0ad564478f284afff660a5b924 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 31 May 2016 13:57:12 +0300 Subject: add rpc command get_cpu_util_full to cpp --- src/rpc-server/commands/trex_rpc_cmd_general.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp') diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 68ea2587..541ff099 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -156,6 +156,26 @@ TrexRpcCmdGetActivePGIds::_run(const Json::Value ¶ms, Json::Value &result) { return (TREX_RPC_CMD_OK); } +/* + Get cpu utilization per thread with up to 20 latest values, Latest value will be first in array. + */ +trex_rpc_cmd_rc_e +TrexRpcCmdGetCpuUtilFull::_run(const Json::Value ¶ms, Json::Value &result) { + cpu_util_full_t cpu_util_full; + + Json::Value §ion = result["result"]; + section = Json::arrayValue; + + if (get_stateless_obj()->get_platform_api()->get_cpu_util_full(cpu_util_full) != 0) + return TREX_RPC_CMD_INTERNAL_ERR; + + for (int thread_id = 0; thread_id < cpu_util_full.size(); thread_id++) { + for (int history_id = 0; history_id < cpu_util_full[thread_id].size(); history_id++) { + section[thread_id].append(cpu_util_full.at(thread_id).at(history_id)); + } + } + return (TREX_RPC_CMD_OK); +} /** * get the CPU model -- cgit From 300ec24108211721d99ac9faf67fd1f91057b95b Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 2 Jun 2016 16:24:49 +0300 Subject: cpu utilization per thread + mbufs per socket + add in tui --- src/rpc-server/commands/trex_rpc_cmd_general.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp') diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 541ff099..37eafef8 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -156,22 +156,23 @@ TrexRpcCmdGetActivePGIds::_run(const Json::Value ¶ms, Json::Value &result) { return (TREX_RPC_CMD_OK); } -/* - Get cpu utilization per thread with up to 20 latest values, Latest value will be first in array. - */ + +// get utilization of CPU per thread with up to 20 latest values + mbufs per socket trex_rpc_cmd_rc_e -TrexRpcCmdGetCpuUtilFull::_run(const Json::Value ¶ms, Json::Value &result) { +TrexRpcCmdGetUtilization::_run(const Json::Value ¶ms, Json::Value &result) { cpu_util_full_t cpu_util_full; Json::Value §ion = result["result"]; - section = Json::arrayValue; + + if (get_stateless_obj()->get_platform_api()->get_mbuf_util(section) != 0) + return TREX_RPC_CMD_INTERNAL_ERR; if (get_stateless_obj()->get_platform_api()->get_cpu_util_full(cpu_util_full) != 0) return TREX_RPC_CMD_INTERNAL_ERR; for (int thread_id = 0; thread_id < cpu_util_full.size(); thread_id++) { for (int history_id = 0; history_id < cpu_util_full[thread_id].size(); history_id++) { - section[thread_id].append(cpu_util_full.at(thread_id).at(history_id)); + section["cpu"][thread_id].append(cpu_util_full.at(thread_id).at(history_id)); } } return (TREX_RPC_CMD_OK); -- cgit From 9b8f4554f63056ef214053b41ec31c3d3a75125b Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Sun, 5 Jun 2016 13:13:00 +0300 Subject: cpu utilization - syntax fixes --- src/rpc-server/commands/trex_rpc_cmd_general.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp') diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 37eafef8..27010e0e 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -164,15 +164,17 @@ TrexRpcCmdGetUtilization::_run(const Json::Value ¶ms, Json::Value &result) { Json::Value §ion = result["result"]; - if (get_stateless_obj()->get_platform_api()->get_mbuf_util(section) != 0) + if (get_stateless_obj()->get_platform_api()->get_mbuf_util(section) != 0) { return TREX_RPC_CMD_INTERNAL_ERR; + } - if (get_stateless_obj()->get_platform_api()->get_cpu_util_full(cpu_util_full) != 0) + if (get_stateless_obj()->get_platform_api()->get_cpu_util_full(cpu_util_full) != 0) { return TREX_RPC_CMD_INTERNAL_ERR; + } for (int thread_id = 0; thread_id < cpu_util_full.size(); thread_id++) { for (int history_id = 0; history_id < cpu_util_full[thread_id].size(); history_id++) { - section["cpu"][thread_id].append(cpu_util_full.at(thread_id).at(history_id)); + section["cpu"][thread_id].append(cpu_util_full[thread_id][history_id]); } } return (TREX_RPC_CMD_OK); -- cgit