Browse Source

add server check

ming 3 years ago
parent
commit
8e39e6fcdc
1 changed files with 6 additions and 1 deletions
  1. 6 1
      etc/serverCheck.py

+ 6 - 1
etc/serverCheck.py

@@ -1,5 +1,6 @@
 import urllib.request
 import json
+import requests
 
 def notify_group(msg):
     #'WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD' is ChoozmoTeam
@@ -11,7 +12,11 @@ def notify_group(msg):
 try:
     contents = urllib.request.urlopen("https://www.choozmo.com:8887/checkStatus").read()
     status_dict = json.loads(contents.decode('utf-8'))
-
+    if len(status_dict['errors'])==0:
+        print('Everything works fine')
+    else:
+        for msg in status_dict['errors']:
+            notify_group('ERROR : '+msg+' down')
 except:
     err_msg = 'ERROR : 8887 status api down'
     print(err_msg)