1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-12-22 07:17:05 +00:00

report free disk space in the admin

This commit is contained in:
Joshua Tauberer 2014-10-12 21:31:58 +00:00
parent 048e35a80f
commit b5b3fca137

View File

@ -52,6 +52,19 @@ def run_system_checks(env):
# admin email is automatically directed.
check_alias_exists("administrator@" + env['PRIMARY_HOSTNAME'], env)
# Check free disk space.
st = os.statvfs(env['STORAGE_ROOT'])
bytes_total = st.f_blocks * st.f_frsize
bytes_free = st.f_bavail * st.f_frsize
disk_msg = "The disk has %s GB space remaining." % str(round(bytes_free/1024.0/1024.0/1024.0*10.0)/10.0)
if bytes_free > .3 * bytes_total:
env['out'].print_ok(disk_msg)
elif bytes_free > .15 * bytes_total:
env['out'].print_warning(disk_msg)
else:
env['out'].print_error(disk_msg)
def run_network_checks(env):
# Also see setup/network-checks.sh.