Commit 34e7cfb7 authored by Francis Dupont's avatar Francis Dupont Committed by Marcin Siodelski
Browse files

[#1041] Checkpoint: added uptime, last commit and HA to do

parent 82f58f88
......@@ -79,6 +79,9 @@ ControlledDhcpv4Srv* ControlledDhcpv4Srv::server_ = NULL;
void
ControlledDhcpv4Srv::init(const std::string& file_name) {
// Keep the call timestamp.
start_ = boost::posix_time::second_clock::universal_time();
// Configure the server using JSON file.
ConstElementPtr result = loadConfigFile(file_name);
int rcode;
......@@ -579,7 +582,14 @@ ControlledDhcpv4Srv::commandStatusGetHandler(const string&,
ConstElementPtr /*args*/) {
ElementPtr status = Element::createMap();
status->set("pid", Element::create(static_cast<int>(getpid())));
// TODO...
auto now = boost::posix_time::second_clock::universal_time();
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
// todo: duration since last config commit.
// todo: number of service threads.
return (createAnswer(0, status));
}
......
......@@ -14,6 +14,7 @@
#include <database/database_connection.h>
#include <dhcpsrv/timer_mgr.h>
#include <dhcp4/dhcp4_srv.h>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace isc {
namespace dhcp {
......@@ -121,7 +122,6 @@ public:
return (server_);
}
private:
/// @brief Callback that will be called from iface_mgr when data
/// is received over control socket.
......@@ -427,6 +427,9 @@ private:
/// Shared pointer to the instance of timer @c TimerMgr is held here to
/// make sure that the @c TimerMgr outlives instance of this class.
TimerMgrPtr timer_mgr_;
/// @brief Timestamp of the start of the server.
boost::posix_time::ptime start_;
};
}; // namespace isc::dhcp
......
......@@ -1037,6 +1037,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) {
sendUnixCommand("{ \"command\": \"status-get\" }", response);
EXPECT_TRUE(response.find("\"result\": 0") != string::npos);
EXPECT_TRUE(response.find("\"pid\": ") != string::npos);
EXPECT_TRUE(response.find("\"uptime\": ") != string::npos);
}
// This test verifies that the DHCP server handles config-backend-pull command
......
......@@ -163,6 +163,9 @@ ControlledDhcpv6Srv::loadConfigFile(const std::string& file_name) {
void
ControlledDhcpv6Srv::init(const std::string& file_name) {
// Keep the call timestamp.
start_ = boost::posix_time::second_clock::universal_time();
// Configure the server using JSON file.
ConstElementPtr result = loadConfigFile(file_name);
int rcode;
......@@ -579,7 +582,14 @@ ControlledDhcpv6Srv::commandStatusGetHandler(const string&,
ConstElementPtr /*args*/) {
ElementPtr status = Element::createMap();
status->set("pid", Element::create(static_cast<int>(getpid())));
// TODO...
auto now = boost::posix_time::second_clock::universal_time();
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
// todo: duration since last config commit.
// todo: number of service threads.
return (createAnswer(0, status));
}
......
......@@ -14,6 +14,7 @@
#include <database/database_connection.h>
#include <dhcpsrv/timer_mgr.h>
#include <dhcp6/dhcp6_srv.h>
#include <boost/date_time/posix_time/posix_time.hpp>
namespace isc {
namespace dhcp {
......@@ -424,6 +425,9 @@ private:
/// Shared pointer to the instance of timer @c TimerMgr is held here to
/// make sure that the @c TimerMgr outlives instance of this class.
TimerMgrPtr timer_mgr_;
/// @brief Timestamp of the start of the server.
boost::posix_time::ptime start_;
};
}; // namespace isc::dhcp
......
......@@ -929,6 +929,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) {
sendUnixCommand("{ \"command\": \"status-get\" }", response);
EXPECT_TRUE(response.find("\"result\": 0") != string::npos);
EXPECT_TRUE(response.find("\"pid\": ") != string::npos);
EXPECT_TRUE(response.find("\"uptime\": ") != string::npos);
}
// This test verifies that the DHCP server handles server-tag-get command
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment