diff options
Diffstat (limited to 'src/rpc-server')
-rw-r--r-- | src/rpc-server/include/trex_rpc_server_api.h | 5 | ||||
-rw-r--r-- | src/rpc-server/src/commands/trex_rpc_cmd_general.cpp | 3 | ||||
-rw-r--r-- | src/rpc-server/src/trex_rpc_server.cpp | 14 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/rpc-server/include/trex_rpc_server_api.h b/src/rpc-server/include/trex_rpc_server_api.h index 5f567a5c..bb455be2 100644 --- a/src/rpc-server/include/trex_rpc_server_api.h +++ b/src/rpc-server/include/trex_rpc_server_api.h @@ -119,8 +119,13 @@ public: void start(); void stop(); + static const std::string &get_server_uptime() { + return s_server_uptime; + } + private: std::vector<TrexRpcServerInterface *> m_servers; + static const std::string s_server_uptime; }; #endif /* __TREX_RPC_SERVER_API_H__ */ diff --git a/src/rpc-server/src/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/src/commands/trex_rpc_cmd_general.cpp index 2be4a76f..581f3a02 100644 --- a/src/rpc-server/src/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/src/commands/trex_rpc_cmd_general.cpp @@ -20,6 +20,7 @@ limitations under the License. */ #include "trex_rpc_cmds.h" #include <../linux_dpdk/version.h> +#include <trex_rpc_server_api.h> using namespace std; @@ -41,7 +42,7 @@ TrexRpcCmdGetStatus::_run(const Json::Value ¶ms, Json::Value &result) { section["general"]["build_date"] = get_build_date(); section["general"]["build_time"] = get_build_time(); section["general"]["version_user"] = VERSION_USER; - + section["general"]["uptime"] = TrexRpcServer::get_server_uptime(); return (RPC_CMD_OK); } diff --git a/src/rpc-server/src/trex_rpc_server.cpp b/src/rpc-server/src/trex_rpc_server.cpp index 34e60c96..17eeec6d 100644 --- a/src/rpc-server/src/trex_rpc_server.cpp +++ b/src/rpc-server/src/trex_rpc_server.cpp @@ -25,7 +25,6 @@ limitations under the License. #include <zmq.h> #include <sstream> - /************** RPC server interface ***************/ TrexRpcServerInterface::TrexRpcServerInterface(const TrexRpcServerConfig &cfg) : m_cfg(cfg) { @@ -70,6 +69,19 @@ bool TrexRpcServerInterface::is_running() { /************** RPC server *************/ +static const std::string +get_current_date_time() { + time_t now = time(0); + struct tm tstruct; + char buf[80]; + tstruct = *localtime(&now); + strftime(buf, sizeof(buf), "%d-%b-%Y / %X", &tstruct); + + return buf; +} + +const std::string TrexRpcServer::s_server_uptime = get_current_date_time(); + TrexRpcServer::TrexRpcServer(const TrexRpcServerConfig &req_resp_cfg) { /* add the request response server */ |