]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3213] added statistic-global-get-all
authorRazvan Becheriu <razvan@isc.org>
Mon, 8 Sep 2025 11:37:32 +0000 (14:37 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 8 Sep 2025 19:43:16 +0000 (19:43 +0000)
20 files changed:
doc/sphinx/api-files.txt
doc/sphinx/arm/stats.rst
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/http_control_socket_unittest.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/http_control_socket_unittest.cc
src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in
src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in
src/bin/shell/tests/shell_dhcp4_process_tests.sh.in
src/bin/shell/tests/shell_dhcp6_process_tests.sh.in
src/bin/shell/tests/tls_dhcp4_process_tests.sh.in
src/bin/shell/tests/tls_dhcp6_process_tests.sh.in
src/lib/stats/context.cc
src/lib/stats/context.h
src/lib/stats/stats_mgr.cc
src/lib/stats/stats_mgr.h
src/lib/stats/tests/stats_mgr_unittest.cc
src/share/api/statistic-global-get-all.json [new file with mode: 0644]

index 9806449c08861346ab7e5f2968eec28f2d558fab..7871938f92f085581bba00c921a3847e883eb9cb 100644 (file)
@@ -171,6 +171,7 @@ src/share/api/server-tag-get.json
 src/share/api/shutdown.json
 src/share/api/statistic-get.json
 src/share/api/statistic-get-all.json
+src/share/api/statistic-global-get-all.json
 src/share/api/statistic-remove.json
 src/share/api/statistic-remove-all.json
 src/share/api/statistic-reset.json
index d716f0be53c5a24f056f12f05fbcf30996d7ca86..4e85c18889c240dfa95446a42b13543c75feebab 100644 (file)
@@ -928,6 +928,439 @@ or
        "result": 0
    }
 
