[tor-commits] [gettor/master] Fix gettor check script

hiro at torproject.org hiro at torproject.org
Tue Oct 15 14:02:16 UTC 2019


commit 7b1dbc34f89f509906385168bf18113cfe4174a6
Author: hiro <hiro at torproject.org>
Date:   Mon Oct 14 17:28:20 2019 +0200

    Fix gettor check script
---
 scripts/check_service | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/check_service b/scripts/check_service
index b070a4b..e2f45fe 100644
--- a/scripts/check_service
+++ b/scripts/check_service
@@ -100,14 +100,18 @@ if __name__ == "__main__":
     else:
         password = "yourPassword"
 
-    status_file = open(STATUS_FILE,'w')
+    status_file = open(STATUS_FILE, 'r')
+    message = status_file.read()
+    status_file.close()
 
     try:
         status, message = send_email_from_gmail(password)
     except Exception as e:
         status = UNKNOWN
         message = repr(e)
-        status_file.write("UNKNOWN: %s" % message)
+        status_file = open(STATUS_FILE,'w')
+        status_file.write("UNKNOWN\n3: %s" % message)
+        status_file.close()
 
     time.sleep(600)
 
@@ -119,6 +123,7 @@ if __name__ == "__main__":
         status = CRITICAL
         message = repr(e)
     finally:
+        status_file = open(STATUS_FILE,'w')
         if status == OK:
             status_file.write("OK\n0: %s" % message)
         elif status == WARNING:
@@ -129,4 +134,6 @@ if __name__ == "__main__":
             status_file.write("UNKNOWN\n3: %s" % message)
             status = UNKNOWN
 
+        status_file.close()
+
         sys.exit(status)





More information about the tor-commits mailing list