mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[#1041] Checkpoint: moved uptime/reload to libprocess
This commit is contained in:
committed by
Marcin Siodelski
parent
f3f5125e3b
commit
300c6809dc
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
"support": [
|
"support": [
|
||||||
"kea-dhcp4",
|
"kea-dhcp4",
|
||||||
"kea-dhcp6"
|
"kea-dhcp6",
|
||||||
|
"kea-dhcp-ddns",
|
||||||
|
"kea-ctrl-agent"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -619,6 +619,8 @@ The D2 server supports only a subset of DHCPv4 / DHCPv6 server commands:
|
|||||||
|
|
||||||
- shutdown
|
- shutdown
|
||||||
|
|
||||||
|
- status-get
|
||||||
|
|
||||||
- version-get
|
- version-get
|
||||||
|
|
||||||
.. _agent-commands:
|
.. _agent-commands:
|
||||||
@@ -646,4 +648,6 @@ commands are handled by the CA and they relate to the CA process itself:
|
|||||||
|
|
||||||
- shutdown
|
- shutdown
|
||||||
|
|
||||||
|
- status-get
|
||||||
|
|
||||||
- version-get
|
- version-get
|
||||||
|
@@ -295,6 +295,7 @@ The D2 server supports the following operational commands:
|
|||||||
- config-write
|
- config-write
|
||||||
- list-commands
|
- list-commands
|
||||||
- shutdown
|
- shutdown
|
||||||
|
- status-get
|
||||||
- version-get
|
- version-get
|
||||||
|
|
||||||
.. _d2-tsig-key-list-config:
|
.. _d2-tsig-key-list-config:
|
||||||
|
@@ -5536,6 +5536,7 @@ The DHCPv4 server supports the following operational commands:
|
|||||||
- leases-reclaim
|
- leases-reclaim
|
||||||
- list-commands
|
- list-commands
|
||||||
- shutdown
|
- shutdown
|
||||||
|
- status-get
|
||||||
- version-get
|
- version-get
|
||||||
|
|
||||||
as described in :ref:`commands-common`. In addition, it supports the
|
as described in :ref:`commands-common`. In addition, it supports the
|
||||||
|
@@ -5548,6 +5548,7 @@ The DHCPv6 server supports the following operational commands:
|
|||||||
- leases-reclaim
|
- leases-reclaim
|
||||||
- list-commands
|
- list-commands
|
||||||
- shutdown
|
- shutdown
|
||||||
|
- status-get
|
||||||
- version-get
|
- version-get
|
||||||
|
|
||||||
as described in :ref:`commands-common`. In addition, it supports the
|
as described in :ref:`commands-common`. In addition, it supports the
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
#include <database/database_connection.h>
|
#include <database/database_connection.h>
|
||||||
#include <dhcpsrv/timer_mgr.h>
|
#include <dhcpsrv/timer_mgr.h>
|
||||||
#include <dhcp4/dhcp4_srv.h>
|
#include <dhcp4/dhcp4_srv.h>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace dhcp {
|
namespace dhcp {
|
||||||
@@ -122,6 +121,7 @@ public:
|
|||||||
return (server_);
|
return (server_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief Callback that will be called from iface_mgr when data
|
/// @brief Callback that will be called from iface_mgr when data
|
||||||
/// is received over control socket.
|
/// is received over control socket.
|
||||||
@@ -427,9 +427,6 @@ private:
|
|||||||
/// Shared pointer to the instance of timer @c TimerMgr is held here to
|
/// Shared pointer to the instance of timer @c TimerMgr is held here to
|
||||||
/// make sure that the @c TimerMgr outlives instance of this class.
|
/// make sure that the @c TimerMgr outlives instance of this class.
|
||||||
TimerMgrPtr timer_mgr_;
|
TimerMgrPtr timer_mgr_;
|
||||||
|
|
||||||
/// @brief Timestamp of the start of the server.
|
|
||||||
boost::posix_time::ptime start_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace isc::dhcp
|
}; // namespace isc::dhcp
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
#include <database/database_connection.h>
|
#include <database/database_connection.h>
|
||||||
#include <dhcpsrv/timer_mgr.h>
|
#include <dhcpsrv/timer_mgr.h>
|
||||||
#include <dhcp6/dhcp6_srv.h>
|
#include <dhcp6/dhcp6_srv.h>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace dhcp {
|
namespace dhcp {
|
||||||
@@ -425,9 +424,6 @@ private:
|
|||||||
/// Shared pointer to the instance of timer @c TimerMgr is held here to
|
/// Shared pointer to the instance of timer @c TimerMgr is held here to
|
||||||
/// make sure that the @c TimerMgr outlives instance of this class.
|
/// make sure that the @c TimerMgr outlives instance of this class.
|
||||||
TimerMgrPtr timer_mgr_;
|
TimerMgrPtr timer_mgr_;
|
||||||
|
|
||||||
/// @brief Timestamp of the start of the server.
|
|
||||||
boost::posix_time::ptime start_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace isc::dhcp
|
}; // namespace isc::dhcp
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#include <cc/user_context.h>
|
#include <cc/user_context.h>
|
||||||
#include <cc/simple_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -680,18 +679,6 @@ public:
|
|||||||
/// @param srv_elem server top level map to alter
|
/// @param srv_elem server top level map to alter
|
||||||
static void moveDdnsParams(isc::data::ElementPtr srv_elem);
|
static void moveDdnsParams(isc::data::ElementPtr srv_elem);
|
||||||
|
|
||||||
/// @brief Returns the last commit timestamp.
|
|
||||||
/// @return the last commit timestamp.
|
|
||||||
boost::posix_time::ptime getLastCommitTime() const {
|
|
||||||
return (last_commit_time_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Sets the last commit timestamp.
|
|
||||||
/// @param last_commit_time last commit timestamp.
|
|
||||||
void setLastCommitTime(const boost::posix_time::ptime& last_commit_time) {
|
|
||||||
last_commit_time_ = last_commit_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Unparse a configuration object
|
/// @brief Unparse a configuration object
|
||||||
///
|
///
|
||||||
/// @return a pointer to unparsed configuration
|
/// @return a pointer to unparsed configuration
|
||||||
@@ -845,9 +832,6 @@ private:
|
|||||||
|
|
||||||
/// @brief Pointer to the configuration consistency settings
|
/// @brief Pointer to the configuration consistency settings
|
||||||
CfgConsistencyPtr cfg_consist_;
|
CfgConsistencyPtr cfg_consist_;
|
||||||
|
|
||||||
/// @brief Stores the last commit timestamp.
|
|
||||||
boost::posix_time::ptime last_commit_time_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @name Pointers to the @c SrvConfig object.
|
/// @name Pointers to the @c SrvConfig object.
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <process/config_ctl_info.h>
|
#include <process/config_ctl_info.h>
|
||||||
#include <process/logging_info.h>
|
#include <process/logging_info.h>
|
||||||
#include <util/optional.h>
|
#include <util/optional.h>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace process {
|
namespace process {
|
||||||
@@ -134,6 +135,18 @@ public:
|
|||||||
return (server_tag_);
|
return (server_tag_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Returns the last commit timestamp.
|
||||||
|
/// @return the last commit timestamp.
|
||||||
|
boost::posix_time::ptime getLastCommitTime() const {
|
||||||
|
return (last_commit_time_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Sets the last commit timestamp.
|
||||||
|
/// @param last_commit_time last commit timestamp.
|
||||||
|
void setLastCommitTime(const boost::posix_time::ptime& last_commit_time) {
|
||||||
|
last_commit_time_ = last_commit_time;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @brief Copies the current configuration to a new configuration.
|
/// @brief Copies the current configuration to a new configuration.
|
||||||
///
|
///
|
||||||
@@ -154,6 +167,9 @@ private:
|
|||||||
|
|
||||||
/// @brief Logical name of the server
|
/// @brief Logical name of the server
|
||||||
util::Optional<std::string> server_tag_;
|
util::Optional<std::string> server_tag_;
|
||||||
|
|
||||||
|
/// @brief Stores the last commit timestamp.
|
||||||
|
boost::posix_time::ptime last_commit_time_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Non-const pointer to the @c ConfigBase.
|
/// @brief Non-const pointer to the @c ConfigBase.
|
||||||
|
@@ -99,6 +99,9 @@ DCfgMgrBase::simpleParseConfig(isc::data::ConstElementPtr config_set,
|
|||||||
post_config_cb();
|
post_config_cb();
|
||||||
}
|
}
|
||||||
LOG_INFO(dctl_logger, DCTL_CONFIG_COMPLETE).arg(getConfigSummary(0));
|
LOG_INFO(dctl_logger, DCTL_CONFIG_COMPLETE).arg(getConfigSummary(0));
|
||||||
|
// Set the last commit timestamp.
|
||||||
|
auto now = boost::posix_time::second_clock::universal_time();
|
||||||
|
context_->setLastCommitTime(now);
|
||||||
} else {
|
} else {
|
||||||
rollback = true;
|
rollback = true;
|
||||||
}
|
}
|
||||||
|
@@ -135,6 +135,9 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) {
|
|||||||
<< comment->stringValue());
|
<< comment->stringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note that the controller was started.
|
||||||
|
start_ = boost::posix_time::second_clock::universal_time();
|
||||||
|
|
||||||
// Everything is clear for launch, so start the application's
|
// Everything is clear for launch, so start the application's
|
||||||
// event loop.
|
// event loop.
|
||||||
try {
|
try {
|
||||||
@@ -636,6 +639,26 @@ DControllerBase::serverTagGetHandler(const std::string&, ConstElementPtr) {
|
|||||||
return (createAnswer(COMMAND_SUCCESS, response));
|
return (createAnswer(COMMAND_SUCCESS, response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConstElementPtr
|
||||||
|
DControllerBase::statusGetHandler(const std::string&, ConstElementPtr) {
|
||||||
|
ElementPtr status = Element::createMap();
|
||||||
|
status->set("pid", Element::create(static_cast<int>(getpid())));
|
||||||
|
|
||||||
|
auto now = boost::posix_time::second_clock::universal_time();
|
||||||
|
if (!start_.is_not_a_date_time()) {
|
||||||
|
auto uptime = now - start_;
|
||||||
|
status->set("uptime", Element::create(uptime.total_seconds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto last_commit = process_->getCfgMgr()->getContext()->getLastCommitTime();
|
||||||
|
if (!last_commit.is_not_a_date_time()) {
|
||||||
|
auto reload = now - last_commit;
|
||||||
|
status->set("reload", Element::create(reload.total_seconds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (createAnswer(COMMAND_SUCCESS, status));
|
||||||
|
}
|
||||||
|
|
||||||
ConstElementPtr
|
ConstElementPtr
|
||||||
DControllerBase::versionGetHandler(const std::string&, ConstElementPtr) {
|
DControllerBase::versionGetHandler(const std::string&, ConstElementPtr) {
|
||||||
ConstElementPtr answer;
|
ConstElementPtr answer;
|
||||||
|
@@ -123,9 +123,10 @@ public:
|
|||||||
/// 1. parse command line arguments
|
/// 1. parse command line arguments
|
||||||
/// 2. instantiate and initialize the application process
|
/// 2. instantiate and initialize the application process
|
||||||
/// 3. load the configuration file
|
/// 3. load the configuration file
|
||||||
/// 4. initialize signal handling
|
/// 4. record the start timestamp
|
||||||
/// 5. start and wait on the application process event loop
|
/// 5. initialize signal handling
|
||||||
/// 6. exit to the caller
|
/// 6. start and wait on the application process event loop
|
||||||
|
/// 7. exit to the caller
|
||||||
///
|
///
|
||||||
/// It is intended to be called from main() and be given the command line
|
/// It is intended to be called from main() and be given the command line
|
||||||
/// arguments.
|
/// arguments.
|
||||||
@@ -340,6 +341,19 @@ public:
|
|||||||
serverTagGetHandler(const std::string& command,
|
serverTagGetHandler(const std::string& command,
|
||||||
isc::data::ConstElementPtr args);
|
isc::data::ConstElementPtr args);
|
||||||
|
|
||||||
|
/// @brief handler for status-get command
|
||||||
|
///
|
||||||
|
/// This method handles the status-get command, which retrieves
|
||||||
|
/// the server process information i.e. the pid and returns it in
|
||||||
|
/// response.
|
||||||
|
///
|
||||||
|
/// @param command (ignored)
|
||||||
|
/// @param args (ignored)
|
||||||
|
/// @return process information wrapped in a response
|
||||||
|
isc::data::ConstElementPtr
|
||||||
|
statusGetHandler(const std::string& command,
|
||||||
|
isc::data::ConstElementPtr args);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @brief Virtual method that provides derivations the opportunity to
|
/// @brief Virtual method that provides derivations the opportunity to
|
||||||
/// support additional command line options. It is invoked during command
|
/// support additional command line options. It is invoked during command
|
||||||
|
@@ -134,7 +134,7 @@ public:
|
|||||||
/// Certainly once during process startup, and possibly later if the user
|
/// Certainly once during process startup, and possibly later if the user
|
||||||
/// alters configuration. This method must not throw, it should catch any
|
/// alters configuration. This method must not throw, it should catch any
|
||||||
/// processing errors and return a success or failure answer as described
|
/// processing errors and return a success or failure answer as described
|
||||||
/// below.
|
/// below. On success the last commit timestamp must be updated.
|
||||||
///
|
///
|
||||||
/// @param config_set a new configuration (JSON) for the process
|
/// @param config_set a new configuration (JSON) for the process
|
||||||
/// @param check_only true if configuration is to be verified only, not applied
|
/// @param check_only true if configuration is to be verified only, not applied
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <util/pid_file.h>
|
#include <util/pid_file.h>
|
||||||
#include <util/signal_set.h>
|
#include <util/signal_set.h>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
@@ -260,6 +261,9 @@ protected:
|
|||||||
/// @brief Manufacture the pid file name
|
/// @brief Manufacture the pid file name
|
||||||
std::string makePIDFileName() const;
|
std::string makePIDFileName() const;
|
||||||
|
|
||||||
|
/// @brief Timestamp of the start of the daemon.
|
||||||
|
boost::posix_time::ptime start_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief Config file name or empty if config file not used.
|
/// @brief Config file name or empty if config file not used.
|
||||||
std::string config_file_;
|
std::string config_file_;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
Reference in New Issue
Block a user