def run(self):
        if 'ZooKeeper' not in self.raw_config:
            host = 'localhost'
            port = 2181
        else:
            host = self.raw_config['ZooKeeper'].get(
                'host', 'localhost')
            port = int(self.raw_config['ZooKeeper'].get(
                'port', '2181'))

        data = {}
        data['imok'] = 1

        self.checks_logger.debug('ZooKeeper_plugin: started gathering data')

        for command in self.zookeeper_commands:

            try:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

                # set a timeout for socket operation
                s.settimeout(4)

                s.connect(
                    (host, port)
                )

                s.sendall(command)
                reply = s.recv(1024)
                if command == 'conf':
                    data = self.convert_conf(data, reply)
                elif command == 'ruok':
                    data = self.convert_ruok(data, reply)
                elif command == 'srvr':
                    data = self.convert_srvr(data, reply)
                elif command == 'mntr':
                    data = self.convert_mntr(data, reply)

                del s
            except Exception as exception:
                self.checks_logger.error(
                    'ZooKeeper_plugin: failed to read from socket. Error: {0}'
                    .format(exception.message))

        self.checks_logger.debug('ZooKeeper_plugin: completed, returning')

        return data
dataset/ETHPy150Open serverdensity/sd-agent-plugins/ZooKeeper/ZooKeeper.py/ZooKeeper.run/original