in source/code/troubleshooter/modules/connect/check_endpts.py [0:0]
def check_log_analytics_endpts():
success = NO_ERROR
no_certs_printed = False
connected_err = []
verified_err = []
# get OMS endpoint to check if fairfax region
oms_endpt = geninfo_lookup('OMS_ENDPOINT')
if (oms_endpt == None):
error_info.append(('OMS endpoint', OMSADMIN_PATH))
return ERR_INFO_MISSING
# get workspace ID
workspace_id = geninfo_lookup('WORKSPACE_ID')
if (workspace_id == None):
error_info.append(('Workspace ID', OMSADMIN_PATH))
return ERR_INFO_MISSING
# get log analytics endpoints
if ('.us' in oms_endpt):
log_analytics_endpts = ["usge-jobruntimedata-prod-1.usgovtrafficmanager.net", \
"usge-agentservice-prod-1.usgovtrafficmanager.net", "*.ods.opinsights.azure.us", \
"*.oms.opinsights.azure.us"]
else:
log_analytics_endpts = ["*.ods.opinsights.azure.com", "*.oms.opinsights.azure.com", \
"ods.systemcenteradvisor.com"]
for endpt in log_analytics_endpts:
# replace '*' with workspace ID
if ('*' in endpt):
endpt = endpt.replace('*', workspace_id)
# check endpoint without certs
(la_connected, la_verified) = check_endpt_ssl(SSL_CMD, endpt)
if (not (la_connected or la_verified)):
# try with certs (if they exist)
if (os.path.isfile(CERT_PATH) and os.path.isfile(KEY_PATH)):
ssl_command = "{0} -cert {1} -key {2}".format(SSL_CMD, CERT_PATH, KEY_PATH)
(la_cert_connected, la_cert_verified) = check_endpt_ssl(ssl_command, endpt)
# didn't connect or verify with certs
if (not (la_cert_connected or la_cert_verified)):
connected_err.append((endpt, ssl_command.format(endpt)))
success = ERR_ENDPT
# connected but didn't verify with certs
elif (la_cert_connected and not la_cert_verified):
# haven't run into a connected error already
if (success != ERR_ENDPT):
verified_err.append((endpt, ssl_command.format(endpt)))
success = WARN_ENDPT
else:
# lets user know cert and key aren't there
if (not no_certs_printed):
print("NOTE: Certificate and key files don't exist, OMS isn't onboarded.")
no_certs_printed = True
# if certs didn't work at all, check to see if no certs was connected (but not verified)
if (la_connected and not la_verified):
# haven't run into a connected error already
if (success != ERR_ENDPT):
verified_err.append((endpt, SSL_CMD.format(endpt)))
success = WARN_ENDPT
# neither with nor without certs connected
connected_err.append((endpt, SSL_CMD.format(endpt)))
success = ERR_ENDPT
# if any connection issues found
if (success == ERR_ENDPT):
error_info.extend(connected_err)
# if no connection issues found but some verification issues found
elif (success == WARN_ENDPT):
error_info.extend(verified_err)
return success