Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黎涛
meta_base_code
Commits
ca8b6a2f
Commit
ca8b6a2f
authored
Dec 09, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
25d9442b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
es_status.py
celery_stats/es_status.py
+15
-5
No files found.
celery_stats/es_status.py
View file @
ca8b6a2f
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment