Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
common_scripy
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
吴升宇
common_scripy
Commits
b4deed76
Commit
b4deed76
authored
Feb 08, 2021
by
王瑞环
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mr/develop/add_adviser_es_monitor' into 'master'
update See merge request
!4
parents
2f2ab6a3
9ee3064c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
23 deletions
+29
-23
adveriser_es_monitor.py
scripies/adveriser_es_monitor.py
+29
-23
No files found.
scripies/adveriser_es_monitor.py
View file @
b4deed76
...
...
@@ -7,7 +7,7 @@ mysql 里面的数据和es里面的数据是否一致
import
pymysql
import
datetime
from
dingtalkchatbot.chatbot
import
DingtalkChatbot
import
settings_local
import
settings_local
from
elasticsearch
import
Elasticsearch
...
...
@@ -23,7 +23,7 @@ def main():
artemis_cursor
=
artemis_db
.
cursor
()
limit
=
100
account_sql
=
"select doctor_id, (rechange_amount+cashback_amount) as amount from account_account order by modify_time desc limit
%
s"
try
:
artemis_cursor
.
execute
(
account_sql
,
(
limit
))
accounts
=
artemis_cursor
.
fetchall
()
...
...
@@ -34,7 +34,7 @@ def main():
"query"
:
{
"bool"
:
{
"filter"
:
[
{
"terms"
:
{
"id"
:
doctor_ids
}}]}}}
es_result
=
es
.
search
(
query
)
es_result
=
es
.
search
(
query
,
settings_local
.
ES_INDEX
)
budgetSql
=
"""
select budget, is_open from bdtransfer_prioritybdtransfer
where merchant_id = {}
...
...
@@ -43,7 +43,7 @@ def main():
consumeSql
=
"""
select amount from bdtransfer_bdtransferconsume
where merchant_id = {}
and date =
{}
"""
and date =
'{}'
"""
today
=
str
(
datetime
.
date
.
today
())
num
=
0.0
...
...
@@ -65,31 +65,36 @@ def main():
budget_res
=
artemis_cursor
.
fetchone
()
artemis_cursor
.
execute
(
consume_sql
)
consume_res
=
artemis_cursor
.
fetchone
()
if
budget_res
:
budget
=
budget_res
[
0
]
mysql_is_merchant_priority_send_order
=
budget_res
[
1
]
if
consume_res
:
consume
=
consume_res
[
0
]
mysql_left_consume
=
consume
-
budget
print
(
"""
merchant_left_money: {}, mysql_merchant_left_money: {},
left_consume: {}, mysql_left_consume:{},
is_merchant_priority_send_order: {},
mysql_is_merchant_priority_send_order:{}"""
.
format
(
merchant_left_money
,
mysql_merchant_left_money
,
left_consume
,
mysql_left_consume
,
is_merchant_priority_send_order
,
mysql_is_merchant_priority_send_order
))
mysql_left_consume
=
budget
-
consume
if
(
merchant_left_money
==
mysql_merchant_left_money
and
left_consume
==
mysql_left_consume
and
i
s_merchant_priority_send_order
==
mysql_is_merchant_priority_send_order
):
int
(
merchant_left_money
)
==
int
(
mysql_merchant_left_money
)
and
int
(
left_consume
)
==
int
(
mysql_left_consume
)
and
i
nt
(
is_merchant_priority_send_order
)
==
int
(
mysql_is_merchant_priority_send_order
)
):
pass
else
:
num
=
num
+
1
error_doctors
.
append
(
doctor_id
)
if
(
is_merchant_priority_send_order
==
mysql_is_merchant_priority_send_order
and
is_merchant_priority_send_order
==
False
):
pass
else
:
print
(
"""
doctor_id: {},
merchant_left_money: {}, mysql_merchant_left_money: {},
left_consume: {}, mysql_left_consume:{},
is_merchant_priority_send_order: {},
mysql_is_merchant_priority_send_order:{}"""
.
format
(
doctor_id
,
merchant_left_money
,
mysql_merchant_left_money
,
left_consume
,
mysql_left_consume
,
is_merchant_priority_send_order
,
mysql_is_merchant_priority_send_order
))
num
=
num
+
1
error_doctors
.
append
(
doctor_id
)
print
(
num
)
if
num
/
limit
>
0.02
:
msg
=
"数据同步监控,总共{}个医生id,有{}个数据存在差异,具体医生id:{}"
.
format
(
limit
,
len
(
error_doctors
),
error_doctors
)
...
...
@@ -99,7 +104,7 @@ def main():
at_mobiles
=
[
"17794411132"
]
# at_mobiles = []
xiaoding
.
send_text
(
msg
=
msg
,
at_mobiles
=
at_mobiles
)
except
Exception
as
e
:
msg
=
"数据同步监控,数据diff出现问题"
webhook
=
'https://oapi.dingtalk.com/robot/send?access_token={}'
.
format
(
...
...
@@ -111,4 +116,4 @@ def main():
if
__name__
==
'__main__'
:
main
()
main
()
\ No newline at end of file
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