zookeeper_collector.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:ops_agent 作者: sjqzhang 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号