We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[zookeeper] bytes_outstanding metric returns number of requests served by zk node
User checking through the ZooKeeper check noticed that the bytes_outsanding metric the DD agent is scrapping is not bytes, but rather the number of inflight requests currently being serviced by the ZK node.

https://github.com/apache/zookeeper/blob/ca480231e1bdcbe6beda9142766fc3caa2031cd8/src/java/main/org/apache/zookeeper/server/ServerStats.java#L104

https://github.com/apache/zookeeper/blob/ca480231e1bdcbe6beda9142766fc3caa2031cd8/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java#L740


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `checks.d/zk.py`
Content:
```
1 '''
2 Parses the response from zookeeper's `stat` admin command, which looks like:
3 
4 ```
5 Zookeeper version: 3.2.2--1, built on 03/16/2010 07:31 GMT
6 Clients:
7  /10.42.114.160:32634[1](queued=0,recved=12,sent=0)
8  /10.37.137.74:21873[1](queued=0,recved=53613,sent=0)
9  /10.37.137.74:21876[1](queued=0,recved=57436,sent=0)
10  /10.115.77.32:32990[1](queued=0,recved=16,sent=0)
11  /10.37.137.74:21891[1](queued=0,recved=55011,sent=0)
12  /10.37.137.74:21797[1](queued=0,recved=19431,sent=0)
13 
14 Latency min/avg/max: -10/0/20007
15 Received: 101032173
16 Sent: 0
17 Outstanding: 0
18 Zxid: 0x1034799c7
19 Mode: leader
20 Node count: 487
21 ```
22 
23 Tested with Zookeeper versions 3.0.0 to 3.4.5
24 
25 '''
26 # stdlib
27 import re
28 import socket
29 import struct
30 from StringIO import StringIO
31 
32 # project
33 from checks import AgentCheck
34 
35 class ZKConnectionFailure(Exception):
36     """ Raised when we are unable to connect or get the output of a command. """
37     pass
38 
39 
40 class ZookeeperCheck(AgentCheck):
41     version_pattern = re.compile(r'Zookeeper version: ([^.]+)\.([^.]+)\.([^-]+)', flags=re.I)
42 
43     SOURCE_TYPE_NAME = 'zookeeper'
44 
45     def check(self, instance):
46         host = instance.get('host', 'localhost')
47         port = int(instance.get('port', 2181))
48         timeout = float(instance.get('timeout', 3.0))
49         expected_mode = (instance.get('expected_mode') or '').strip()
50         tags = instance.get('tags', [])
51         cx_args = (host, port, timeout)
52 
53         # Send a service check based on the `ruok` response.
54         try:
55             ruok_out = self._send_command('ruok', *cx_args)
56         except ZKConnectionFailure:
57             # The server should not respond at all if it's not OK.
58             status = AgentCheck.CRITICAL
59             message = 'No response from `ruok` command'
60             self.increment('zookeeper.timeouts')
61         else:
62             ruok_out.seek(0)
63             ruok = ruok_out.readline()
64             if ruok == 'imok':
65                 status = AgentCheck.OK
66             else:
67                 status = AgentCheck.WARNING
68             message = u'Response from the server: %s' % ruok
69         self.service_check('zookeeper.ruok', status, message=message)
70 
71         # Read metrics from the `stat` output.
72         try:
73             stat_out = self._send_command('stat', *cx_args)
74         except ZKConnectionFailure:
75             self.increment('zookeeper.timeouts')
76         else:
77             # Parse the response
78             metrics, new_tags, mode = self.parse_stat(stat_out)
79 
80             # Write the data
81             for metric, value in metrics:
82                 self.gauge(metric, value, tags=tags + new_tags)
83 
84             if expected_mode:
85                 if mode == expected_mode:
86                     status = AgentCheck.OK
87                     message = u"Server is in %s mode" % mode
88                 else:
89                     status = AgentCheck.CRITICAL
90                     message = u"Server is in %s mode but check expects %s mode" % (expected_mode, mode)
91                 self.service_check('zookeeper.mode', status, message=message)
92 
93     def _send_command(self, command, host, port, timeout):
94         sock = socket.socket()
95         sock.settimeout(timeout)
96         buf = StringIO()
97         chunk_size = 1024
98         # try-finally and try-except to stay compatible with python 2.4
99         try:
100             try:
101                 # Connect to the zk client port and send the stat command
102                 sock.connect((host, port))
103                 sock.sendall(command)
104 
105                 # Read the response into a StringIO buffer
106                 chunk = sock.recv(chunk_size)
107                 buf.write(chunk)
108                 num_reads = 1
109                 max_reads = 10000
110                 while chunk:
111                     if num_reads > max_reads:
112                         # Safeguard against an infinite loop
113                         raise Exception("Read %s bytes before exceeding max reads of %s. " % (buf.tell(), max_reads))
114                     chunk = sock.recv(chunk_size)
115                     buf.write(chunk)
116                     num_reads += 1
117             except (socket.timeout, socket.error):
118                 raise ZKConnectionFailure()
119         finally:
120             sock.close()
121         return buf
122 
123     def parse_stat(self, buf):
124         ''' `buf` is a readable file-like object
125             returns a tuple: ([(metric_name, value)], tags)
126         '''
127         metrics = []
128         buf.seek(0)
129 
130         # Check the version line to make sure we parse the rest of the
131         # body correctly. Particularly, the Connections val was added in
132         # >= 3.4.4.
133         start_line = buf.readline()
134         match = self.version_pattern.match(start_line)
135         if match is None:
136             raise Exception("Could not parse version from stat command output: %s" % start_line)
137         else:
138             version_tuple = match.groups()
139         has_connections_val = version_tuple >= ('3', '4', '4')
140 
141         # Clients:
142         buf.readline() # skip the Clients: header
143         connections = 0
144         client_line = buf.readline().strip()
145         if client_line:
146             connections += 1
147         while client_line:
148             client_line = buf.readline().strip()
149             if client_line:
150                 connections += 1
151 
152         # Latency min/avg/max: -10/0/20007
153         _, value = buf.readline().split(':')
154         l_min, l_avg, l_max = [int(v) for v in value.strip().split('/')]
155         metrics.append(('zookeeper.latency.min', l_min))
156         metrics.append(('zookeeper.latency.avg', l_avg))
157         metrics.append(('zookeeper.latency.max', l_max))
158 
159         # Received: 101032173
160         _, value = buf.readline().split(':')
161         metrics.append(('zookeeper.bytes_received', long(value.strip())))
162 
163         # Sent: 1324
164         _, value = buf.readline().split(':')
165         metrics.append(('zookeeper.bytes_sent', long(value.strip())))
166 
167         if has_connections_val:
168             # Connections: 1
169             _, value = buf.readline().split(':')
170             metrics.append(('zookeeper.connections', int(value.strip())))
171         else:
172             # If the zk version doesnt explicitly give the Connections val,
173             # use the value we computed from the client list.
174             metrics.append(('zookeeper.connections', connections))
175 
176         # Outstanding: 0
177         _, value = buf.readline().split(':')
178         metrics.append(('zookeeper.bytes_outstanding', long(value.strip())))
179 
180         # Zxid: 0x1034799c7
181         _, value = buf.readline().split(':')
182         # Parse as a 64 bit hex int
183         zxid = long(value.strip(), 16)
184         # convert to bytes
185         zxid_bytes = struct.pack('>q', zxid)
186         # the higher order 4 bytes is the epoch
187         (zxid_epoch,) = struct.unpack('>i', zxid_bytes[0:4])
188         # the lower order 4 bytes is the count
189         (zxid_count,) = struct.unpack('>i', zxid_bytes[4:8])
190 
191         metrics.append(('zookeeper.zxid.epoch', zxid_epoch))
192         metrics.append(('zookeeper.zxid.count', zxid_count))
193 
194         # Mode: leader
195         _, value = buf.readline().split(':')
196         mode = value.strip().lower()
197         tags = [u'mode:' + mode]
198 
199         # Node count: 487
200         _, value = buf.readline().split(':')
201         metrics.append(('zookeeper.nodes', long(value.strip())))
202 
203         return metrics, tags, mode
204
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/checks.d/zk.py b/checks.d/zk.py
--- a/checks.d/zk.py
+++ b/checks.d/zk.py
@@ -175,7 +175,10 @@
 
         # Outstanding: 0
         _, value = buf.readline().split(':')
+        # Fixme: This metric name is wrong. It should be removed in a major version of the agent
+        # See https://github.com/DataDog/dd-agent/issues/1383
         metrics.append(('zookeeper.bytes_outstanding', long(value.strip())))
+        metrics.append(('zookeeper.outstanding_requests', long(value.strip())))
 
         # Zxid: 0x1034799c7
         _, value = buf.readline().split(':')

{"golden_diff": "diff --git a/checks.d/zk.py b/checks.d/zk.py\n--- a/checks.d/zk.py\n+++ b/checks.d/zk.py\n@@ -175,7 +175,10 @@\n \n         # Outstanding: 0\n         _, value = buf.readline().split(':')\n+        # Fixme: This metric name is wrong. It should be removed in a major version of the agent\n+        # See https://github.com/DataDog/dd-agent/issues/1383\n         metrics.append(('zookeeper.bytes_outstanding', long(value.strip())))\n+        metrics.append(('zookeeper.outstanding_requests', long(value.strip())))\n \n         # Zxid: 0x1034799c7\n         _, value = buf.readline().split(':')\n", "issue": "[zookeeper] bytes_outstanding metric returns number of requests served by zk node\nUser checking through the ZooKeeper check noticed that the bytes_outsanding metric the DD agent is scrapping is not bytes, but rather the number of inflight requests currently being serviced by the ZK node.\n\nhttps://github.com/apache/zookeeper/blob/ca480231e1bdcbe6beda9142766fc3caa2031cd8/src/java/main/org/apache/zookeeper/server/ServerStats.java#L104\n\nhttps://github.com/apache/zookeeper/blob/ca480231e1bdcbe6beda9142766fc3caa2031cd8/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java#L740\n\n", "before_files": [{"content": "'''\nParses the response from zookeeper's `stat` admin command, which looks like:\n\n```\nZookeeper version: 3.2.2--1, built on 03/16/2010 07:31 GMT\nClients:\n /10.42.114.160:32634[1](queued=0,recved=12,sent=0)\n /10.37.137.74:21873[1](queued=0,recved=53613,sent=0)\n /10.37.137.74:21876[1](queued=0,recved=57436,sent=0)\n /10.115.77.32:32990[1](queued=0,recved=16,sent=0)\n /10.37.137.74:21891[1](queued=0,recved=55011,sent=0)\n /10.37.137.74:21797[1](queued=0,recved=19431,sent=0)\n\nLatency min/avg/max: -10/0/20007\nReceived: 101032173\nSent: 0\nOutstanding: 0\nZxid: 0x1034799c7\nMode: leader\nNode count: 487\n```\n\nTested with Zookeeper versions 3.0.0 to 3.4.5\n\n'''\n# stdlib\nimport re\nimport socket\nimport struct\nfrom StringIO import StringIO\n\n# project\nfrom checks import AgentCheck\n\nclass ZKConnectionFailure(Exception):\n    \"\"\" Raised when we are unable to connect or get the output of a command. \"\"\"\n    pass\n\n\nclass ZookeeperCheck(AgentCheck):\n    version_pattern = re.compile(r'Zookeeper version: ([^.]+)\\.([^.]+)\\.([^-]+)', flags=re.I)\n\n    SOURCE_TYPE_NAME = 'zookeeper'\n\n    def check(self, instance):\n        host = instance.get('host', 'localhost')\n        port = int(instance.get('port', 2181))\n        timeout = float(instance.get('timeout', 3.0))\n        expected_mode = (instance.get('expected_mode') or '').strip()\n        tags = instance.get('tags', [])\n        cx_args = (host, port, timeout)\n\n        # Send a service check based on the `ruok` response.\n        try:\n            ruok_out = self._send_command('ruok', *cx_args)\n        except ZKConnectionFailure:\n            # The server should not respond at all if it's not OK.\n            status = AgentCheck.CRITICAL\n            message = 'No response from `ruok` command'\n            self.increment('zookeeper.timeouts')\n        else:\n            ruok_out.seek(0)\n            ruok = ruok_out.readline()\n            if ruok == 'imok':\n                status = AgentCheck.OK\n            else:\n                status = AgentCheck.WARNING\n            message = u'Response from the server: %s' % ruok\n        self.service_check('zookeeper.ruok', status, message=message)\n\n        # Read metrics from the `stat` output.\n        try:\n            stat_out = self._send_command('stat', *cx_args)\n        except ZKConnectionFailure:\n            self.increment('zookeeper.timeouts')\n        else:\n            # Parse the response\n            metrics, new_tags, mode = self.parse_stat(stat_out)\n\n            # Write the data\n            for metric, value in metrics:\n                self.gauge(metric, value, tags=tags + new_tags)\n\n            if expected_mode:\n                if mode == expected_mode:\n                    status = AgentCheck.OK\n                    message = u\"Server is in %s mode\" % mode\n                else:\n                    status = AgentCheck.CRITICAL\n                    message = u\"Server is in %s mode but check expects %s mode\" % (expected_mode, mode)\n                self.service_check('zookeeper.mode', status, message=message)\n\n    def _send_command(self, command, host, port, timeout):\n        sock = socket.socket()\n        sock.settimeout(timeout)\n        buf = StringIO()\n        chunk_size = 1024\n        # try-finally and try-except to stay compatible with python 2.4\n        try:\n            try:\n                # Connect to the zk client port and send the stat command\n                sock.connect((host, port))\n                sock.sendall(command)\n\n                # Read the response into a StringIO buffer\n                chunk = sock.recv(chunk_size)\n                buf.write(chunk)\n                num_reads = 1\n                max_reads = 10000\n                while chunk:\n                    if num_reads > max_reads:\n                        # Safeguard against an infinite loop\n                        raise Exception(\"Read %s bytes before exceeding max reads of %s. \" % (buf.tell(), max_reads))\n                    chunk = sock.recv(chunk_size)\n                    buf.write(chunk)\n                    num_reads += 1\n            except (socket.timeout, socket.error):\n                raise ZKConnectionFailure()\n        finally:\n            sock.close()\n        return buf\n\n    def parse_stat(self, buf):\n        ''' `buf` is a readable file-like object\n            returns a tuple: ([(metric_name, value)], tags)\n        '''\n        metrics = []\n        buf.seek(0)\n\n        # Check the version line to make sure we parse the rest of the\n        # body correctly. Particularly, the Connections val was added in\n        # >= 3.4.4.\n        start_line = buf.readline()\n        match = self.version_pattern.match(start_line)\n        if match is None:\n            raise Exception(\"Could not parse version from stat command output: %s\" % start_line)\n        else:\n            version_tuple = match.groups()\n        has_connections_val = version_tuple >= ('3', '4', '4')\n\n        # Clients:\n        buf.readline() # skip the Clients: header\n        connections = 0\n        client_line = buf.readline().strip()\n        if client_line:\n            connections += 1\n        while client_line:\n            client_line = buf.readline().strip()\n            if client_line:\n                connections += 1\n\n        # Latency min/avg/max: -10/0/20007\n        _, value = buf.readline().split(':')\n        l_min, l_avg, l_max = [int(v) for v in value.strip().split('/')]\n        metrics.append(('zookeeper.latency.min', l_min))\n        metrics.append(('zookeeper.latency.avg', l_avg))\n        metrics.append(('zookeeper.latency.max', l_max))\n\n        # Received: 101032173\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.bytes_received', long(value.strip())))\n\n        # Sent: 1324\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.bytes_sent', long(value.strip())))\n\n        if has_connections_val:\n            # Connections: 1\n            _, value = buf.readline().split(':')\n            metrics.append(('zookeeper.connections', int(value.strip())))\n        else:\n            # If the zk version doesnt explicitly give the Connections val,\n            # use the value we computed from the client list.\n            metrics.append(('zookeeper.connections', connections))\n\n        # Outstanding: 0\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.bytes_outstanding', long(value.strip())))\n\n        # Zxid: 0x1034799c7\n        _, value = buf.readline().split(':')\n        # Parse as a 64 bit hex int\n        zxid = long(value.strip(), 16)\n        # convert to bytes\n        zxid_bytes = struct.pack('>q', zxid)\n        # the higher order 4 bytes is the epoch\n        (zxid_epoch,) = struct.unpack('>i', zxid_bytes[0:4])\n        # the lower order 4 bytes is the count\n        (zxid_count,) = struct.unpack('>i', zxid_bytes[4:8])\n\n        metrics.append(('zookeeper.zxid.epoch', zxid_epoch))\n        metrics.append(('zookeeper.zxid.count', zxid_count))\n\n        # Mode: leader\n        _, value = buf.readline().split(':')\n        mode = value.strip().lower()\n        tags = [u'mode:' + mode]\n\n        # Node count: 487\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.nodes', long(value.strip())))\n\n        return metrics, tags, mode\n", "path": "checks.d/zk.py"}], "after_files": [{"content": "'''\nParses the response from zookeeper's `stat` admin command, which looks like:\n\n```\nZookeeper version: 3.2.2--1, built on 03/16/2010 07:31 GMT\nClients:\n /10.42.114.160:32634[1](queued=0,recved=12,sent=0)\n /10.37.137.74:21873[1](queued=0,recved=53613,sent=0)\n /10.37.137.74:21876[1](queued=0,recved=57436,sent=0)\n /10.115.77.32:32990[1](queued=0,recved=16,sent=0)\n /10.37.137.74:21891[1](queued=0,recved=55011,sent=0)\n /10.37.137.74:21797[1](queued=0,recved=19431,sent=0)\n\nLatency min/avg/max: -10/0/20007\nReceived: 101032173\nSent: 0\nOutstanding: 0\nZxid: 0x1034799c7\nMode: leader\nNode count: 487\n```\n\nTested with Zookeeper versions 3.0.0 to 3.4.5\n\n'''\n# stdlib\nimport re\nimport socket\nimport struct\nfrom StringIO import StringIO\n\n# project\nfrom checks import AgentCheck\n\nclass ZKConnectionFailure(Exception):\n    \"\"\" Raised when we are unable to connect or get the output of a command. \"\"\"\n    pass\n\n\nclass ZookeeperCheck(AgentCheck):\n    version_pattern = re.compile(r'Zookeeper version: ([^.]+)\\.([^.]+)\\.([^-]+)', flags=re.I)\n\n    SOURCE_TYPE_NAME = 'zookeeper'\n\n    def check(self, instance):\n        host = instance.get('host', 'localhost')\n        port = int(instance.get('port', 2181))\n        timeout = float(instance.get('timeout', 3.0))\n        expected_mode = (instance.get('expected_mode') or '').strip()\n        tags = instance.get('tags', [])\n        cx_args = (host, port, timeout)\n\n        # Send a service check based on the `ruok` response.\n        try:\n            ruok_out = self._send_command('ruok', *cx_args)\n        except ZKConnectionFailure:\n            # The server should not respond at all if it's not OK.\n            status = AgentCheck.CRITICAL\n            message = 'No response from `ruok` command'\n            self.increment('zookeeper.timeouts')\n        else:\n            ruok_out.seek(0)\n            ruok = ruok_out.readline()\n            if ruok == 'imok':\n                status = AgentCheck.OK\n            else:\n                status = AgentCheck.WARNING\n            message = u'Response from the server: %s' % ruok\n        self.service_check('zookeeper.ruok', status, message=message)\n\n        # Read metrics from the `stat` output.\n        try:\n            stat_out = self._send_command('stat', *cx_args)\n        except ZKConnectionFailure:\n            self.increment('zookeeper.timeouts')\n        else:\n            # Parse the response\n            metrics, new_tags, mode = self.parse_stat(stat_out)\n\n            # Write the data\n            for metric, value in metrics:\n                self.gauge(metric, value, tags=tags + new_tags)\n\n            if expected_mode:\n                if mode == expected_mode:\n                    status = AgentCheck.OK\n                    message = u\"Server is in %s mode\" % mode\n                else:\n                    status = AgentCheck.CRITICAL\n                    message = u\"Server is in %s mode but check expects %s mode\" % (expected_mode, mode)\n                self.service_check('zookeeper.mode', status, message=message)\n\n    def _send_command(self, command, host, port, timeout):\n        sock = socket.socket()\n        sock.settimeout(timeout)\n        buf = StringIO()\n        chunk_size = 1024\n        # try-finally and try-except to stay compatible with python 2.4\n        try:\n            try:\n                # Connect to the zk client port and send the stat command\n                sock.connect((host, port))\n                sock.sendall(command)\n\n                # Read the response into a StringIO buffer\n                chunk = sock.recv(chunk_size)\n                buf.write(chunk)\n                num_reads = 1\n                max_reads = 10000\n                while chunk:\n                    if num_reads > max_reads:\n                        # Safeguard against an infinite loop\n                        raise Exception(\"Read %s bytes before exceeding max reads of %s. \" % (buf.tell(), max_reads))\n                    chunk = sock.recv(chunk_size)\n                    buf.write(chunk)\n                    num_reads += 1\n            except (socket.timeout, socket.error):\n                raise ZKConnectionFailure()\n        finally:\n            sock.close()\n        return buf\n\n    def parse_stat(self, buf):\n        ''' `buf` is a readable file-like object\n            returns a tuple: ([(metric_name, value)], tags)\n        '''\n        metrics = []\n        buf.seek(0)\n\n        # Check the version line to make sure we parse the rest of the\n        # body correctly. Particularly, the Connections val was added in\n        # >= 3.4.4.\n        start_line = buf.readline()\n        match = self.version_pattern.match(start_line)\n        if match is None:\n            raise Exception(\"Could not parse version from stat command output: %s\" % start_line)\n        else:\n            version_tuple = match.groups()\n        has_connections_val = version_tuple >= ('3', '4', '4')\n\n        # Clients:\n        buf.readline() # skip the Clients: header\n        connections = 0\n        client_line = buf.readline().strip()\n        if client_line:\n            connections += 1\n        while client_line:\n            client_line = buf.readline().strip()\n            if client_line:\n                connections += 1\n\n        # Latency min/avg/max: -10/0/20007\n        _, value = buf.readline().split(':')\n        l_min, l_avg, l_max = [int(v) for v in value.strip().split('/')]\n        metrics.append(('zookeeper.latency.min', l_min))\n        metrics.append(('zookeeper.latency.avg', l_avg))\n        metrics.append(('zookeeper.latency.max', l_max))\n\n        # Received: 101032173\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.bytes_received', long(value.strip())))\n\n        # Sent: 1324\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.bytes_sent', long(value.strip())))\n\n        if has_connections_val:\n            # Connections: 1\n            _, value = buf.readline().split(':')\n            metrics.append(('zookeeper.connections', int(value.strip())))\n        else:\n            # If the zk version doesnt explicitly give the Connections val,\n            # use the value we computed from the client list.\n            metrics.append(('zookeeper.connections', connections))\n\n        # Outstanding: 0\n        _, value = buf.readline().split(':')\n        # Fixme: This metric name is wrong. It should be removed in a major version of the agent\n        # See https://github.com/DataDog/dd-agent/issues/1383\n        metrics.append(('zookeeper.bytes_outstanding', long(value.strip())))\n        metrics.append(('zookeeper.outstanding_requests', long(value.strip())))\n\n        # Zxid: 0x1034799c7\n        _, value = buf.readline().split(':')\n        # Parse as a 64 bit hex int\n        zxid = long(value.strip(), 16)\n        # convert to bytes\n        zxid_bytes = struct.pack('>q', zxid)\n        # the higher order 4 bytes is the epoch\n        (zxid_epoch,) = struct.unpack('>i', zxid_bytes[0:4])\n        # the lower order 4 bytes is the count\n        (zxid_count,) = struct.unpack('>i', zxid_bytes[4:8])\n\n        metrics.append(('zookeeper.zxid.epoch', zxid_epoch))\n        metrics.append(('zookeeper.zxid.count', zxid_count))\n\n        # Mode: leader\n        _, value = buf.readline().split(':')\n        mode = value.strip().lower()\n        tags = [u'mode:' + mode]\n\n        # Node count: 487\n        _, value = buf.readline().split(':')\n        metrics.append(('zookeeper.nodes', long(value.strip())))\n\n        return metrics, tags, mode\n", "path": "checks.d/zk.py"}]}