zooeytsai %!s(int64=2) %!d(string=hai) anos
pai
achega
b9ef1d9170
Modificáronse 1 ficheiros con 22 adicións e 7 borrados
  1. 22 7
      monitor/mon_chro.py

+ 22 - 7
monitor/mon_chro.py

@@ -5,16 +5,31 @@ import time
 import fire
 import dataset
 from datetime import datetime
-import pymysql
-pymysql.install_as_MySQLdb()
+# import pymysql
+# pymysql.install_as_MySQLdb()
 
+d = ['hhh.com.tw','innews.com.tw']
 db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
-cursor = db.query('select dt from seo.google_rank order by id  desc limit 1')
-for c in cursor:
+cursor_rank = db.query('select dt from seo.google_rank order by id desc limit 1')
+cursor_general = db.query('select domain from seo.general_log order by id desc limit 5')
+for c in cursor_rank:
     last_time = c['dt']
-    
 diff = datetime.now() - last_time
 if diff.seconds > 600:
-    print('異常,啟動reboot.py')
+    print('google_rank異常,啟動reboot.py')
     os.system('python3 reboot.py')
-print('正常')
+print('google_rank正常')
+
+lst = []
+for c in cursor_general:
+    if c['domain'] not in d:
+        lst.append(1)
+if len(lst) > 0:
+    print('general異常,啟動reboot.py')
+    os.system('python3 reboot.py')
+else:
+    print('general正常')
+
+
+
+