in AzureMonitorAgent/ama_tst/modules/connect/check_endpts.py [0:0]
def check_ama_endpts():
# compose URLs to check
endpoints = [GLOBAL_HANDLER_URL]
regions = geninfo_lookup('DCR_REGION')
workspace_ids = geninfo_lookup('DCR_WORKSPACE_ID')
if regions == None or workspace_ids == None:
return ERR_INFO_MISSING
for region in regions:
endpoints.append(REGION_HANDLER_URL.format(region))
for id in workspace_ids:
endpoints.append(ODS_URL.format(id))
if not geninfo_lookup('ME_REGION') == None:
endpoints.append(ME_URL)
for me_region in geninfo_lookup('ME_REGION'):
endpoints.append(ME_REGION_URL.format(me_region))
# modify URLs if URL suffix is .us(Azure Government) or .cn(Azure China)
url_suffix = geninfo_lookup('URL_SUFFIX')
if not url_suffix == '.com':
for endpoint in endpoints:
endpoint.replace('.com', url_suffix)
dce, e = find_dce()
if e != None:
error_info.append((e,))
return ERR_DCE
for endpoint in dce:
endpoints.append(endpoint)
for endpoint in endpoints:
# check if IP address can be resolved using nslookup
resolved, e = resolve_ip(endpoint)
if not resolved:
error_info.append((endpoint,e))
return ERR_RESOLVE_IP
# check ssl handshake
command = SSL_CMD
# skip openssl check with authenticated proxy
if not geninfo_lookup('MDSD_PROXY_USERNAME') == None:
return WARN_OPENSSL_PROXY
proxy = geninfo_lookup('MDSD_PROXY_ADDRESS')
if not proxy == None:
proxy = proxy.replace('http://', '')
command = command + ' -proxy {0}'.format(proxy)
if not geninfo_lookup('SSL_CERT_DIR') == None:
command = command + " -CApath " + geninfo_lookup('SSL_CERT_DIR')
if not geninfo_lookup('SSL_CERT_FILE') == None:
command = command + " -CAfile " + geninfo_lookup('SSL_CERT_FILE')
(connected, verified, e) = check_endpt_ssl(command, endpoint)
if not connected or not verified:
error_info.append((endpoint, command.format(endpoint), e))
return ERR_ENDPT
# check AMCS ping results
if "handler.control.monitor" in endpoint:
checked_curl = check_endpt_curl(endpoint)
if checked_curl != NO_ERROR:
return checked_curl
return NO_ERROR