Repository: JDRaftKeeper/RaftKeeper (language: cpp)

Issue:
Add metric `zk_is_leader` to mntr output
### Description
<!-- Describe the enhancement you want, including the motivation. -->

Our monitoring is based on `mntr` output, but  value of `zk_server_state` is an string. We can not track the leader switching history. So we need a number metric.

### Are you willing to submit PR?



Discussion / hints:

Fix patch:
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());


Test patch:
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