// information) with each lease.
"store-extended-info": true,
+ // Statistics keep some samples per observation point.
+ // There are two default values: maximum count and maximum age.
+ // Set the maximum count to zero disables it.
+ "statistic-default-sample-count": 0,
+
+ // When the maximum count the maximum age (in seconds) applies.
+ "statistic-default-sample-age": 60,
+
// Governs how the Kea DHCPv4 server should deal with the invalid
// data received from the client.
"sanity-checks": {
// information) with each lease.
"store-extended-info": true,
+ // Statistics keep some samples per observation point.
+ // There are two default values: maximum count and maximum age.
+ // Set the maximum count to zero disables it.
+ "statistic-default-sample-count": 0,
+
+ // When the maximum count the maximum age (in seconds) applies.
+ "statistic-default-sample-age": 60,
+
// Governs how the Kea DHCPv6 server should deal with the invalid
// data received from the client.
"sanity-checks": {
(config_pair.first == "ddns-replace-client-name") ||
(config_pair.first == "ddns-generated-prefix") ||
(config_pair.first == "ddns-qualifying-suffix") ||
- (config_pair.first == "store-extended-info")) {
+ (config_pair.first == "store-extended-info") ||
+ (config_pair.first == "statistic-default-sample-count") ||
+ (config_pair.first == "statistic-default-sample-age")) {
CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
config_pair.second);
continue;
(config_pair.first == "ddns-replace-client-name") ||
(config_pair.first == "ddns-generated-prefix") ||
(config_pair.first == "ddns-qualifying-suffix") ||
- (config_pair.first == "store-extended-info")) {
+ (config_pair.first == "store-extended-info") ||
+ (config_pair.first == "statistic-default-sample-count") ||
+ (config_pair.first == "statistic-default-sample-age")) {
CfgMgr::instance().getStagingCfg()->addConfiguredGlobal(config_pair.first,
config_pair.second);
continue;
/// list and map types for entries.
/// Order follows global_param rule in bison grammar.
const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
- { "valid-lifetime", Element::integer },
- { "min-valid-lifetime", Element::integer },
- { "max-valid-lifetime", Element::integer },
- { "renew-timer", Element::integer },
- { "rebind-timer", Element::integer },
- { "decline-probation-period", Element::integer },
- { "subnet4", Element::list },
- { "shared-networks", Element::list },
- { "interfaces-config", Element::map },
- { "lease-database", Element::map },
- { "hosts-database", Element::map },
- { "hosts-databases", Element::list },
- { "host-reservation-identifiers", Element::list },
- { "client-classes", Element::list },
- { "option-def", Element::list },
- { "option-data", Element::list },
- { "hooks-libraries", Element::list },
- { "expired-leases-processing", Element::map },
- { "dhcp4o6-port", Element::integer },
- { "control-socket", Element::map },
- { "dhcp-queue-control", Element::map },
- { "dhcp-ddns", Element::map },
- { "echo-client-id", Element::boolean },
- { "match-client-id", Element::boolean },
- { "authoritative", Element::boolean },
- { "next-server", Element::string },
- { "server-hostname", Element::string },
- { "boot-file-name", Element::string },
- { "user-context", Element::map },
- { "comment", Element::string },
- { "sanity-checks", Element::map },
- { "reservations", Element::list },
- { "config-control", Element::map },
- { "server-tag", Element::string },
- { "reservation-mode", Element::string },
- { "calculate-tee-times", Element::boolean },
- { "t1-percent", Element::real },
- { "t2-percent", Element::real },
- { "loggers", Element::list },
- { "hostname-char-set", Element::string },
- { "hostname-char-replacement", Element::string },
- { "ddns-send-updates", Element::boolean },
- { "ddns-override-no-update", Element::boolean },
- { "ddns-override-client-update", Element::boolean },
- { "ddns-replace-client-name", Element::string },
- { "ddns-generated-prefix", Element::string },
- { "ddns-qualifying-suffix", Element::string },
- { "store-extended-info", Element::boolean }
+ { "valid-lifetime", Element::integer },
+ { "min-valid-lifetime", Element::integer },
+ { "max-valid-lifetime", Element::integer },
+ { "renew-timer", Element::integer },
+ { "rebind-timer", Element::integer },
+ { "decline-probation-period", Element::integer },
+ { "subnet4", Element::list },
+ { "shared-networks", Element::list },
+ { "interfaces-config", Element::map },
+ { "lease-database", Element::map },
+ { "hosts-database", Element::map },
+ { "hosts-databases", Element::list },
+ { "host-reservation-identifiers", Element::list },
+ { "client-classes", Element::list },
+ { "option-def", Element::list },
+ { "option-data", Element::list },
+ { "hooks-libraries", Element::list },
+ { "expired-leases-processing", Element::map },
+ { "dhcp4o6-port", Element::integer },
+ { "control-socket", Element::map },
+ { "dhcp-queue-control", Element::map },
+ { "dhcp-ddns", Element::map },
+ { "echo-client-id", Element::boolean },
+ { "match-client-id", Element::boolean },
+ { "authoritative", Element::boolean },
+ { "next-server", Element::string },
+ { "server-hostname", Element::string },
+ { "boot-file-name", Element::string },
+ { "user-context", Element::map },
+ { "comment", Element::string },
+ { "sanity-checks", Element::map },
+ { "reservations", Element::list },
+ { "config-control", Element::map },
+ { "server-tag", Element::string },
+ { "reservation-mode", Element::string },
+ { "calculate-tee-times", Element::boolean },
+ { "t1-percent", Element::real },
+ { "t2-percent", Element::real },
+ { "loggers", Element::list },
+ { "hostname-char-set", Element::string },
+ { "hostname-char-replacement", Element::string },
+ { "ddns-send-updates", Element::boolean },
+ { "ddns-override-no-update", Element::boolean },
+ { "ddns-override-client-update", Element::boolean },
+ { "ddns-replace-client-name", Element::string },
+ { "ddns-generated-prefix", Element::string },
+ { "ddns-qualifying-suffix", Element::string },
+ { "store-extended-info", Element::boolean },
+ { "statistic-default-sample-count", Element::integer },
+ { "statistic-default-sample-age", Element::integer }
};
/// @brief This table defines default global values for DHCPv4
{ "ddns-qualifying-suffix", Element::string, "" },
{ "hostname-char-set", Element::string, "[^A-Za-z0-9.-]" },
{ "hostname-char-replacement", Element::string, "" },
- { "store-extended-info", Element::boolean, "false" }
+ { "store-extended-info", Element::boolean, "false" },
+ { "statistic-default-sample-count", Element::integer, "20" },
+ { "statistic-default-sample-age", Element::integer, "0" }
};
/// @brief This table defines all option definition parameters.
/// list and map types for entries.
/// Order follows global_param rule in bison grammar.
const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
- { "data-directory", Element::string },
- { "preferred-lifetime", Element::integer },
- { "min-preferred-lifetime", Element::integer },
- { "max-preferred-lifetime", Element::integer },
- { "valid-lifetime", Element::integer },
- { "min-valid-lifetime", Element::integer },
- { "max-valid-lifetime", Element::integer },
- { "renew-timer", Element::integer },
- { "rebind-timer", Element::integer },
- { "decline-probation-period", Element::integer },
- { "subnet6", Element::list },
- { "shared-networks", Element::list },
- { "interfaces-config", Element::map },
- { "lease-database", Element::map },
- { "hosts-database", Element::map },
- { "hosts-databases", Element::list },
- { "mac-sources", Element::list },
- { "relay-supplied-options", Element::list },
- { "host-reservation-identifiers", Element::list },
- { "client-classes", Element::list },
- { "option-def", Element::list },
- { "option-data", Element::list },
- { "hooks-libraries", Element::list },
- { "expired-leases-processing", Element::map },
- { "server-id", Element::map },
- { "dhcp4o6-port", Element::integer },
- { "control-socket", Element::map },
- { "dhcp-queue-control", Element::map },
- { "dhcp-ddns", Element::map },
- { "user-context", Element::map },
- { "comment", Element::string },
- { "sanity-checks", Element::map },
- { "reservations", Element::list },
- { "config-control", Element::map },
- { "server-tag", Element::string },
- { "reservation-mode", Element::string },
- { "calculate-tee-times", Element::boolean },
- { "t1-percent", Element::real },
- { "t2-percent", Element::real },
- { "loggers", Element::list },
- { "hostname-char-set", Element::string },
- { "hostname-char-replacement", Element::string },
- { "ddns-send-updates", Element::boolean },
- { "ddns-override-no-update", Element::boolean },
- { "ddns-override-client-update", Element::boolean },
- { "ddns-replace-client-name", Element::string },
- { "ddns-generated-prefix", Element::string },
- { "ddns-qualifying-suffix", Element::string },
- { "store-extended-info", Element::boolean }
+ { "data-directory", Element::string },
+ { "preferred-lifetime", Element::integer },
+ { "min-preferred-lifetime", Element::integer },
+ { "max-preferred-lifetime", Element::integer },
+ { "valid-lifetime", Element::integer },
+ { "min-valid-lifetime", Element::integer },
+ { "max-valid-lifetime", Element::integer },
+ { "renew-timer", Element::integer },
+ { "rebind-timer", Element::integer },
+ { "decline-probation-period", Element::integer },
+ { "subnet6", Element::list },
+ { "shared-networks", Element::list },
+ { "interfaces-config", Element::map },
+ { "lease-database", Element::map },
+ { "hosts-database", Element::map },
+ { "hosts-databases", Element::list },
+ { "mac-sources", Element::list },
+ { "relay-supplied-options", Element::list },
+ { "host-reservation-identifiers", Element::list },
+ { "client-classes", Element::list },
+ { "option-def", Element::list },
+ { "option-data", Element::list },
+ { "hooks-libraries", Element::list },
+ { "expired-leases-processing", Element::map },
+ { "server-id", Element::map },
+ { "dhcp4o6-port", Element::integer },
+ { "control-socket", Element::map },
+ { "dhcp-queue-control", Element::map },
+ { "dhcp-ddns", Element::map },
+ { "user-context", Element::map },
+ { "comment", Element::string },
+ { "sanity-checks", Element::map },
+ { "reservations", Element::list },
+ { "config-control", Element::map },
+ { "server-tag", Element::string },
+ { "reservation-mode", Element::string },
+ { "calculate-tee-times", Element::boolean },
+ { "t1-percent", Element::real },
+ { "t2-percent", Element::real },
+ { "loggers", Element::list },
+ { "hostname-char-set", Element::string },
+ { "hostname-char-replacement", Element::string },
+ { "ddns-send-updates", Element::boolean },
+ { "ddns-override-no-update", Element::boolean },
+ { "ddns-override-client-update", Element::boolean },
+ { "ddns-replace-client-name", Element::string },
+ { "ddns-generated-prefix", Element::string },
+ { "ddns-qualifying-suffix", Element::string },
+ { "store-extended-info", Element::boolean },
+ { "statistic-default-sample-count", Element::integer },
+ { "statistic-default-sample-age", Element::integer }
};
/// @brief This table defines default global values for DHCPv6
{ "ddns-override-client-update", Element::boolean, "false" },
{ "ddns-replace-client-name", Element::string, "never" },
{ "ddns-generated-prefix", Element::string, "myhost" },
- { "ddns-qualifying-suffix", Element::string, "" },
- { "hostname-char-set", Element::string, "[^A-Za-z0-9.-]" },
- { "hostname-char-replacement", Element::string, "" },
- { "store-extended-info", Element::boolean, "false" }
-
+ { "ddns-qualifying-suffix", Element::string, "" },
+ { "hostname-char-set", Element::string, "[^A-Za-z0-9.-]" },
+ { "hostname-char-replacement", Element::string, "" },
+ { "store-extended-info", Element::boolean, "false" },
+ { "statistic-default-sample-count", Element::integer, "20" },
+ { "statistic-default-sample-age", Element::integer, "0" }
};
/// @brief This table defines all option definition parameters.
-// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
//
// 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
namespace isc {
namespace stats {
+std::pair<bool, uint32_t>
+Observation::default_max_sample_count_ = std::make_pair(true, 20);
+
+std::pair<bool, StatsDuration>
+Observation::default_max_sample_age_ =
+ std::make_pair(false, time_duration(0, 0, 0, 0));
+
Observation::Observation(const std::string& name, const int64_t value) :
- name_(name), type_(STAT_INTEGER) {
+ name_(name), type_(STAT_INTEGER),
+ max_sample_count_(default_max_sample_count_),
+ max_sample_age_(default_max_sample_age_) {
setValue(value);
}
Observation::Observation(const std::string& name, const double value) :
- name_(name), type_(STAT_FLOAT) {
+ name_(name), type_(STAT_FLOAT),
+ max_sample_count_(default_max_sample_count_),
+ max_sample_age_(default_max_sample_age_) {
setValue(value);
}
Observation::Observation(const std::string& name, const StatsDuration& value) :
- name_(name), type_(STAT_DURATION) {
+ name_(name), type_(STAT_DURATION),
+ max_sample_count_(default_max_sample_count_),
+ max_sample_age_(default_max_sample_age_) {
setValue(value);
}
Observation::Observation(const std::string& name, const std::string& value) :
- name_(name), type_(STAT_STRING) {
+ name_(name), type_(STAT_STRING),
+ max_sample_count_(default_max_sample_count_),
+ max_sample_age_(default_max_sample_age_) {
setValue(value);
}
<< typeToText(exp_type) << ", but the actual type is "
<< typeToText(type_));
}
+ // Should we refuse the max_samples = 0 value here?
// setting new value of max_sample_count_
max_sample_count_.first = true;
max_sample_count_.second = max_samples;
}
}
+void Observation::setMaxSampleAgeDefault(const StatsDuration& duration) {
+ // setting new value of default_max_sample_age_
+ default_max_sample_age_.second = duration;
+}
+
+void Observation::setMaxSampleCountDefault(uint32_t max_samples) {
+ if (max_samples == 0) {
+ // deactivating the default_max_sample_count_ limit
+ default_max_sample_count_.first = false;
+ default_max_sample_age_.first = true;
+ } else {
+ // setting new value of default_max_sample_count_
+ default_max_sample_count_.second = max_samples;
+ // deactivating the default_max_sample_age_ limit
+ default_max_sample_age_.first = false;
+ default_max_sample_count_.first = true;
+ }
+}
+
+const StatsDuration& Observation::getMaxSampleAgeDefault() {
+ return (default_max_sample_age_.second);
+}
+
+uint32_t Observation::getMaxSampleCountDefault() {
+ if (default_max_sample_count_.first) {
+ return (default_max_sample_count_.second);
+ } else {
+ return (0);
+ }
+}
+
std::string Observation::typeToText(Type type) {
std::stringstream tmp;
switch (type) {
};
}
-};
-};
+} // end of namespace stats
+} // end of namespace isc
-// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
//
// 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
///
/// Since Kea 1.6 multiple samples are stored for the same observation.
class Observation {
- public:
+public:
/// @brief Type of available statistics
///
/// setMaxSampleCount(100);
void setMaxSampleCount(uint32_t max_samples);
+ /// @brief Determines default maximum age of samples.
+ ///
+ /// @param duration determines default maximum age of samples.
+ static void setMaxSampleAgeDefault(const StatsDuration& duration);
+
+ /// @brief Determines default maximum count of samples.
+ ///
+ /// @param max_samples default maximum count of samples to keep.
+ /// (0 means to disable count limit and enable age limit)
+ static void setMaxSampleCountDefault(uint32_t max_samples);
+
+ /// @brief Get default maximum age of samples.
+ ///
+ /// @return default maximum age of samples.
+ static const StatsDuration& getMaxSampleAgeDefault();
+
+ /// @brief Get default maximum count of samples.
+ ///
+ /// @return max_samples default maximum count of samples to keep.
+ /// (0 means that count limit was disabled)
+ static uint32_t getMaxSampleCountDefault();
+
+ /// @
+
/// @brief Records absolute integer observation
///
/// @param value integer value observed
/// The bool value informs which limit
/// is available
/// True means active limit, false means inactive limit
+ std::pair<bool, uint32_t> max_sample_count_;
+
+ /// @brief Default maximum number of samples
+ ///
/// By default the MaxSampleCount is set to 20
/// and MaxSampleAge is disabled
- std::pair<bool, uint32_t> max_sample_count_ = std::make_pair(true, 20);
+ static std::pair<bool, uint32_t> default_max_sample_count_;
/// @brief Maximum timespan of samples
/// The limit is represented as a pair
/// The bool value informs which limit
/// is available
/// True means active limit, false means inactive limit
+ std::pair<bool, StatsDuration> max_sample_age_;
+
+ /// @brief Default maximum timespan of samples
+ ///
/// By default the MaxSampleCount is set to 20
/// and MaxSampleAge is disabled
- std::pair<bool, StatsDuration> max_sample_age_ = std::make_pair(false,
- boost::posix_time::time_duration(0, 0, 0, 0));
+ static std::pair<bool, StatsDuration> default_max_sample_age_;
/// @defgroup samples_storage Storage for supported observations
///
global_->setMaxSampleCountAll(max_samples);
}
+void
+StatsMgr::setMaxSampleAgeDefault(const StatsDuration& duration) {
+ if (MultiThreadingMgr::instance().getMode()) {
+ lock_guard<mutex> lock(*mutex_);
+ setMaxSampleAgeDefaultInternal(duration);
+ } else {
+ setMaxSampleAgeDefaultInternal(duration);
+ }
+}
+
+void
+StatsMgr::setMaxSampleAgeDefaultInternal(const StatsDuration& duration) {
+ Observation::setMaxSampleAgeDefault(duration);
+}
+
+void
+StatsMgr::setMaxSampleCountDefault(uint32_t max_samples) {
+ if (MultiThreadingMgr::instance().getMode()) {
+ lock_guard<mutex> lock(*mutex_);
+ setMaxSampleCountDefaultInternal(max_samples);
+ } else {
+ setMaxSampleCountDefaultInternal(max_samples);
+ }
+}
+
+void
+StatsMgr::setMaxSampleCountDefaultInternal(uint32_t max_samples) {
+ Observation::setMaxSampleCountDefault(max_samples);
+}
+
+const StatsDuration&
+StatsMgr::getMaxSampleAgeDefault() const {
+ if (MultiThreadingMgr::instance().getMode()) {
+ lock_guard<mutex> lock(*mutex_);
+ return (getMaxSampleAgeDefaultInternal());
+ } else {
+ return (getMaxSampleAgeDefaultInternal());
+ }
+}
+
+const StatsDuration&
+StatsMgr::getMaxSampleAgeDefaultInternal() const {
+ return (Observation::getMaxSampleAgeDefault());
+}
+
+uint32_t
+StatsMgr::getMaxSampleCountDefault() const {
+ if (MultiThreadingMgr::instance().getMode()) {
+ lock_guard<mutex> lock(*mutex_);
+ return (getMaxSampleCountDefaultInternal());
+ } else {
+ return (getMaxSampleCountDefaultInternal());
+ }
+}
+
+uint32_t
+StatsMgr::getMaxSampleCountDefaultInternal() const {
+ return (Observation::getMaxSampleCountDefault());
+}
+
bool
StatsMgr::reset(const string& name) {
if (MultiThreadingMgr::instance().getMode()) {
/// @param max_samples how many samples of a given statistic should be kept
void setMaxSampleCountAll(uint32_t max_samples);
+ /// @brief Set default duration limit.
+ ///
+ /// @param duration determines default maximum age of samples
+ void setMaxSampleAgeDefault(const StatsDuration& duration);
+
+ /// @brief Set default count limit.
+ ///
+ /// @param max_samples default maximum number of samples to keep
+ /// (0 means to disable count limit and enable age limit)
+ void setMaxSampleCountDefault(uint32_t max_samples);
+
+ /// @brief Get default duration limit.
+ ///
+ /// @return default maximum age of samples.
+ const StatsDuration& getMaxSampleAgeDefault() const;
+
+ /// @brief Get default count limit.
+ ///
+ /// @return default maximum number of samples to keep.
+ /// (0 means that count limit was disabled)
+ uint32_t getMaxSampleCountDefault() const;
+
/// @}
/// @defgroup consumer_methods Methods are used by data consumers.
/// @private
+ /// @brief Set default duration limit.
+ ///
+ /// Should be called in a thread safe context.
+ ///
+ /// @param duration determines default maximum age of samples
+ void setMaxSampleAgeDefaultInternal(const StatsDuration& duration);
+
+ /// @brief Set default count limit.
+ ///
+ /// Should be called in a thread safe context.
+ ///
+ /// @param max_samples default maximum number of samples to keep
+ /// (0 means to disable count limit and enable age limit)
+ void setMaxSampleCountDefaultInternal(uint32_t max_samples);
+
+ /// @private
+
+ /// @brief Get default duration limit.
+ ///
+ /// Should be called in a thread safe context.
+ ///
+ /// @return default maximum age of samples.
+ const StatsDuration& getMaxSampleAgeDefaultInternal() const;
+
+ /// @brief Get default count limit.
+ ///
+ /// Should be called in a thread safe context.
+ ///
+ /// @return default maximum number of samples to keep.
+ /// (0 means that count limit was disabled)
+ uint32_t getMaxSampleCountDefaultInternal() const;
+
+ /// @private
+
/// @brief Resets specified statistic.
///
/// Should be called in a thread safe context.