+.. isccmd:: statistic-global-get-all
+.. _command-statistic-global-get-all:
+
+The ``statistic-global-get-all`` Command
+----------------------------------------
+
+The :isccmd:`statistic-global-get-all` command retrieves all global statistics recorded
+(same as :isccmd:`statistic-global-get-all` but omitting subnet statistics). An example
+command may look like this:
+
+::
+
+   {
+       "command": "statistic-global-get-all",
+       "arguments": { }
+   }
+
+The server responds with details of all recorded statistics, with a
+result set to 0 to indicate that it iterated over all statistics (even
+when the total number of statistics is zero).
+
+Here is an example response returning all collected statistics:
+
+::
+
+   {
+       "command": "statistic-global-get-all",
+       "arguments": {
+           "assigned-addresses": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.836096"
+               ]
+           ],
+           "cumulative-assigned-addresses": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.836166"
+               ]
+           ],
+           "declined-addresses": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.836156"
+               ]
+           ],
+           "pkt4-ack-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616247"
+               ]
+           ],
+           "pkt4-ack-sent": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616290"
+               ]
+           ],
+           "pkt4-decline-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616296"
+               ]
+           ],
+           "pkt4-discover-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616303"
+               ]
+           ],
+           "pkt4-inform-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616308"
+               ]
+           ],
+           "pkt4-nak-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616312"
+               ]
+           ],
+           "pkt4-nak-sent": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616314"
+               ]
+           ],
+           "pkt4-offer-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616318"
+               ]
+           ],
+           "pkt4-offer-sent": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616323"
+               ]
+           ],
+           "pkt4-parse-failed": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616326"
+               ]
+           ],
+           "pkt4-receive-drop": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616330"
+               ]
+           ],
+           "pkt4-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616335"
+               ]
+           ],
+           "pkt4-release-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616339"
+               ]
+           ],
+           "pkt4-request-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616343"
+               ]
+           ],
+           "pkt4-sent": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616348"
+               ]
+           ],
+           "pkt4-unknown-received": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616354"
+               ]
+           ],
+           "reclaimed-declined-addresses": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.836159"
+               ]
+           ],
+           "reclaimed-leases": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.836163"
+               ]
+           ],
+           "v4-allocation-fail": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616358"
+               ]
+           ],
+           "v4-allocation-fail-classes": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616363"
+               ]
+           ],
+           "v4-allocation-fail-no-pools": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616368"
+               ]
+           ],
+           "v4-allocation-fail-shared-network": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616372"
+               ]
+           ],
+           "v4-allocation-fail-subnet": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616376"
+               ]
+           ],
+           "v4-lease-reuses": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616410"
+               ]
+           ],
+           "v4-reservation-conflicts": [
+               [
+                   0,
+                   "2023-06-13 20:42:46.616412"
+               ]
+           ]
+       },
+       "result": 0
+   }
+
+or
+
+::
+
+   {
+       "command": "statistic-global-get-all",
+       "arguments": {
+           "assigned-nas": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196757"
+               ]
+           ],
+           "assigned-pds": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196757"
+               ]
+           ],
+           "cumulative-assigned-nas": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196757"
+               ]
+           ],
+           "cumulative-assigned-pds": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196758"
+               ]
+           ],
+           "cumulative-registered": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196758"
+               ]
+           ],
+           "declined-addresses": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196754"
+               ]
+           ],
+           "pkt6-addr-reg-inform-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177731"
+               ]
+           ],
+           "pkt6-addr-reg-reply-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177731"
+               ]
+           ],
+           "pkt6-addr-reg-reply-sent": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177731"
+               ]
+           ],
+           "pkt6-advertise-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177731"
+               ]
+           ],
+           "pkt6-advertise-sent": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177739"
+               ]
+           ],
+           "pkt6-decline-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177739"
+               ]
+           ],
+           "pkt6-dhcpv4-query-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177740"
+               ]
+           ],
+           "pkt6-dhcpv4-response-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177740"
+               ]
+           ],
+           "pkt6-dhcpv4-response-sent": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177741"
+               ]
+           ],
+           "pkt6-infrequest-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177742"
+               ]
+           ],
+           "pkt6-parse-failed": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177742"
+               ]
+           ],
+           "pkt6-rebind-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177743"
+               ]
+           ],
+           "pkt6-receive-drop": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177743"
+               ]
+           ],
+           "pkt6-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177744"
+               ]
+           ],
+           "pkt6-release-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177744"
+               ]
+           ],
+           "pkt6-renew-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177745"
+               ]
+           ],
+           "pkt6-reply-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177745"
+               ]
+           ],
+           "pkt6-reply-sent": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177746"
+               ]
+           ],
+           "pkt6-request-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177747"
+               ]
+           ],
+           "pkt6-sent": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177747"
+               ]
+           ],
+           "pkt6-solicit-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177748"
+               ]
+           ],
+           "pkt6-unknown-received": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177748"
+               ]
+           ],
+           "reclaimed-declined-addresses": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196755"
+               ]
+           ],
+           "reclaimed-leases": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.196756"
+               ]
+           ],
+           "v6-allocation-fail": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177749"
+               ]
+           ],
+           "v6-allocation-fail-classes": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177755"
+               ]
+           ],
+           "v6-allocation-fail-no-pools": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177756"
+               ]
+           ],
+           "v6-allocation-fail-shared-network": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177756"
+               ]
+           ],
+           "v6-allocation-fail-subnet": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177757"
+               ]
+           ],
+           "v6-ia-na-lease-reuses": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177757"
+               ]
+           ],
+           "v6-ia-pd-lease-reuses": [
+               [
+                   0,
+                   "2023-06-13 21:28:57.177758"
+               ]
+           ]
+       },
+       "result": 0
+   }
+
 .. isccmd:: statistic-reset-all
 .. _command-statistic-reset-all:
 
