-1737. [func] tmark
+1738. [func] fdupont
+ Added new global parameters statistic-default-sample-count and
+ statistic-default-sample-age to set the default values uses
+ a sample keeping limits in new statistics.
+ (Gitlab #1005)
+
+1737. [func] tmark
Added store-extended-info parameter to kea-dhcp4 and kea-dhcp6
which enables the storage of additional information per lease.
This has been added in anticipation of supporting LeaseQuery.
This section describes DHCPv4-specific statistics. For a general
overview and usage of statistics, see :ref:`stats`.
+Beginning with Kea 1.7.7 the DHCPv4 server provides two global
+parameters to control statistics default sample limits:
+
+- ``statistic-default-sample-count`` - determines the default maximum
+ number of samples which will be kept. The special value of zero
+ means to use a default maximum age.
+
+- ``statistic-default-sample-age`` - determines the default maximum
+ age in seconds of samples which will be kept.
+
+.. note::
+
+ These apply to default values and have no action on existing statistics.
+ To change sample limits on an existing (or all) statistic use commands
+ of the dedicated hook described in :ref:`command-statistic-sample-count-set`
+ and :ref:`command-statistic-sample-age-set-all`.
+
+For instance to reduce the statistic keeping overhead you can set
+the default maximum sample count to 1 so only one sample will be kept by:
+
+::
+
+ "Dhcp4": {
+ "statistic-default-sample-count": 1,
+ "subnet4": [ ... ],
+ ...
+ }
+
The DHCPv4 server supports the following statistics:
.. tabularcolumns:: |p{0.2\linewidth}|p{0.1\linewidth}|p{0.7\linewidth}|
This section describes DHCPv6-specific statistics. For a general
overview and usage of statistics, see :ref:`stats`.
+Beginning with Kea 1.7.7 the DHCPv6 server provides two global
+parameters to control statistics default sample limits:
+
+- ``statistic-default-sample-count`` - determines the default maximum
+ number of samples which will be kept. The special value of zero
+ means to use a default maximum age.
+
+- ``statistic-default-sample-age`` - determines the default maximum
+ age in seconds of samples which will be kept.
+
+.. note::
+
+ These apply to default values and have no action on existing statistics.
+ To change sample limits on an existing (or all) statistic use commands
+ of the dedicated hook described in :ref:`command-statistic-sample-count-set`
+ and :ref:`command-statistic-sample-age-set-all`.
+
+For instance to reduce the statistic keeping overhead you can set
+the default maximum sample count to 1 so only one sample will be kept by:
+
+::
+
+ "Dhcp6": {
+ "statistic-default-sample-count": 1,
+ "subnet6": [ ... ],
+ ...
+ }
+
The DHCPv6 server supports the following statistics:
.. tabularcolumns:: |p{0.2\linewidth}|p{0.1\linewidth}|p{0.7\linewidth}|
statistic completely (-remove). We can change the statistics time based
limit (-sample-age-set) and size based limit (-sample-count-set) which
control how long or how many samples of the given statistic are retained.
+
+This only applies for existing statistics: to change the default limits used
+when a new statistic is created, for instance during server startup,
+the statistic-default-sample-count and statistic-default-sample-age
+global configuration parameters must be used.
+
The difference between reset and remove is somewhat subtle.
The reset command sets the value of the statistic to zero or a neutral value,
so after this operation, the statistic will have a value of 0 (integer),
#include <dhcpsrv/testutils/test_config_backend_dhcp4.h>
#include <process/config_ctl_info.h>
#include <hooks/hooks_manager.h>
+#include <stats/stats_mgr.h>
+#include <util/boost_time_utils.h>
#include <util/doubles.h>
#include "marker_file.h"
EXPECT_TRUE(subnet2->getStoreExtendedInfo());
}
+/// This test checks that the statistic-default-sample-count and age
+/// global parameters are committed to the stats manager as expected.
+TEST_F(Dhcp4ParserTest, statsDefaultLimits) {
+ std::string config = "{ " + genIfaceConfig() + "," +
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"statistic-default-sample-count\": 10, "
+ "\"statistic-default-sample-age\": 5, "
+ "\"valid-lifetime\": 4000 }";
+
+ ConstElementPtr json;
+ ASSERT_NO_THROW(json = parseDHCP4(config));
+ extractConfig(config);
+
+ ConstElementPtr status;
+ ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
+ checkResult(status, 0);
+
+ CfgMgr::instance().commit();
+
+ stats::StatsMgr& stats_mgr = stats::StatsMgr::instance();
+ EXPECT_EQ(10, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:05",
+ util::durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+}
+
}
" }\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
+" }\n",
+ // CONFIGURATION 72
+"{\n"
+" \"interfaces-config\": {\n"
+" \"interfaces\": [ \"*\" ],\n"
+" \"re-detect\": false\n"
+" },\n"
+" \"rebind-timer\": 2000,\n"
+" \"renew-timer\": 1000,\n"
+" \"statistic-default-sample-age\": 5,\n"
+" \"statistic-default-sample-count\": 10,\n"
+" \"valid-lifetime\": 4000\n"
" }\n"
};
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"foo\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"nohost\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"valid-lifetime\": 7200\n"
" }\n"
" ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"valid-lifetime\": 4000\n"
" }\n"
" ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": true,\n"
" \"subnet4\": [\n"
" {\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 4000\n"
+" }\n",
+ // CONFIGURATION 72
+"{\n"
+" \"authoritative\": false,\n"
+" \"boot-file-name\": \"\",\n"
+" \"calculate-tee-times\": false,\n"
+" \"ddns-generated-prefix\": \"myhost\",\n"
+" \"ddns-override-client-update\": false,\n"
+" \"ddns-override-no-update\": false,\n"
+" \"ddns-qualifying-suffix\": \"\",\n"
+" \"ddns-replace-client-name\": \"never\",\n"
+" \"ddns-send-updates\": true,\n"
+" \"decline-probation-period\": 86400,\n"
+" \"dhcp-ddns\": {\n"
+" \"enable-updates\": false,\n"
+" \"max-queue-size\": 1024,\n"
+" \"ncr-format\": \"JSON\",\n"
+" \"ncr-protocol\": \"UDP\",\n"
+" \"sender-ip\": \"0.0.0.0\",\n"
+" \"sender-port\": 0,\n"
+" \"server-ip\": \"127.0.0.1\",\n"
+" \"server-port\": 53001\n"
+" },\n"
+" \"dhcp-queue-control\": {\n"
+" \"capacity\": 500,\n"
+" \"enable-queue\": false,\n"
+" \"queue-type\": \"kea-ring4\"\n"
+" },\n"
+" \"dhcp4o6-port\": 0,\n"
+" \"echo-client-id\": true,\n"
+" \"expired-leases-processing\": {\n"
+" \"flush-reclaimed-timer-wait-time\": 25,\n"
+" \"hold-reclaimed-time\": 3600,\n"
+" \"max-reclaim-leases\": 100,\n"
+" \"max-reclaim-time\": 250,\n"
+" \"reclaim-timer-wait-time\": 10,\n"
+" \"unwarned-reclaim-cycles\": 5\n"
+" },\n"
+" \"hooks-libraries\": [ ],\n"
+" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n"
+" \"hostname-char-replacement\": \"\",\n"
+" \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n"
+" \"interfaces-config\": {\n"
+" \"interfaces\": [ \"*\" ],\n"
+" \"re-detect\": false\n"
+" },\n"
+" \"lease-database\": {\n"
+" \"type\": \"memfile\"\n"
+" },\n"
+" \"match-client-id\": true,\n"
+" \"next-server\": \"0.0.0.0\",\n"
+" \"option-data\": [ ],\n"
+" \"option-def\": [ ],\n"
+" \"rebind-timer\": 2000,\n"
+" \"renew-timer\": 1000,\n"
+" \"reservation-mode\": \"all\",\n"
+" \"sanity-checks\": {\n"
+" \"lease-checks\": \"warn\"\n"
+" },\n"
+" \"server-hostname\": \"\",\n"
+" \"server-tag\": \"\",\n"
+" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 5,\n"
+" \"statistic-default-sample-count\": 10,\n"
+" \"store-extended-info\": false,\n"
+" \"subnet4\": [ ],\n"
+" \"t1-percent\": 0.5,\n"
+" \"t2-percent\": 0.875,\n"
+" \"valid-lifetime\": 4000\n"
" }\n"
};
-// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
#include <dhcpsrv/testutils/test_config_backend_dhcp6.h>
#include <hooks/hooks_manager.h>
#include <process/config_ctl_info.h>
+#include <stats/stats_mgr.h>
+#include <util/boost_time_utils.h>
#include "test_data_files_config.h"
#include "test_libraries.h"
EXPECT_TRUE(subnet->getStoreExtendedInfo());
}
+/// This test checks that the statistic-default-sample-count and age
+/// global parameters are committed to the stats manager as expected.
+TEST_F(Dhcp6ParserTest, statsDefaultLimits) {
+ std::string config = "{ " + genIfaceConfig() + "," +
+ "\"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"statistic-default-sample-count\": 10, "
+ "\"statistic-default-sample-age\": 5, "
+ "\"valid-lifetime\": 4000 }";
+ ConstElementPtr json;
+ ASSERT_NO_THROW(json = parseDHCP6(config));
+ extractConfig(config);
-};
+ ConstElementPtr status;
+ ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ checkResult(status, 0);
+
+ CfgMgr::instance().commit();
+
+ stats::StatsMgr& stats_mgr = stats::StatsMgr::instance();
+ EXPECT_EQ(10, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:05",
+ util::durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+}
+
+
+}
" }\n"
" ],\n"
" \"valid-lifetime\": 4000\n"
+" }\n",
+ // CONFIGURATION 60
+"{\n"
+" \"interfaces-config\": {\n"
+" \"interfaces\": [ \"*\" ],\n"
+" \"re-detect\": false\n"
+" },\n"
+" \"preferred-lifetime\": 3000,\n"
+" \"rebind-timer\": 2000,\n"
+" \"renew-timer\": 1000,\n"
+" \"statistic-default-sample-age\": 5,\n"
+" \"statistic-default-sample-count\": 10,\n"
+" \"valid-lifetime\": 4000\n"
" }\n"
};
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"valid-lifetime\": 7200\n"
" }\n"
" ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" },\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 0,\n"
+" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet6\": [\n"
" {\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.8,\n"
" \"valid-lifetime\": 4000\n"
+" }\n",
+ // CONFIGURATION 60
+"{\n"
+" \"calculate-tee-times\": true,\n"
+" \"ddns-generated-prefix\": \"myhost\",\n"
+" \"ddns-override-client-update\": false,\n"
+" \"ddns-override-no-update\": false,\n"
+" \"ddns-qualifying-suffix\": \"\",\n"
+" \"ddns-replace-client-name\": \"never\",\n"
+" \"ddns-send-updates\": true,\n"
+" \"decline-probation-period\": 86400,\n"
+" \"dhcp-ddns\": {\n"
+" \"enable-updates\": false,\n"
+" \"max-queue-size\": 1024,\n"
+" \"ncr-format\": \"JSON\",\n"
+" \"ncr-protocol\": \"UDP\",\n"
+" \"sender-ip\": \"0.0.0.0\",\n"
+" \"sender-port\": 0,\n"
+" \"server-ip\": \"127.0.0.1\",\n"
+" \"server-port\": 53001\n"
+" },\n"
+" \"dhcp-queue-control\": {\n"
+" \"capacity\": 500,\n"
+" \"enable-queue\": false,\n"
+" \"queue-type\": \"kea-ring6\"\n"
+" },\n"
+" \"dhcp4o6-port\": 0,\n"
+" \"expired-leases-processing\": {\n"
+" \"flush-reclaimed-timer-wait-time\": 25,\n"
+" \"hold-reclaimed-time\": 3600,\n"
+" \"max-reclaim-leases\": 100,\n"
+" \"max-reclaim-time\": 250,\n"
+" \"reclaim-timer-wait-time\": 10,\n"
+" \"unwarned-reclaim-cycles\": 5\n"
+" },\n"
+" \"hooks-libraries\": [ ],\n"
+" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\" ],\n"
+" \"hostname-char-replacement\": \"\",\n"
+" \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n"
+" \"interfaces-config\": {\n"
+" \"interfaces\": [ \"*\" ],\n"
+" \"re-detect\": false\n"
+" },\n"
+" \"lease-database\": {\n"
+" \"type\": \"memfile\"\n"
+" },\n"
+" \"mac-sources\": [ \"any\" ],\n"
+" \"option-data\": [ ],\n"
+" \"option-def\": [ ],\n"
+" \"preferred-lifetime\": 3000,\n"
+" \"rebind-timer\": 2000,\n"
+" \"relay-supplied-options\": [ \"65\" ],\n"
+" \"renew-timer\": 1000,\n"
+" \"reservation-mode\": \"all\",\n"
+" \"sanity-checks\": {\n"
+" \"lease-checks\": \"warn\"\n"
+" },\n"
+" \"server-id\": {\n"
+" \"enterprise-id\": 0,\n"
+" \"htype\": 0,\n"
+" \"identifier\": \"\",\n"
+" \"persist\": true,\n"
+" \"time\": 0,\n"
+" \"type\": \"LLT\"\n"
+" },\n"
+" \"server-tag\": \"\",\n"
+" \"shared-networks\": [ ],\n"
+" \"statistic-default-sample-age\": 5,\n"
+" \"statistic-default-sample-count\": 10,\n"
+" \"store-extended-info\": false,\n"
+" \"subnet6\": [ ],\n"
+" \"t1-percent\": 0.5,\n"
+" \"t2-percent\": 0.8,\n"
+" \"valid-lifetime\": 4000\n"
" }\n"
};
#include <log/logger_manager.h>
#include <log/logger_specification.h>
#include <dhcp/pkt.h> // Needed for HWADDR_SOURCE_*
+#include <stats/stats_mgr.h>
#include <util/strutil.h>
#include <list>
void
SrvConfig::updateStatistics() {
+ // Update default sample limits.
+ stats::StatsMgr& stats_mgr = stats::StatsMgr::instance();
+ ConstElementPtr max_samples =
+ getConfiguredGlobal("statistic-default-sample-count");
+ if (max_samples) {
+ stats_mgr.setMaxSampleCountDefault(max_samples->intValue());
+ }
+ ConstElementPtr duration =
+ getConfiguredGlobal("statistic-default-sample-age");
+ if (duration) {
+ int64_t time_duration = duration->intValue();
+ int64_t hours = time_duration / 3600;
+ time_duration -= hours * 3600;
+ int64_t minutes = time_duration / 60;
+ time_duration -= minutes * 60;
+ int64_t seconds = time_duration;
+ stats_mgr.setMaxSampleAgeDefault(boost::posix_time::time_duration(hours, minutes, seconds, 0));
+ }
+
// Updating subnet statistics involves updating lease statistics, which
// is done by the LeaseMgr. Since servers with subnets, must have a
// LeaseMgr, we do not bother updating subnet stats for servers without
DdnsParamsPtr
SrvConfig::getDdnsParams(const Subnet4Ptr& subnet) const {
- return (DdnsParamsPtr(new DdnsParams(subnet,
+ return (DdnsParamsPtr(new DdnsParams(subnet,
getD2ClientConfig()->getEnableUpdates())));
}
-// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-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
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <process/logging_info.h>
#include <stats/stats_mgr.h>
+#include <util/boost_time_utils.h>
#include <boost/scoped_ptr.hpp>
subnets = cfg_mgr.getStagingCfg()->getCfgSubnets4();
subnets->add(subnet2);
+ // Change the stats default limits.
+ cfg_mgr.getStagingCfg()->addConfiguredGlobal("statistic-default-sample-count",
+ Element::create(15));
+ cfg_mgr.getStagingCfg()->addConfiguredGlobal("statistic-default-sample-age",
+ Element::create(2));
+
// Let's commit it
cfg_mgr.commit();
+ EXPECT_EQ(15, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:02", durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+
EXPECT_FALSE(stats_mgr.getObservation("subnet[123].total-addresses"));
EXPECT_FALSE(stats_mgr.getObservation("subnet[123].assigned-addresses"));
subnets = external_cfg->getCfgSubnets4();
subnets->add(subnet2);
+ external_cfg->addConfiguredGlobal("statistic-default-sample-count",
+ Element::create(16));
+ external_cfg->addConfiguredGlobal("statistic-default-sample-age",
+ Element::create(3));
+
// Let's merge it.
cfg_mgr.mergeIntoCurrentCfg(external_cfg->getSequence());
// The stats should have been updated and so we should be able to get
- // obeservations for subnet 42.
+ // observations for subnet 42.
+ EXPECT_EQ(16, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:03", durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+
EXPECT_TRUE(stats_mgr.getObservation("subnet[42].total-addresses"));
EXPECT_TRUE(stats_mgr.getObservation("subnet[42].assigned-addresses"));
subnets = cfg_mgr.getStagingCfg()->getCfgSubnets6();
subnets->add(subnet2);
+ // Change the stats default limits.
+ cfg_mgr.getStagingCfg()->addConfiguredGlobal("statistic-default-sample-count",
+ Element::create(14));
+ cfg_mgr.getStagingCfg()->addConfiguredGlobal("statistic-default-sample-age",
+ Element::create(10));
+
// Let's commit it
cfg_mgr.commit();
+ EXPECT_EQ(14, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:10", durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+
EXPECT_FALSE(stats_mgr.getObservation("subnet[123].total-nas"));
EXPECT_FALSE(stats_mgr.getObservation("subnet[123].assigned-nas"));
subnets = external_cfg->getCfgSubnets6();
subnets->add(subnet2);
+ external_cfg->addConfiguredGlobal("statistic-default-sample-count",
+ Element::create(17));
+ external_cfg->addConfiguredGlobal("statistic-default-sample-age",
+ Element::create(4));
+
// Let's merge it.
cfg_mgr.mergeIntoCurrentCfg(external_cfg->getSequence());
+ EXPECT_EQ(17, stats_mgr.getMaxSampleCountDefault());
+ EXPECT_EQ("00:00:04", durationToText(stats_mgr.getMaxSampleAgeDefault(), 0));
+
EXPECT_TRUE(stats_mgr.getObservation("subnet[42].total-nas"));
EXPECT_TRUE(stats_mgr.getObservation("subnet[42].assigned-nas"));
EXPECT_TRUE(stats_mgr.getObservation("subnet[42].total-pds"));
-// 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
TEST_F(ObservationTest, setCountLimit) {
// Preparing of 21 test's samples for each type of storage
int64_t int_samples[22] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21};
+ 14, 15, 16, 17, 18, 19, 20, 21};
double float_samples[22] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
- 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0,
- 20.0, 21.0};
+ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0,
+ 20.0, 21.0};
std::string string_samples[22] = {"a", "b", "c", "d", "e", "f", "g", "h",
- "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
- "v"};
+ "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
+ "v"};
millisec::time_duration duration_samples[22];
for (uint32_t i = 0; i < 22; ++i) {
EXPECT_EQ(d.getMaxSampleCount().second, 20);
}
+// limit defaults are tested with StatsMgr.
+
// Test checks whether timing is reported properly.
TEST_F(ObservationTest, timers) {
ptime before = microsec_clock::local_time();
-// 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
EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().first, false);
}
+// Test checks whether setting default age limit and count limit works
+// properly.
+TEST_F(StatsMgrTest, setLimitsDefault) {
+ ASSERT_EQ(StatsMgr::instance().getMaxSampleCountDefault(), 20);
+ ASSERT_EQ(StatsMgr::instance().getMaxSampleAgeDefault(), time_duration(0, 0, 0, 0));
+
+ // Set a couple of statistics
+ StatsMgr::instance().setValue("alpha", static_cast<int64_t>(1234));
+ StatsMgr::instance().setValue("beta", 12.34);
+ StatsMgr::instance().setValue("gamma", time_duration(1, 2, 3, 4));
+ StatsMgr::instance().setValue("delta", "Lorem ipsum");
+
+ // check what default applied
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().second, 20);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().second, time_duration(0, 0, 0, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().second, 20);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().second, time_duration(0, 0, 0, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().second, 20);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().second, time_duration(0, 0, 0, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().second, 20);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().second, time_duration(0, 0, 0, 0));
+
+ // Retry with another default count limits.
+ EXPECT_NO_THROW(StatsMgr::instance().setMaxSampleCountDefault(10));
+ EXPECT_NO_THROW(StatsMgr::instance().setMaxSampleAgeDefault(time_duration(0, 0, 5, 0)));
+ ASSERT_EQ(StatsMgr::instance().getMaxSampleCountDefault(), 10);
+ ASSERT_EQ(StatsMgr::instance().getMaxSampleAgeDefault(), time_duration(0, 0, 5, 0));
+
+ EXPECT_NO_THROW(StatsMgr::instance().removeAll());
+
+ StatsMgr::instance().setValue("alpha", static_cast<int64_t>(1234));
+ StatsMgr::instance().setValue("beta", 12.34);
+ StatsMgr::instance().setValue("gamma", time_duration(1, 2, 3, 4));
+ StatsMgr::instance().setValue("delta", "Lorem ipsum");
+
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+
+ // Retry with count limit disable.
+ EXPECT_NO_THROW(StatsMgr::instance().setMaxSampleCountDefault(0));
+ ASSERT_EQ(StatsMgr::instance().getMaxSampleCountDefault(), 0);
+
+ EXPECT_NO_THROW(StatsMgr::instance().removeAll());
+
+ StatsMgr::instance().setValue("alpha", static_cast<int64_t>(1234));
+ StatsMgr::instance().setValue("beta", 12.34);
+ StatsMgr::instance().setValue("gamma", time_duration(1, 2, 3, 4));
+ StatsMgr::instance().setValue("delta", "Lorem ipsum");
+
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("alpha")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("beta")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("gamma")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().first, false);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleCount().second, 10);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().first, true);
+ EXPECT_EQ(StatsMgr::instance().getObservation("delta")->getMaxSampleAge().second, time_duration(0, 0, 5, 0));
+
+ EXPECT_NO_THROW(StatsMgr::instance().setMaxSampleCountDefault(20));
+ EXPECT_NO_THROW(StatsMgr::instance().setMaxSampleAgeDefault(time_duration(0, 0, 0, 0)));
+}
+
// This test checks whether a single (get("foo")) and all (getAll())
// statistics are reported properly.
TEST_F(StatsMgrTest, getGetAll) {