def check(self, config):
self.data = super(ZookeeperCollector, self).check(config)
try:
# command args
cx_args = (config['host'], config['zkcli_port'], config['timeout'])
# Read metrics from the `stat` output.
stat_out = self._send_command('stat', *cx_args)
self.data = self.parse_stat(stat_out, self.data)
# Read status from the `ruok` output.
ruok_out = self._send_command('ruok', *cx_args)
ruok_out.seek(0)
ruok = ruok_out.readline().strip()
if ruok == 'imok':
self.data['server.status'] = 0
else:
self.data['server.status'] = 1
except Exception, e:
print e.message
finally:
return self.data
评论列表
文章目录