index 1d59e0b7ac0bf097e1754f0e76205f11497e9de3..41b64d7eee7719f081999c351c7e145055a8496c 100644 (file)
@@ -1544,6 +1544,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P
     CommandMgr::instance().registerCommand("statistic-get-all",
         std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
 
+    CommandMgr::instance().registerCommand("statistic-global-get-all",
+        std::bind(&StatsMgr::statisticGlobalGetAllHandler, ph::_1, ph::_2));
+
     CommandMgr::instance().registerCommand("statistic-reset-all",
         std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
 
@@ -1607,6 +1610,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
         CommandMgr::instance().deregisterCommand("shutdown");
         CommandMgr::instance().deregisterCommand("statistic-get");
         CommandMgr::instance().deregisterCommand("statistic-get-all");
+        CommandMgr::instance().deregisterCommand("statistic-global-get-all");
         CommandMgr::instance().deregisterCommand("statistic-remove");
         CommandMgr::instance().deregisterCommand("statistic-remove-all");
         CommandMgr::instance().deregisterCommand("statistic-reset");
index e5a314b30244776240ee029053afc2fa64442d3f..8ff37b43e2faa9619cd04f5b60e266bb59569e73 100644 (file)
@@ -546,6 +546,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, commandsRegistration) {
     EXPECT_TRUE(command_list.find("\"shutdown\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-get\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-get-all\"") != string::npos);
+    EXPECT_TRUE(command_list.find("\"statistic-global-get-all\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-remove\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-remove-all\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-reset\"") != string::npos);
@@ -656,6 +657,12 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlChannelStats) {
 
     EXPECT_EQ(stats_get_all, response);
 
+    // Check statistic-global-get-all
+    sendUnixCommand("{ \"command\" : \"statistic-global-get-all\", "
+                    "  \"arguments\": {}}", response);
+
+    EXPECT_EQ(stats_get_all, response);
+
     // Check statistic-reset
     sendUnixCommand("{ \"command\" : \"statistic-reset\", "
                     "  \"arguments\": {"
@@ -1668,6 +1675,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, listCommands) {
     checkListCommands(rsp, "shutdown");
     checkListCommands(rsp, "statistic-get");
     checkListCommands(rsp, "statistic-get-all");
+    checkListCommands(rsp, "statistic-global-get-all");
     checkListCommands(rsp, "statistic-remove");
     checkListCommands(rsp, "statistic-remove-all");
     checkListCommands(rsp, "statistic-reset");
index 48579a744a11beaf72ec7a447142c4eec0f3a56d..2f7e64a9aec6cac177f5093a1d7dc0490a97aaaa 100644 (file)
@@ -966,6 +966,12 @@ BaseCtrlChannelDhcpv4Test::testControlChannelStats() {
 
     EXPECT_EQ(stats_get_all, response);
 
+    // Check statistic-global-get-all
+    sendHttpCommand("{ \"command\" : \"statistic-global-get-all\", "
+                    "  \"arguments\": {}}", response);
+
+    EXPECT_EQ(stats_get_all, response);
+
     // Check statistic-reset
     sendHttpCommand("{ \"command\" : \"statistic-reset\", "
                     "  \"arguments\": {"
@@ -2611,6 +2617,7 @@ BaseCtrlChannelDhcpv4Test::testListCommands() {
     checkListCommands(rsp, "shutdown");
     checkListCommands(rsp, "statistic-get");
     checkListCommands(rsp, "statistic-get-all");
+    checkListCommands(rsp, "statistic-global-get-all");
     checkListCommands(rsp, "statistic-remove");
     checkListCommands(rsp, "statistic-remove-all");
     checkListCommands(rsp, "statistic-reset");
index 9d2dcdf6e96449361df6d94ed06d149f64844e1b..c7d9b072fbc2c719bbf762746d71fbda7a79a2c9 100644 (file)
@@ -1331,6 +1331,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port /*= DHCP6_SERVER_P
     CommandMgr::instance().registerCommand("statistic-get-all",
         std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
 
+    CommandMgr::instance().registerCommand("statistic-global-get-all",
+        std::bind(&StatsMgr::statisticGlobalGetAllHandler, ph::_1, ph::_2));
+
     CommandMgr::instance().registerCommand("statistic-reset-all",
         std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
 
@@ -1393,6 +1396,7 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
         CommandMgr::instance().deregisterCommand("shutdown");
         CommandMgr::instance().deregisterCommand("statistic-get");
         CommandMgr::instance().deregisterCommand("statistic-get-all");
+        CommandMgr::instance().deregisterCommand("statistic-global-get-all");
         CommandMgr::instance().deregisterCommand("statistic-remove");
         CommandMgr::instance().deregisterCommand("statistic-remove-all");
         CommandMgr::instance().deregisterCommand("statistic-reset");
index f0d5eac6365aac15a1ace337b992237d6c178108..91145d92fe3db434ffc406d1e8c2e154200e5f9b 100644 (file)
@@ -550,6 +550,7 @@ TEST_F(CtrlDhcpv6SrvTest, commandsRegistration) {
     EXPECT_TRUE(command_list.find("\"shutdown\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-get\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-get-all\"") != string::npos);
+    EXPECT_TRUE(command_list.find("\"statistic-global-get-all\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-remove\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-remove-all\"") != string::npos);
     EXPECT_TRUE(command_list.find("\"statistic-reset\"") != string::npos);
@@ -666,6 +667,12 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlChannelStats) {
 
     EXPECT_EQ(stats_get_all, response);
 
+    // Check statistic-global-get-all
+    sendUnixCommand("{ \"command\" : \"statistic-global-get-all\", "
+                    "  \"arguments\": {}}", response);
+
+    EXPECT_EQ(stats_get_all, response);
+
     // Check statistic-reset
     sendUnixCommand("{ \"command\" : \"statistic-reset\", "
                     "  \"arguments\": {"
@@ -1672,6 +1679,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, listCommands) {
     checkListCommands(rsp, "shutdown");
     checkListCommands(rsp, "statistic-get");
     checkListCommands(rsp, "statistic-get-all");
+    checkListCommands(rsp, "statistic-global-get-all");
     checkListCommands(rsp, "statistic-remove");
     checkListCommands(rsp, "statistic-remove-all");
     checkListCommands(rsp, "statistic-reset");
index 06ba22761eb9c68e2db62ca2ad2f19c20c3c6ecf..8be9d533a67b396ddee531340a885080b8a00983 100644 (file)
@@ -983,6 +983,12 @@ BaseCtrlChannelDhcpv6Test::testControlChannelStats() {
 
     EXPECT_EQ(stats_get_all, response);
 
+    // Check statistic-global-get-all
+    sendHttpCommand("{ \"command\" : \"statistic-global-get-all\", "
+                    "  \"arguments\": {}}", response);
+
+    EXPECT_EQ(stats_get_all, response);
+
     // Check statistic-reset
     sendHttpCommand("{ \"command\" : \"statistic-reset\", "
                     "  \"arguments\": {"
@@ -2611,6 +2617,7 @@ BaseCtrlChannelDhcpv6Test::testListCommands() {
     checkListCommands(rsp, "shutdown");
     checkListCommands(rsp, "statistic-get");
     checkListCommands(rsp, "statistic-get-all");
+    checkListCommands(rsp, "statistic-global-get-all");
     checkListCommands(rsp, "statistic-remove");
     checkListCommands(rsp, "statistic-remove-all");
     checkListCommands(rsp, "statistic-reset");
index 89aa299eaf1880b7c8fbfcebb67685d1b9e04736..6515095b948d21d4ba3a2e497a98f3752d10c51a 100755 (executable)
@@ -229,7 +229,7 @@ shell_command_test "shell.bad-auth" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.bad-auth-password-file" \
     "--auth-user foo --auth-password-file foobar" "list-commands" "fail" \
     "Failed to run: [Errno 2] No such file or directory: 'foobar'"
@@ -238,7 +238,7 @@ shell_command_test "shell.bad-auth-password-file-content" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.good-auth-password-file-content" \
     "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.flag-precedence" \
     "--auth-user pet --auth-password meow --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
     "Failed to run: HTTP Error 401: Unauthorized"
index 62778274f3708f0969d9833b4c5e867ade354e0a..74b22828298f30556dea59be2f4a2bf183ca122f 100755 (executable)
@@ -234,7 +234,7 @@ shell_command_test "shell.bad-auth" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.bad-auth-password-file" \
     "--auth-user foo --auth-password-file foobar" "list-commands" "fail" \
     "Failed to run: [Errno 2] No such file or directory: 'foobar'"
@@ -243,7 +243,7 @@ shell_command_test "shell.bad-auth-password-file-content" \
     "Failed to run: HTTP Error 401: Unauthorized"
 shell_command_test "shell.good-auth-password-file-content" \
     "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 shell_command_test "shell.flag-precedence" \
     "--auth-user pet --auth-password meow --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
     "Failed to run: HTTP Error 401: Unauthorized"
index db0b39d2c05315368a0d24cb9995fb42bdda3193..e4f5da844ce3dcbab4426cc81b3f3ad73f2f9ead 100755 (executable)
@@ -214,7 +214,7 @@ version_test() {
 
 version_test "shell.version"
 shell_command_test "shell.list-commands" "list-commands" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
 shell_command_test "shell.bogus" "give-me-a-beer" \
 "[ { \"result\": 2, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
 shell_command_test "shell.empty-config-test" "config-test" \
index 37339989dfd9c4a84c4f51016e7ca38ce76ddb04..8dd102c0d49aafea2f688910442c841ed9c2d9f4 100755 (executable)
@@ -219,7 +219,7 @@ version_test() {
 
 version_test "shell.version"
 shell_command_test "shell.list-commands" "list-commands" \
-    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]" ""
 shell_command_test "shell.bogus" "give-me-a-beer" \
 "[ { \"result\": 2, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
 shell_command_test "shell.empty-config-test" "config-test" \
index 24cb1e8c027cd46b2e981e95958d85692f3d2dc8..7e6e0915b0bdd7520a1af29b8a0121884d3a7ee8 100755 (executable)
@@ -306,10 +306,10 @@ list_commands_test() {
 }
 
 list_commands_test "NoTLS" "${CONFIG_NONE}" "" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Encrypted" "${CONFIG_NOCR}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Authenticated" "${CONFIG}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt --cert ${TEST_CA_DIR}/kea-client.crt --key ${TEST_CA_DIR}/kea-client.key" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index 29c419a7af1301c7f98dc8e8cb7ae9517a13c439..fe0646db4affed613b6f1e4a598d9605d130e6d3 100755 (executable)
@@ -321,10 +321,10 @@ list_commands_test() {
 }
 
 list_commands_test "NoTLS" "${CONFIG_NONE}" "" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Encrypted" "${CONFIG_NOCR}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
 list_commands_test "Authenticated" "${CONFIG}" \
 "--ca ${TEST_CA_DIR}/kea-ca.crt --cert ${TEST_CA_DIR}/kea-client.crt --key ${TEST_CA_DIR}/kea-client.key" \
-"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+"[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-global-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index 5826b35f11681ebe0c7bcf64553e2f3f1d6b1d47..e28228132ac737bd0c433c32ca77a28b4f14668a 100644 (file)
@@ -77,6 +77,20 @@ StatContext::getAll() const {
     return (map);
 }
 
+ConstElementPtr
+StatContext::getAllGlobal() const {
+    ElementPtr map = Element::createMap(); // a map
+    // Let's iterate over all stored statistics...
+    for (auto const& s : stats_) {
+        // ... and add each of them to the map omitting
+        // subnet statistics.
+        if (s.first.find("subnet") != 0) {
+            map->set(s.first, s.second->getJSON());
+        }
+    }
+    return (map);
+}
+
 void
 StatContext::setMaxSampleCountAll(uint32_t max_samples) {
     // Let's iterate over all stored statistics...
index 117872f96c5592e0bfa194f7423981019fd97dc7..b5879974db3e8b97bc4cde4e5039ba419dce1c0e 100644 (file)
@@ -75,6 +75,12 @@ public:
     /// @return map with all observations
     isc::data::ConstElementPtr getAll() const;
 
+    /// @brief Returns a map with all observations omitting those
+    /// related to subnet statistics.
+    ///
+    /// @return map with all observations
+    isc::data::ConstElementPtr getAllGlobal() const;
+
 private:
 
     /// @brief Statistics container
index 3d0bf32559bb01d29428d6050b3741ec4a203ae4..cbb7b3262552dff09c58b4298dc5068382a272fb 100644 (file)
@@ -295,11 +295,22 @@ StatsMgr::getAll() const {
     return (getAllInternal());
 }
 
+ConstElementPtr
+StatsMgr::getAllGlobal() const {
+    MultiThreadingLock lock(*mutex_);
+    return (getAllGlobalInternal());
+}
+
 ConstElementPtr
 StatsMgr::getAllInternal() const {
     return (global_->getAll());
 }
 
+ConstElementPtr
+StatsMgr::getAllGlobalInternal() const {
+    return (global_->getAllGlobal());
+}
+
 void
 StatsMgr::resetAll() {
     MultiThreadingLock lock(*mutex_);
@@ -437,6 +448,13 @@ StatsMgr::statisticGetAllHandler(const string& /*name*/,
     return (createAnswer(CONTROL_RESULT_SUCCESS, all_stats));
 }
 
+ConstElementPtr
+StatsMgr::statisticGlobalGetAllHandler(const string& /*name*/,
+                                       const ConstElementPtr& /*params*/) {
+    ConstElementPtr all_stats = StatsMgr::instance().getAllGlobal();
+    return (createAnswer(CONTROL_RESULT_SUCCESS, all_stats));
+}
+
 ConstElementPtr
 StatsMgr::statisticResetAllHandler(const string& /*name*/,
                                    const ConstElementPtr& /*params*/) {
index f49ab8ab7c562cf9fb383702d5a7487d564ac088..5ddf71537e7943e91355dc4844b4a3fe409c9159 100644 (file)
@@ -259,6 +259,11 @@ public:
     /// @return JSON structures representing all statistics
     isc::data::ConstElementPtr getAll() const;
 
+    /// @brief Returns all global statistics (omitting subnet statistics) as a JSON structure.
+    ///
+    /// @return JSON structures representing all global statistics (omitting subnet statistics)
+    isc::data::ConstElementPtr getAllGlobal() const;
+
     /// @}
 
     /// @brief Returns an observation.
@@ -413,11 +418,23 @@ public:
     ///
     /// @param name name of the command (ignored, should be "statistic-get-all")
     /// @param params ignored
-    /// @return answer containing values of all statistic
+    /// @return answer containing values of all statistics
     static isc::data::ConstElementPtr
     statisticGetAllHandler(const std::string& name,
                            const isc::data::ConstElementPtr& params);
 
+    /// @brief Handles statistic-global-get-all command
+    ///
+    /// This method handles statistic-global-get-all command, which returns values
+    /// of all global statistics (omitting subnet statistics). Params parameter is ignored.
+    ///
+    /// @param name name of the command (ignored, should be "statistic-global-get-all")
+    /// @param params ignored
+    /// @return answer containing values of all global statistics (omitting subnet statistics)
+    static isc::data::ConstElementPtr
+    statisticGlobalGetAllHandler(const std::string& name,
+                                 const isc::data::ConstElementPtr& params);
+
     /// @brief Handles statistic-reset-all command
     ///
     /// This method handles statistic-reset-all command, which sets values of
@@ -731,6 +748,13 @@ private:
     /// @return JSON structures representing all statistics
     isc::data::ConstElementPtr getAllInternal() const;
 
+    /// @brief Returns all global statistics (omitting subnet statistics) as a JSON structure.
+    ///
+    /// Should be called in a thread safe context.
+    ///
+    /// @return JSON structures representing all global statistics (omitting subnet statistics)
+    isc::data::ConstElementPtr getAllGlobalInternal() const;
+
     /// @private
 
     /// @brief Utility method that attempts to extract statistic name
index 734d134c8ddfa6039d9939f26005fcccdfdc8bbd..5da34838946ba5f52e1b8a949e4032e8a21d5e40 100644 (file)
@@ -693,17 +693,20 @@ TEST_F(StatsMgrTest, commandGetAll) {
     StatsMgr::instance().setValue("beta", 12.34);
     StatsMgr::instance().setValue("gamma", dur1234);
     StatsMgr::instance().setValue("delta", "Lorem ipsum");
+    StatsMgr::instance().setValue("subnet", static_cast<int64_t>(5678));
 
     // Now get them. They're used to generate expected output
     ConstElementPtr rep_alpha = StatsMgr::instance().get("alpha");
     ConstElementPtr rep_beta = StatsMgr::instance().get("beta");
     ConstElementPtr rep_gamma = StatsMgr::instance().get("gamma");
     ConstElementPtr rep_delta = StatsMgr::instance().get("delta");
+    ConstElementPtr rep_subnet = StatsMgr::instance().get("subnet");
 
     ASSERT_TRUE(rep_alpha);
     ASSERT_TRUE(rep_beta);
     ASSERT_TRUE(rep_gamma);
     ASSERT_TRUE(rep_delta);
+    ASSERT_TRUE(rep_subnet);
 
     std::string exp_str_alpha = "[ [ 1234, \"" +
         isc::util::clockToText(StatsMgr::instance().getObservation("alpha")
@@ -717,6 +720,9 @@ TEST_F(StatsMgrTest, commandGetAll) {
     std::string exp_str_delta = "[ [ \"Lorem ipsum\", \"" +
         isc::util::clockToText(StatsMgr::instance().getObservation("delta")
                                    ->getString().second) + "\" ] ]";
+    std::string exp_str_subnet = "[ [ 5678, \"" +
+        isc::util::clockToText(StatsMgr::instance().getObservation("subnet")
+                                   ->getInteger().second) + "\" ] ]";
 
     // Check that all of them can be reported at once
     ConstElementPtr rsp = StatsMgr::instance().statisticGetAllHandler(
@@ -727,6 +733,68 @@ TEST_F(StatsMgrTest, commandGetAll) {
     ASSERT_EQ(0, status_code);
     ASSERT_TRUE(rep_all);
 
+    // Verifying this is a bit more involved, as we don't know whether the
+    // order would be preserved or not.
+    EXPECT_EQ(5, rep_all->size());
+    ASSERT_TRUE(rep_all->get("alpha"));
+    ASSERT_TRUE(rep_all->get("beta"));
+    ASSERT_TRUE(rep_all->get("delta"));
+    ASSERT_TRUE(rep_all->get("gamma"));
+    ASSERT_TRUE(rep_all->get("subnet"));
+    EXPECT_FALSE(rep_all->get("epsilon"));
+
+    EXPECT_EQ(exp_str_alpha, rep_all->get("alpha")->str());
+    EXPECT_EQ(exp_str_beta, rep_all->get("beta")->str());
+    EXPECT_EQ(exp_str_gamma, rep_all->get("gamma")->str());
+    EXPECT_EQ(exp_str_delta, rep_all->get("delta")->str());
+    EXPECT_EQ(exp_str_subnet, rep_all->get("subnet")->str());
+}
+
+// This test checks whether statistic-global-get-all command returns all statistics
+// correctly.
+TEST_F(StatsMgrTest, commandGlobalGetAll) {
+    // Set a couple of statistics
+    StatsMgr::instance().setValue("alpha", static_cast<int64_t>(1234));
+    StatsMgr::instance().setValue("beta", 12.34);
+    StatsMgr::instance().setValue("gamma", dur1234);
+    StatsMgr::instance().setValue("delta", "Lorem ipsum");
+    StatsMgr::instance().setValue("subnet", static_cast<int64_t>(5678));
+
+    // Now get them. They're used to generate expected output
+    ConstElementPtr rep_alpha = StatsMgr::instance().get("alpha");
+    ConstElementPtr rep_beta = StatsMgr::instance().get("beta");
+    ConstElementPtr rep_gamma = StatsMgr::instance().get("gamma");
+    ConstElementPtr rep_delta = StatsMgr::instance().get("delta");
+    ConstElementPtr rep_subnet = StatsMgr::instance().get("subnet");
+
+    ASSERT_TRUE(rep_alpha);
+    ASSERT_TRUE(rep_beta);
+    ASSERT_TRUE(rep_gamma);
+    ASSERT_TRUE(rep_delta);
+    ASSERT_TRUE(rep_subnet);
+
+    std::string exp_str_alpha = "[ [ 1234, \"" +
+        isc::util::clockToText(StatsMgr::instance().getObservation("alpha")
+                                   ->getInteger().second) + "\" ] ]";
+    std::string exp_str_beta = "[ [ 12.34, \"" +
+        isc::util::clockToText(StatsMgr::instance().getObservation("beta")
+                                   ->getFloat().second) + "\" ] ]";
+    std::string exp_str_gamma = "[ [ \"01:02:03.004000\", \"" +
+        isc::util::clockToText(StatsMgr::instance().getObservation("gamma")
+                                   ->getDuration().second) + "\" ] ]";
+    std::string exp_str_delta = "[ [ \"Lorem ipsum\", \"" +
+        isc::util::clockToText(StatsMgr::instance().getObservation("delta")
+                                   ->getString().second) + "\" ] ]";
+
+    // Check that all of them can be reported at once
+    ConstElementPtr rsp = StatsMgr::instance().statisticGlobalGetAllHandler(
+        "statistic-global-get-all", ElementPtr());
+    ASSERT_TRUE(rsp);
+    int status_code;
+    ConstElementPtr rep_all = parseAnswer(status_code, rsp);
+    ASSERT_EQ(0, status_code);
+    ASSERT_TRUE(rep_all);
+
     // Verifying this is a bit more involved, as we don't know whether the
     // order would be preserved or not.
     EXPECT_EQ(4, rep_all->size());
@@ -734,6 +802,7 @@ TEST_F(StatsMgrTest, commandGetAll) {
     ASSERT_TRUE(rep_all->get("beta"));
     ASSERT_TRUE(rep_all->get("delta"));
     ASSERT_TRUE(rep_all->get("gamma"));
+    ASSERT_FALSE(rep_all->get("subnet"));
     EXPECT_FALSE(rep_all->get("epsilon"));
 
     EXPECT_EQ(exp_str_alpha, rep_all->get("alpha")->str());
diff --git a/src/share/api/statistic-global-get-all.json b/src/share/api/statistic-global-get-all.json
new file mode 100644 (file)
index 0000000..e007da5
--- /dev/null
@@ -0,0 +1,404 @@
+{
+    "access": "read",
+    "avail": "3.1.2",
+    "brief": [
+        "This command retrieves all recorded global statistics (omitting subnet statistics)."
+    ],
+    "cmd-comment": [
+        "The server responds with the details of all recorded global statistics (omitting subnet statistics), with a result of 0 indicating that it iterated over all global statistics (even when the total number of global statistics is zero)."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"statistic-global-get-all\",",
+        "    \"arguments\": { }",
+        "}"
+    ],
+    "resp-syntax": [
+        "{",
+        "    \"result\": 0,",
+        "    \"arguments\": {",
+        "        \"assigned-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.836096\"",
+        "            ]",
+        "        ],",
+        "        \"cumulative-assigned-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.836166\"",
+        "            ]",
+        "        ],",
+        "        \"declined-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.836156\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-ack-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616247\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-ack-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616290\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-decline-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616296\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-discover-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616303\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-inform-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616308\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-nak-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616312\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-nak-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616314\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-offer-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616318\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-offer-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616323\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-parse-failed\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616326\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-receive-drop\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616330\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616335\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-release-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616339\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-request-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616343\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616348\"",
+        "            ]",
+        "        ],",
+        "        \"pkt4-unknown-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616354\"",
+        "            ]",
+        "        ],",
+        "        \"reclaimed-declined-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.836159\"",
+        "            ]",
+        "        ],",
+        "        \"reclaimed-leases\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.836163\"",
+        "            ]",
+        "        ],",
+        "        \"v4-allocation-fail\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616358\"",
+        "            ]",
+        "        ],",
+        "        \"v4-allocation-fail-classes\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616363\"",
+        "            ]",
+        "        ],",
+        "        \"v4-allocation-fail-no-pools\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616368\"",
+        "            ]",
+        "        ],",
+        "        \"v4-allocation-fail-shared-network\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616372\"",
+        "            ]",
+        "        ],",
+        "        \"v4-allocation-fail-subnet\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616376\"",
+        "            ]",
+        "        ],",
+        "        \"v4-lease-reuses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616410\"",
+        "            ]",
+        "        ],",
+        "        \"v4-reservation-conflicts\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 20:42:46.616412\"",
+        "            ]",
+        "        ]",
+        "    }",
+        "}",
+        "",
+        "or",
+        "",
+        "{",
+        "    \"result\": 0,",
+        "    \"arguments\": {",
+        "        \"assigned-nas\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196757\"",
+        "            ]",
+        "        ],",
+        "        \"assigned-pds\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196757\"",
+        "            ]",
+        "        ],",
+        "        \"cumulative-assigned-nas\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196757\"",
+        "            ]",
+        "        ],",
+        "        \"cumulative-assigned-pds\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196758\"",
+        "            ]",
+        "        ],",
+        "        \"declined-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196754\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-advertise-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177731\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-advertise-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177739\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-decline-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177739\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-dhcpv4-query-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177740\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-dhcpv4-response-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177740\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-dhcpv4-response-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177741\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-infrequest-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177742\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-parse-failed\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177742\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-rebind-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177743\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-receive-drop\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177743\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177744\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-release-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177744\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-renew-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177745\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-reply-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177745\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-reply-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177746\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-request-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177747\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-sent\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177747\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-solicit-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177748\"",
+        "            ]",
+        "        ],",
+        "        \"pkt6-unknown-received\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177748\"",
+        "            ]",
+        "        ],",
+        "        \"reclaimed-declined-addresses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196755\"",
+        "            ]",
+        "        ],",
+        "        \"reclaimed-leases\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.196756\"",
+        "            ]",
+        "        ],",
+        "        \"v6-allocation-fail\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177749\"",
+        "            ]",
+        "        ],",
+        "        \"v6-allocation-fail-classes\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177755\"",
+        "            ]",
+        "        ],",
+        "        \"v6-allocation-fail-no-pools\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177756\"",
+        "            ]",
+        "        ],",
+        "        \"v6-allocation-fail-shared-network\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177756\"",
+        "            ]",
+        "        ],",
+        "        \"v6-allocation-fail-subnet\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177757\"",
+        "            ]",
+        "        ],",
+        "        \"v6-ia-na-lease-reuses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177757\"",
+        "            ]",
+        "        ],",
+        "        \"v6-ia-pd-lease-reuses\": [",
+        "            [",
+        "                0,",
+        "                \"2023-06-13 21:28:57.177758\"",
+        "            ]",
+        "        ]",
+        "    }",
+        "}"
+    ],
+
+    "description": "See <xref linkend=\"command-statistic-global-get-all\"/>",
+    "name": "statistic-global-get-all",
+    "support": [
+        "kea-dhcp4",
+        "kea-dhcp6"
+    ]
+}