'The Mesos agent runs on every node and listens to http port 5051
See https://mesos.apache.org/documentation/latest/endpoints/
We\'ll use the unauthenticated endpoint /version
The DCOS agent runs on every node and listens to ports 61001 or 61002
See https://dcos.io/docs/1.9/api/agent-routes/
We\'ll use the unauthenticated endpoint /system/health/v1'

def _detect_agents(self):

    mesos_urls = []
    dcos_urls = []
    for var in MESOS_AGENT_IP_ENV:
        if (var in os.environ):
            mesos_urls.append((MESOS_VERSION_URL_TEMPLATE % (os.environ.get(var), MESOS_AGENT_HTTP_PORT)))
            dcos_urls.append((DCOS_HEALTH_URL_TEMPLATE % (os.environ.get(var), DCOS_AGENT_HTTP_PORT)))
            dcos_urls.append((DCOS_HEALTH_URL_TEMPLATE % (os.environ.get(var), DOCS_AGENT_HTTPS_PORT)))
    gw = self.docker_util.get_gateway()
    if gw:
        mesos_urls.append((MESOS_VERSION_URL_TEMPLATE % (gw, MESOS_AGENT_HTTP_PORT)))
        dcos_urls.append((DCOS_HEALTH_URL_TEMPLATE % (gw, DCOS_AGENT_HTTP_PORT)))
        dcos_urls.append((DCOS_HEALTH_URL_TEMPLATE % (gw, DOCS_AGENT_HTTPS_PORT)))
    mesos_url = self._try_urls(mesos_urls, validation_lambda=MesosUtil.mesos_agent_validation)
    if mesos_url:
        self.log.debug(('Found    Mesos    agent    at    ' + mesos_url))
    else:
        self.log.debug(('Could    not    find    Mesos    agent    at    urls    ' + str(mesos_urls)))
    dcos_url = self._try_urls(dcos_urls, validation_lambda=MesosUtil.dcos_agent_validation)
    if dcos_url:
        self.log.debug(('Found    DCOS    agent    at    ' + dcos_url))
    else:
        self.log.debug(('Could    not    find    DCOS    agent    at    urls    ' + str(dcos_urls)))
    return (mesos_url, dcos_url)
