Skip to content
Snippets Groups Projects
Commit c4083991 authored by Florent Thiery's avatar Florent Thiery
Browse files

test if sufficient space is available on the backup server, refs #20957

parent 13bf0fa1
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,22 @@ def test_last_backup_is_recent(server): ...@@ -50,6 +50,22 @@ def test_last_backup_is_recent(server):
return False return False
def test_backup_space(server):
cmd = 'ssh -o StrictHostKeyChecking=no %s df -h /backup | tail -n 1' % (server)
status, out = subprocess.getstatusoutput(cmd)
if status == 0:
dev, total, used, free, used_perc, mount = out.strip().split()
used_perc = int(used_perc.replace('%',''))
if used_perc > 80:
print('There is less than 20% of available space for backups')
return False
else:
return True
else:
print('Failed to check backup space')
return False
os.chdir(os.path.dirname(__file__)) os.chdir(os.path.dirname(__file__))
if os.path.isfile('../utils.py'): if os.path.isfile('../utils.py'):
es_utils = imp.load_source('es_utils', '../utils.py') es_utils = imp.load_source('es_utils', '../utils.py')
...@@ -63,7 +79,10 @@ if os.path.isfile('../utils.py'): ...@@ -63,7 +79,10 @@ if os.path.isfile('../utils.py'):
if not test_last_backup_is_recent(BURP_SERVER): if not test_last_backup_is_recent(BURP_SERVER):
sys.exit(1) sys.exit(1)
else: else:
sys.exit(0) if not test_backup_space(BURP_SERVER):
sys.exit(1)
else:
sys.exit(0)
else: else:
print('No BURP_SERVER defined in config, untestable') print('No BURP_SERVER defined in config, untestable')
sys.exit(2) sys.exit(2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment