From 6bd760a71f66639678932a7e9527e254f187f432 Mon Sep 17 00:00:00 2001 From: JackyWoo Date: Fri, 22 Mar 2024 18:27:21 +0800 Subject: [PATCH] Add metric is_leader --- docs/how-to-monitor-and-manage.md | 1 + src/Service/FourLetterCommand.cpp | 1 + tests/integration/test_four_word_command/test.py | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/how-to-monitor-and-manage.md b/docs/how-to-monitor-and-manage.md index fc17b30c6c..25fd21580f 100644 --- a/docs/how-to-monitor-and-manage.md +++ b/docs/how-to-monitor-and-manage.md @@ -46,6 +46,7 @@ zk_packets_sent 60406965 zk_num_alive_connections 0 zk_outstanding_requests 0 zk_server_state leader +zk_is_leader 1 zk_znode_count 2899570 zk_watch_count 0 zk_ephemerals_count 41933 diff --git a/src/Service/FourLetterCommand.cpp b/src/Service/FourLetterCommand.cpp index a6e733c988..932c7ee80a 100644 --- a/src/Service/FourLetterCommand.cpp +++ b/src/Service/FourLetterCommand.cpp @@ -251,6 +251,7 @@ String MonitorCommand::run() print(ret, "outstanding_requests", keeper_info.outstanding_requests_count); print(ret, "server_state", keeper_info.getRole()); + print(ret, "is_leader", keeper_info.is_leader); print(ret, "znode_count", state_machine.getNodesCount()); print(ret, "watch_count", state_machine.getTotalWatchesCount()); diff --git a/tests/integration/test_four_word_command/test.py b/tests/integration/test_four_word_command/test.py index cf47da617c..537f94031f 100644 --- a/tests/integration/test_four_word_command/test.py +++ b/tests/integration/test_four_word_command/test.py @@ -172,6 +172,7 @@ def test_cmd_mntr(started_cluster): assert int(result["zk_outstanding_requests"]) == 0 assert result["zk_server_state"] == "leader" + assert result["zk_is_leader"] == "1" # contains: # 10 nodes created by test