Commit ca8b6a2f authored by litaolemo's avatar litaolemo

update

parent 25d9442b
......@@ -36,8 +36,13 @@ access_token = '6eb687358606347cef617237cddab6a80e2f5981b46fe04950a96152e387f35c
def get_cluster_stats(ip):
node_requests_url = "http://{ip}:9200/_cluster/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url)
if "@" in ip:
ip,auth = ip.split("@",1)
node_requests_url = "http://{ip}:9200/_cluster/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url, verify=False, auth=tuple(auth.split(':',1)))
else:
node_requests_url = "http://{ip}:9200/_cluster/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url)
res_json = node_requests_res.json()
stats = res_json.get("status")
timestamp = int(datetime.datetime.now().timestamp())
......@@ -58,8 +63,13 @@ def get_index_stats(ip,index):
def get_node_status(ip):
node_requests_url = "http://{ip}:9200/_nodes/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url)
if "@" in ip:
ip,auth = ip.split("@",1)
node_requests_url = "http://{ip}:9200/_nodes/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url, verify=False, auth=tuple(auth.split(':',1)))
else:
node_requests_url = "http://{ip}:9200/_nodes/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url)
res_json = node_requests_res.json()
# print(res_json)
for data_name in res_json["nodes"]:
......@@ -149,5 +159,5 @@ def main_task(ip_list):
if __name__ == "__main__":
# main_task('172.16.31.6')
ip_list = ['172.16.52.29','172.16.52.25','172.16.52.33']
ip_list = ['172.16.52.29','172.16.52.25@elastic:gengmei!@#','172.16.52.33@elastic:gengmei!@#']
main_task(ip_list)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment