code: def is_agent_listening(self, host, port):
          
          try:
              rv = False
              url = "http://%s:%s/" % (host, port)
              response = self.client.get(url, timeout=0.8)
  
              server_header = response.headers["Server"]
              if server_header == AGENT_HEADER:
                  logger.debug("Host agent found on %s:%d" % (host, port))
                  rv = True
              else:
                  logger.debug("...something is listening on %s:%d but it's not the Instana Agent: %s"
                               % (host, port, server_header))
          except (requests.ConnectTimeout, requests.ConnectionError):
              logger.debug("No host agent listening on %s:%d" % (host, port))
              rv = False
          finally:
              return rv
docs: Check if the Instana Agent is listening on <host> and <port>.