Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Support "This ZooKeeper instance is not currently serving requests" #17

Open
TomaszUrugOlszewski opened this issue May 14, 2018 · 0 comments

Comments

@TomaszUrugOlszewski
Copy link

TomaszUrugOlszewski commented May 14, 2018

Hello,

When there is no leader in Zookeeper, stat command returns :

echo stat | nc 10.0.0.7 2181
This ZooKeeper instance is not currently serving requests

Monitoring script check_zookeeper.py can't handle this situation gracefuly, and dies with

/etc/sensu/plugins/check_zookeeper.py -s 10.0.0.7:2181,10.0.0.8:2181,10.0.0.9:2181 -o nagios -w 1 -c 0 -k zk_followers
Traceback (most recent call last):
  File "/etc/sensu/plugins/check_zookeeper.py", line 369, in <module>
    sys.exit(main())
  File "/etc/sensu/plugins/check_zookeeper.py", line 287, in main
    cluster_stats = get_cluster_stats(opts.servers)
  File "/etc/sensu/plugins/check_zookeeper.py", line 325, in get_cluster_stats
    stats["%s:%s" % (host, port)] = zk.get_stats()
  File "/etc/sensu/plugins/check_zookeeper.py", line 172, in get_stats
    stat = self._parse_stat(self._send_cmd('stat'))
  File "/etc/sensu/plugins/check_zookeeper.py", line 221, in _parse_stat
    result['zk_version'] = version[version.index(':')+1:].strip()
ValueError: substring not found

Problem exists here (change in lines 218-221 is my dirty hack):

214     def _parse_stat(self, data):
215         """ Parse the output from the 'stat' 4letter word command """
216         h = StringIO(data)
217 
218         not_serving_requests = re.match("^This ZooKeeper instance is not", data)
219         if not_serving_requests:
220            print("CRITICAL: Zookeeper is out of quorum, not serving requests")
221            sys.exit(2)
222         
223         result = {}
224         
225         version = h.readline()
226         if version:
227             result['zk_version'] = version[version.index(':')+1:].strip()

I'm not sure how to fix it in legitimate way :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant