# Path: lighthouse/check.py
# class Check(Pluggable):
# class deque(collections.deque):
#     def __init__(self):
#     def validate_check_config(cls, config):
#     def apply_check_config(self, config):
#     def perform(self):
#     def run(self):
#     def last_n_results(self, n):
#     def apply_config(self, config):
#     def validate_config(cls, config):
#     def __init__(self, iterable=(), maxlen=None):
#     def maxlen(self):
# 
# Path: lighthouse/sockutils.py
# def get_response(sock, buffer_size=4096):


import logging
import socket
from lighthouse import check, sockutils
        self.query = config.get("query")
        self.expected_response = config.get("response")

    def perform(self):
        """
        Performs a straightforward TCP request and response.

        Sends the TCP `query` to the proper host and port, and loops over the
        socket, gathering response chunks until a full line is acquired.

        If the response line matches the expected value, the check passes. If
        not, the check fails.  The check will also fail if there's an error
        during any step of the send/receive process.
        """
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        sock.connect((self.host, self.port))

        # if no query/response is defined, a successful connection is a pass
        if not self.query:
            sock.close()
            return True

        try:
            sock.sendall(self.query)
        except Exception:
            logger.exception("Error sending TCP query message.")
            sock.close()
            return False


# Path: lighthouse/check.py
# class Check(Pluggable):
# class deque(collections.deque):
#     def __init__(self):
#     def validate_check_config(cls, config):
#     def apply_check_config(self, config):
#     def perform(self):
#     def run(self):
#     def last_n_results(self, n):
#     def apply_config(self, config):
#     def validate_config(cls, config):
#     def __init__(self, iterable=(), maxlen=None):
#     def maxlen(self):
# 
# Path: lighthouse/sockutils.py
# def get_response(sock, buffer_size=4096):


# Path: lighthouse/checks/tcp.py
import logging
import socket
from lighthouse import check, sockutils

        self.query = config.get("query")
        self.expected_response = config.get("response")

    def perform(self):
        """
        Performs a straightforward TCP request and response.

        Sends the TCP `query` to the proper host and port, and loops over the
        socket, gathering response chunks until a full line is acquired.

        If the response line matches the expected value, the check passes. If
        not, the check fails.  The check will also fail if there's an error
        during any step of the send/receive process.
        """
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        sock.connect((self.host, self.port))

        # if no query/response is defined, a successful connection is a pass
        if not self.query:
            sock.close()
            return True

        try:
            sock.sendall(self.query)
        except Exception:
            logger.exception("Error sending TCP query message.")
            sock.close()
            return False


        response, extra = sockutils.get_response(sock)