zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2950: Add keys for the Zxid from the stat command to check_zookeeper.py
Date Tue, 12 Dec 2017 18:45:08 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.5 333dc47b3 -> 9757839c0


ZOOKEEPER-2950: Add keys for the Zxid from the stat command to check_zookeeper.py

Add keys for the zxid and its component pieces: epoch and transaction counter. These are not
reported by the 'mntr' command so they must be obtained from 'stat'. The counter is useful
for tracking transaction rates, and epoch is useful for tracking leader churn.

 zk_zxid         - the 64bit zxid from ZK
 zk_zxid_counter - the lower 32 bits, AKA the counter
 zk_zxid_epoch   - the upper 32 bits, AKA the epoch

Author: Alex Bame <alex@724support.com>

Reviewers: phunt@apache.org

Closes #425 from alexbb/add_zxid_stats and squashes the following commits:

8dfdc9fc [Alex Bame] leave zk_zxid in hex
874628db [Alex Bame] add keys for the Zxid from the stat command:  zk_zxid         - the 64bit
zxid from ZK  zk_zxid_counter - the lower 32 bits, AKA the counter  zk_zxid_epoch   - the
upper 32 bits, AKA the epoch

Change-Id: I5b43b8e27deab23669c7b44f777ddb02f50db4aa
(cherry picked from commit 9e30b9bf8fac56db3846c8cc42997cdc23a9358d)
Signed-off-by: Patrick Hunt <phunt@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/9757839c
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/9757839c
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/9757839c

Branch: refs/heads/branch-3.5
Commit: 9757839c0bacc51267fbe2d9c8753d4d354d752c
Parents: 333dc47
Author: Alex Bame <alex@724support.com>
Authored: Tue Dec 12 10:44:32 2017 -0800
Committer: Patrick Hunt <phunt@apache.org>
Committed: Tue Dec 12 10:45:03 2017 -0800

----------------------------------------------------------------------
 src/contrib/monitoring/check_zookeeper.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/9757839c/src/contrib/monitoring/check_zookeeper.py
----------------------------------------------------------------------
diff --git a/src/contrib/monitoring/check_zookeeper.py b/src/contrib/monitoring/check_zookeeper.py
index c00db8b..568d517 100755
--- a/src/contrib/monitoring/check_zookeeper.py
+++ b/src/contrib/monitoring/check_zookeeper.py
@@ -169,11 +169,16 @@ class ZooKeeperServer(object):
     def get_stats(self):
         """ Get ZooKeeper server stats as a map """
         data = self._send_cmd('mntr')
+        stat = self._parse_stat(self._send_cmd('stat'))
         if data:
-            return self._parse(data)
+            mntr = self._parse(data)
+            missing = ['zk_zxid', 'zk_zxid_counter', 'zk_zxid_epoch']
+            for m in missing:
+                if m in stat:
+                    mntr[m] = stat[m]
+            return mntr
         else:
-            data = self._send_cmd('stat')
-            return self._parse_stat(data)
+            return stat
 
     def _create_socket(self):
         return socket.socket()
@@ -251,6 +256,13 @@ class ZooKeeperServer(object):
                 result['zk_znode_count'] = int(m.group(1))
                 continue
 
+            m = re.match('Zxid: (0x[0-9a-fA-F]+)', line)
+            if m is not None:
+                result['zk_zxid']         = m.group(1)
+                result['zk_zxid_counter'] = int(m.group(1), 16) & int('0xffffffff', 16)
# lower 32 bits
+                result['zk_zxid_epoch']   = int(m.group(1), 16) >>32 # high 32 bits
+                continue
+
         return result 
 
     def _parse_line(self, line):


Mime
View raw message