From b5721674371aa593b88a58a7dd92bc0dce5eca3f Mon Sep 17 00:00:00 2001 From: Ryan Herbert Date: Fri, 21 Oct 2016 16:11:52 +0200 Subject: [PATCH] disk space email Added email notifications to admins when disk space passes below the allowed threshhold --- server/web2py/applications/vidjil/controllers/default.py | 3 +++ server/web2py/applications/vidjil/controllers/file.py | 3 +++ server/web2py/applications/vidjil/modules/vidjil_utils.py | 4 ---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/web2py/applications/vidjil/controllers/default.py b/server/web2py/applications/vidjil/controllers/default.py index 6bb23f36a..01c662e73 100644 --- a/server/web2py/applications/vidjil/controllers/default.py +++ b/server/web2py/applications/vidjil/controllers/default.py @@ -133,6 +133,9 @@ def run_request(): error = "" enough_space = vidjil_utils.check_enough_space(defs.DIR_RESULTS) if not enough_space: + mail.send(to=defs.ADMIN_EMAILS, + subject="[Vidjil] Server space", + message="The space in directory %s has passed below %d\%." % (defs.DIR_RESULTS, defs.FS_LOCK_THRESHHOLD)) return error_message("Runs are temporarily disabled. System admins have been made aware of the situation.") ##TODO check diff --git a/server/web2py/applications/vidjil/controllers/file.py b/server/web2py/applications/vidjil/controllers/file.py index 772798652..0e0451853 100644 --- a/server/web2py/applications/vidjil/controllers/file.py +++ b/server/web2py/applications/vidjil/controllers/file.py @@ -27,6 +27,9 @@ def add(): else: enough_space = vidjil_utils.check_enough_space(defs.DIR_SEQUENCES) if not enough_space: + mail.send(to=defs.ADMIN_EMAILS, + subject="[Vidjil] Server space", + message="The space in directory %s has passed below %d\%." % (defs.DIR_SEQUENCES, defs.FS_LOCK_THRESHHOLD)) return error_message("Uploads are temporarily disabled. System admins have been made aware of the situation.") patient_id = None diff --git a/server/web2py/applications/vidjil/modules/vidjil_utils.py b/server/web2py/applications/vidjil/modules/vidjil_utils.py index 80a5dc460..dd7e95ad0 100644 --- a/server/web2py/applications/vidjil/modules/vidjil_utils.py +++ b/server/web2py/applications/vidjil/modules/vidjil_utils.py @@ -420,8 +420,4 @@ def check_enough_space(directory): available = int(available) size = int(size) result = available >= (size * (defs.FS_LOCK_THRESHHOLD/100)) - #if not result: - # mail.send(to=defs.ADMIN_EMAILS, - # subject="[Vidjil] Server space", - # message="The space in directory %s has passed below %d\%." % (directory, defs.FS_LOCK_THRESHHOLD)) return result -- GitLab