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
6708a61f
Commit
6708a61f
authored
Dec 16, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e59d4b25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
17 deletions
+33
-17
celery_stats_monitor.py
celery_stats/celery_stats_monitor.py
+33
-17
No files found.
celery_stats/celery_stats_monitor.py
View file @
6708a61f
...
...
@@ -7,27 +7,40 @@
import
redis
from
send_msg_to_dingding.send_msg
import
send_msg_to_dingtalk
import
datetime
,
time
token_dict
=
{
'gaia-dbmw'
:{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
'tapir-gaia-service'
:{
'secret'
:
"SEC65d8ac5f9c92677cf0c98624810abc407cf433fd4f2713649dc41310b4658fb5"
,
'access_token'
:
"ca4ca402653c7fe6011c18ff5ac385b2b0f4ab6cab61c545f09f4d8830db6870"
},
'mimas-dbmw'
:{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
'gaia-dbmw'
:
{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
'tapir-gaia-service'
:
{
'secret'
:
"SEC65d8ac5f9c92677cf0c98624810abc407cf433fd4f2713649dc41310b4658fb5"
,
'access_token'
:
"ca4ca402653c7fe6011c18ff5ac385b2b0f4ab6cab61c545f09f4d8830db6870"
},
'mimas-dbmw'
:
{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
"graces-es6-tapir-diary"
:
{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
"graces-es6-tapir-service"
:
{
'secret'
:
"SEC65d8ac5f9c92677cf0c98624810abc407cf433fd4f2713649dc41310b4658fb5"
,
'access_token'
:
"ca4ca402653c7fe6011c18ff5ac385b2b0f4ab6cab61c545f09f4d8830db6870"
},
"mentha-tapir-answer"
:
{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
"mentha-tapir-tractate"
:
{
'secret'
:
"SECba5212dadad3794b3da51c903c828f60ab8342897af2675f1f48fceb8858eb5c"
,
'access_token'
:
"df546521ce46bfb35025ca266efc2d7e8d708d1c8ada9b15ae487786ad06ad12"
},
}
# send_msg_to_dingtalk("123",secret=secret,access_token=access_token)
redis_old_gaia
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN11@172.16.40.166:6379/9"
,
decode_responses
=
True
)
redis_old_mimas
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN3@172.16.40.145:6379/5"
,
decode_responses
=
True
)
redis_new_gaia
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN19@172.16.50.166:6379"
,
decode_responses
=
True
)
redis_new_mimas
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN19@172.16.50.166:6379/1"
,
decode_responses
=
True
)
class
Parse_data
:
def
__init__
(
self
,
top
=
200
,
consume
=
500
):
def
__init__
(
self
,
top
=
200
,
consume
=
500
):
self
.
top
=
top
self
.
consume
=
consume
self
.
offset_dict
=
{}
def
parse
(
self
,
key_name
,
len_data
,
per_sec
=
10
):
def
parse
(
self
,
key_name
,
len_data
,
per_sec
=
10
):
now
=
datetime
.
datetime
.
now
()
time_ts
=
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
len_data
<=
self
.
top
:
...
...
@@ -39,24 +52,24 @@ class Parse_data:
rate
=
len_data_diff
/
per_sec
self
.
offset_dict
[
key_name
]
=
len_data
if
len_data_diff
>
0
:
use_time
=
round
(
len_data
/
rate
/
(
60
/
per_sec
)
/
60
,
1
)
return
"{} 目前{}队列中有{}条数据,预计{}小时后处理完成"
.
format
(
time_ts
,
key_name
,
str
(
len_data
),
str
(
use_time
))
use_time
=
round
(
len_data
/
rate
/
(
60
/
per_sec
)
/
60
,
1
)
return
"{} 目前{}队列中有{}条数据,预计{}小时后处理完成"
.
format
(
time_ts
,
key_name
,
str
(
len_data
),
str
(
use_time
))
else
:
if
abs
(
rate
)
>
0
:
return
"{} {}队列增长中,目前有{}条数据"
.
format
(
time_ts
,
key_name
,
str
(
len_data
))
return
"{} {}队列增长中,目前有{}条数据"
.
format
(
time_ts
,
key_name
,
str
(
len_data
))
self
.
offset_dict
[
key_name
]
=
len_data
return
None
def
len_list_and_send_msg
(
redis_clint
,
key_name
,
rules
,
per_sec
=
10
):
def
len_list_and_send_msg
(
redis_clint
,
key_name
,
rules
,
per_sec
=
10
):
# redis_clint = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN3@172.16.40.145:6379/5", decode_responses=True)
res
=
redis_clint
.
llen
(
key_name
)
# print(key_name,res)
str_res
=
rules
.
parse
(
key_name
,
res
,
per_sec
=
per_sec
)
str_res
=
rules
.
parse
(
key_name
,
res
,
per_sec
=
per_sec
)
if
str_res
:
send_msg_to_dingtalk
(
str_res
,
secret
=
token_dict
[
key_name
][
'secret'
],
access_token
=
token_dict
[
key_name
][
'access_token'
])
send_msg_to_dingtalk
(
str_res
,
secret
=
token_dict
[
key_name
][
'secret'
],
access_token
=
token_dict
[
key_name
][
'access_token'
])
if
__name__
==
"__main__"
:
...
...
@@ -64,12 +77,16 @@ if __name__ == "__main__":
redis_clicnt_dct
=
{
"gaia-dbmw"
:
redis_old_gaia
,
"tapir-gaia-service"
:
redis_old_gaia
,
"mimas-dbmw"
:
redis_old_mimas
"mimas-dbmw"
:
redis_old_mimas
,
"graces-es6-tapir-diary"
:
redis_new_gaia
,
"graces-es6-tapir-service"
:
redis_new_gaia
,
"mentha-tapir-answer"
:
redis_new_mimas
,
"mentha-tapir-tractate"
:
redis_new_mimas
,
}
per_sec
=
10
while
True
:
now
=
datetime
.
datetime
.
now
()
if
now
.
second
%
per_sec
==
0
:
for
redis_clint_key
in
redis_clicnt_dct
:
len_list_and_send_msg
(
redis_clicnt_dct
[
redis_clint_key
],
redis_clint_key
,
rules
,
per_sec
)
time
.
sleep
(
1
)
\ No newline at end of file
len_list_and_send_msg
(
redis_clicnt_dct
[
redis_clint_key
],
redis_clint_key
,
rules
,
per_sec
)
time
.
sleep
(
1
)
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