Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
balancer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
db0fd796
authored
Sep 29, 2023
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retry for get stats from dc
parent
7b6e956c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
balancer/stats.py
+13
-2
sredis/sredis.py
+1
-1
No files found.
balancer/stats.py
View file @
db0fd796
import
requests
import
json
import
logging
import
time
logger
=
logging
.
getLogger
(
__name__
)
PREFIX
=
"RBstat?"
MEM_ALLOCATED_TARGET
=
"target=circle.*.memory.allocated&format=json&time=-1min"
MEM_USAGE_TARGET
=
"circle.*.memory.usage&format=json&time=-1min"
MEM_USAGE_TARGET
=
"
target=
circle.*.memory.usage&format=json&time=-1min"
VMCOUNT_TARGET
=
"target=circle.*.vmcount&format=json&time=-1min"
CPU_PERCENT_TARGET
=
"target=circle.*.cpu.percent&format=json&time=-1min"
...
...
@@ -18,7 +19,7 @@ STAT_TARGETS = {
}
def
get_stat_from_dc
(
datacenter
):
def
get_stat_from_dc
(
datacenter
,
retry
=
False
):
stat
=
{}
for
key
,
target
in
STAT_TARGETS
.
items
():
url
:
str
=
f
"{datacenter}/{PREFIX}{target}"
...
...
@@ -35,4 +36,14 @@ def get_stat_from_dc(datacenter):
data
=
json
.
loads
(
req
.
content
)
stat
[
key
]
=
[
i
[
"datapoints"
][
0
][
0
]
for
i
in
data
]
if
retry
and
stat
[
key
][
0
]
is
None
:
time
.
sleep
(
1
)
req
=
requests
.
request
(
method
=
"GET"
,
url
=
url
,
verify
=
False
,
)
data
=
json
.
loads
(
req
.
content
)
stat
[
key
]
=
[
i
[
"datapoints"
][
0
][
0
]
for
i
in
data
]
return
stat
sredis/sredis.py
View file @
db0fd796
...
...
@@ -62,7 +62,7 @@ def update_datacenter_stats():
all_keys
=
r
.
hgetall
(
"datacenters_hash"
)
for
dc
in
all_keys
.
values
():
logger
.
info
(
f
"Get stats from {dc}"
)
get_stat_from_dc
(
dc
)
get_stat_from_dc
(
dc
,
retry
=
True
)
# update_stats(stats)
...
...
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