Commit b5721674 authored by HERBERT Ryan's avatar HERBERT Ryan

disk space email

Added email notifications to admins when disk space passes below the
allowed threshhold
parent 865b6a75
...@@ -133,6 +133,9 @@ def run_request(): ...@@ -133,6 +133,9 @@ def run_request():
error = "" error = ""
enough_space = vidjil_utils.check_enough_space(defs.DIR_RESULTS) enough_space = vidjil_utils.check_enough_space(defs.DIR_RESULTS)
if not enough_space: 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.") return error_message("Runs are temporarily disabled. System admins have been made aware of the situation.")
##TODO check ##TODO check
......
...@@ -27,6 +27,9 @@ def add(): ...@@ -27,6 +27,9 @@ def add():
else: else:
enough_space = vidjil_utils.check_enough_space(defs.DIR_SEQUENCES) enough_space = vidjil_utils.check_enough_space(defs.DIR_SEQUENCES)
if not enough_space: 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.") return error_message("Uploads are temporarily disabled. System admins have been made aware of the situation.")
patient_id = None patient_id = None
......
...@@ -420,8 +420,4 @@ def check_enough_space(directory): ...@@ -420,8 +420,4 @@ def check_enough_space(directory):
available = int(available) available = int(available)
size = int(size) size = int(size)
result = available >= (size * (defs.FS_LOCK_THRESHHOLD/100)) 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 return result
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment