|
@@ -0,0 +1,35 @@
|
|
|
+import sys
|
|
|
+import random
|
|
|
+import os
|
|
|
+import time
|
|
|
+import fire
|
|
|
+import dataset
|
|
|
+from datetime import datetime
|
|
|
+# 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_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 10')
|
|
|
+for c in cursor_rank:
|
|
|
+ last_time = c['dt']
|
|
|
+diff = datetime.now() - last_time
|
|
|
+lst = []
|
|
|
+for c in cursor_general:
|
|
|
+ if c['domain'] not in d:
|
|
|
+ lst.append(1)
|
|
|
+if diff.seconds > 600:
|
|
|
+ print('google_rank異常,啟動reboot.py')
|
|
|
+ os.system('python3 reboot.py')
|
|
|
+else:
|
|
|
+ print('google_rank正常')
|
|
|
+ if len(lst) > 0:
|
|
|
+ print('general正常')
|
|
|
+ else:
|
|
|
+ print('general異常,啟動reboot.py')
|
|
|
+ os.system('python3 reboot.py')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|