Skip to content
Snippets Groups Projects
Commit 263ba714 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Follow links for msinstance dir (refs #22279).

parent 010a86c6
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,10 @@ import sys ...@@ -10,6 +10,10 @@ import sys
import os import os
BS = 512 BS = 512
YELLOW = '\033[93m'
GREEN = '\033[92m'
RED = '\033[91m'
DEF = '\033[0m'
def to_gbytes(size_bytes): def to_gbytes(size_bytes):
...@@ -31,7 +35,7 @@ paths = [ ...@@ -31,7 +35,7 @@ paths = [
'mount_point': '/home/msuser/msinstance', 'mount_point': '/home/msuser/msinstance',
'recommended_types': ('ext4', 'nfsv4'), 'recommended_types': ('ext4', 'nfsv4'),
'min_size_gbytes': 400, 'min_size_gbytes': 400,
'min_free_size_gbytes': 10, 'min_free_size_gbytes': 15,
}, },
{ {
'type': 'swap', 'type': 'swap',
...@@ -98,19 +102,22 @@ def check_path(p): ...@@ -98,19 +102,22 @@ def check_path(p):
psize = None psize = None
mount_point = p.get('mount_point') mount_point = p.get('mount_point')
if mount_point: if mount_point:
if os.path.isdir(mount_point): if os.path.exists(mount_point):
mount_point = os.path.realpath(mount_point)
name = mount_point name = mount_point
dev, fstype, psize, used = get_path(p['mount_point']) dev, fstype, psize, used = get_path(mount_point)
if fstype not in p.get('recommended_types'): if fstype not in p.get('recommended_types'):
print('Warning, fs type %s not recommended (recommended: %s)' % (fstype, p['recommended_types'])) print('Warning, partition of %s fs type not recommended %s(current: %s, recommended: %s)%s' % (name, YELLOW, fstype, p['recommended_types'], DEF))
warning = True warning = True
if 'nfs' not in dev: if 'nfs' not in dev:
warning = not check_allocation(dev) warning = not check_allocation(dev)
free_gb = psize - used free_gb = psize - used
min_free_size_gbytes = p.get('min_free_size_gbytes') min_free_size_gbytes = p.get('min_free_size_gbytes')
if min_free_size_gbytes and free_gb < min_free_size_gbytes: if min_free_size_gbytes and free_gb < min_free_size_gbytes:
print('%s has less than %s GB free (%s GB free)' % (mount_point, min_free_size_gbytes, free_gb)) print('Partition of %s has less than %s GB free (%s GB free)' % (mount_point, min_free_size_gbytes, free_gb))
error = True error = True
else:
print('Partition of %s is OK' % name)
else: else:
print('%s not found, cannot check' % mount_point) print('%s not found, cannot check' % mount_point)
elif p.get('type') == 'swap': elif p.get('type') == 'swap':
...@@ -118,25 +125,20 @@ def check_path(p): ...@@ -118,25 +125,20 @@ def check_path(p):
psize = get_swap_gbytes() psize = get_swap_gbytes()
if psize and psize < p['min_size_gbytes']: if psize and psize < p['min_size_gbytes']:
print('%s is smaller than the minimum required size (%s GB < %s GB)' % (name, psize, p['min_size_gbytes'])) print('%s is smaller than the minimum required size %s(%s GB < %s GB)%s' % (name, RED, psize, p['min_size_gbytes'], DEF))
error = True error = True
for p in paths: for p in paths:
check_path(p) check_path(p)
OK = 0
ERROR = 1
WARNING = 3
UNTESTABLE = 2
if error: if error:
print('Errors found') print('Errors found')
code = ERROR code = 1
elif warning: elif warning:
print('Some warnings were found') print('Some warnings were found')
code = WARNING code = 2
else: else:
print('All ok') print(GREEN + 'All ok' + DEF)
code = OK code = 0
sys.exit(code) sys.exit(code)
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