Ver código fonte

添加每日数据监控

ck 4 anos atrás
pai
commit
95208d106f
2 arquivos alterados com 30 adições e 2 exclusões
  1. 26 0
      app/moniter/dd_daily.py
  2. 4 2
      model/DingTalkUtils.py

+ 26 - 0
app/moniter/dd_daily.py

@@ -0,0 +1,26 @@
+
+from model.DataBaseUtils import MysqlUtils
+from model.DateUtils import DateUtils
+from model.DingTalkUtils import DingTalkUtils
+
+db=MysqlUtils()
+dt=DateUtils()
+
+
+def run(dt):
+    sql="select count(1) from `order` where date=UNIX_TIMESTAMP('{}')".format(dt)
+    sql2="select count(1) from daily_qq where date='{} 00:00:00' ".format(dt)
+    sql3="select count(1) from daily_vx where date='{} 00:00:00' ".format(dt)
+
+
+    a = db.quchen_text.getOne(sql)
+    b = db.quchen_text.getOne(sql2)
+    c = db.quchen_text.getOne(sql3)
+    DingTalkUtils.send("[{}]\norder: {}\ndaily_qq: {}\ndaily_vx: {}".format(dt,a,b,c))
+
+
+if __name__ == '__main__':
+    run(dt.get_n_days(-1))
+
+
+

+ 4 - 2
model/DingTalkUtils.py

@@ -13,11 +13,13 @@ members = ["13726204048", "18860455786"]
 class DingTalkUtils:
     """
     @phone Str
+
+            不填:默认@所有人
             可多个,按英文逗号隔开
             可填 【ramdom】 随机发送
     """
     def send(msg, phone=""):
-        if phone == "all":
+        if phone == "":
             isAtall = True
             atMobiles = []
 
@@ -33,7 +35,7 @@ class DingTalkUtils:
         data = {'msgtype': 'text',
                     "at": {"isAtAll": isAtall,
                            "atMobiles": atMobiles},
-                    "text": {"content": msg+"[趣程]"}}
+                    "text": {"content": msg+"\n[趣程]"}}
 
         requests.post(url=url, headers=headers, json=data)