Commit ca8b6a2f authored by litaolemo's avatar litaolemo

update

parent 25d9442b
...@@ -36,6 +36,11 @@ access_token = '6eb687358606347cef617237cddab6a80e2f5981b46fe04950a96152e387f35c ...@@ -36,6 +36,11 @@ access_token = '6eb687358606347cef617237cddab6a80e2f5981b46fe04950a96152e387f35c
def get_cluster_stats(ip): def get_cluster_stats(ip):
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_url = "http://{ip}:9200/_cluster/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url) node_requests_res = requests.get(node_requests_url)
res_json = node_requests_res.json() res_json = node_requests_res.json()
...@@ -58,6 +63,11 @@ def get_index_stats(ip,index): ...@@ -58,6 +63,11 @@ def get_index_stats(ip,index):
def get_node_status(ip): def get_node_status(ip):
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_url = "http://{ip}:9200/_nodes/stats".format(ip=ip)
node_requests_res = requests.get(node_requests_url) node_requests_res = requests.get(node_requests_url)
res_json = node_requests_res.json() res_json = node_requests_res.json()
...@@ -149,5 +159,5 @@ def main_task(ip_list): ...@@ -149,5 +159,5 @@ def main_task(ip_list):
if __name__ == "__main__": if __name__ == "__main__":
# main_task('172.16.31.6') # 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) 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