summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/commands/trex_rpc_cmd_general.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 68ea2587..080856c2 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -92,6 +92,32 @@ TrexRpcCmdPing::_run(const Json::Value &params, Json::Value &result) {
}
/**
+ * shutdown command
+ */
+trex_rpc_cmd_rc_e
+TrexRpcCmdShutdown::_run(const Json::Value &params, Json::Value &result) {
+
+ const string &user = parse_string(params, "user", result);
+ bool force = parse_bool(params, "force", result);
+
+ /* verify every port is either free or owned by the issuer */
+ for (auto port : get_stateless_obj()->get_port_list()) {
+ TrexPortOwner &owner = port->get_owner();
+ if ( (!owner.is_free()) && (!owner.is_owned_by(user)) && !force) {
+ std::stringstream ss;
+ ss << "port " << int(port->get_port_id()) << " is owned by '" << owner.get_name() << "' - specify 'force' for override";
+ generate_execute_err(result, ss.str());
+ }
+ }
+
+ /* signal that we got a shutdown request */
+ get_stateless_obj()->get_platform_api()->mark_for_shutdown();
+
+ result["result"] = Json::objectValue;
+ return (TREX_RPC_CMD_OK);
+}
+
+/**
* query command
*/
trex_rpc_cmd_rc_e
@@ -157,6 +183,29 @@ TrexRpcCmdGetActivePGIds::_run(const Json::Value &params, Json::Value &result) {
return (TREX_RPC_CMD_OK);
}
+// get utilization of CPU per thread with up to 20 latest values + mbufs per socket
+trex_rpc_cmd_rc_e
+TrexRpcCmdGetUtilization::_run(const Json::Value &params, Json::Value &result) {
+ cpu_util_full_t cpu_util_full;
+
+ Json::Value &section = result["result"];
+
+ 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["cpu"][thread_id].append(cpu_util_full[thread_id][history_id]);
+ }
+ }
+ return (TREX_RPC_CMD_OK);
+}
+
/**
* get the CPU model
*