Skip to content

Commit

Permalink
Merge pull request #7 from monobaila/override_service_health
Browse files Browse the repository at this point in the history
Update zk_service_health metric when not serving.
  • Loading branch information
mpetazzoni authored Apr 21, 2017
2 parents a76f359 + bb4728e commit 2e5d662
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ All metrics are reported with the `plugin:zookeeper` dimension. Additionally,
if you specify an `Instance` in your `Module` configuration block, its value
will be reported as the `plugin_instance` dimension.

zk_is_leader is a synthetic metric which is 0 iff the contents of zk_server_state is 'follower'
zk_is_leader is a synthetic metric which is 0 if the contents of zk_server_state is 'follower'.
zk_service_health is a synthetic metric which tracks if service is running and servicing requests.

# License

Expand Down
9 changes: 9 additions & 0 deletions zk-collectd.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ def _get_mntr_stats(self):
response = self._send_cmd(MNTR_CMD)
result = {}

# If instance stops serving requests (e.g. loses quorum) it still
# returns "imok" to ruok query but will force close any client
# connections and return an error string to all other 4 letter commands.
# In this situation we should override zk_service_health metric
# initially set in _get_health_stat as it's definitely not in a healthy
# state.
if response == 'This ZooKeeper instance is not currently serving requests\n':
return {'zk_service_health': 0}

for line in response.splitlines():
try:
key, value = self._parse_line(line)
Expand Down

0 comments on commit 2e5d662

Please sign in to comment.