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

Changed partitions test to handle system with /var mount point | refs #32112

parent 1424ec35
No related branches found
No related tags found
No related merge requests found
......@@ -18,11 +18,27 @@ DEF = '\033[0m'
PATHS = [
{
'mount_point': '/',
'condition': '/var', # ignore this mount point check if /var is on the same device
'recommended_types': ('ext4', 'zfs', 'xfs'),
'min_size_gbytes': 6,
'reco_size_gbytes': 9,
'min_available_gbytes': 2,
},
{
'mount_point': '/',
'condition': '!/var', # ignore this mount point check if /var is not on the same device
'recommended_types': ('ext4', 'zfs', 'xfs'),
'min_size_gbytes': 9,
'reco_size_gbytes': 14,
'min_available_gbytes': 4,
},
{
'mount_point': '/var',
'recommended_types': ('ext4', 'zfs', 'xfs'),
'min_size_gbytes': 2,
'reco_size_gbytes': 4,
'min_available_gbytes': 0.5,
},
{
'mount_point': '/home/msuser/msinstance',
'recommended_types': ('ext4', 'zfs', 'nfs', 'nfs4', 'xfs'),
......@@ -64,7 +80,7 @@ def get_memory_gbytes():
return memory_gbytes
def get_path(path):
def get_path_fs(path):
# Filesystem Type 1B-blocks Used Available
# /dev/loop2 ext4 52710469632 38253940736 11755397120
status, output = subprocess.getstatusoutput('df --output="source,fstype,size,avail" -B 1 %s | tail -n 1' % path)
......@@ -107,40 +123,49 @@ def check_allocation(dev):
if __name__ == '__main__':
error = False
warning = False
for p in PATHS:
for part_info in PATHS:
psize = None
if p.get('mount_point'):
mount_point = p['mount_point']
if part_info.get('mount_point'):
mount_point = part_info['mount_point']
if os.path.exists(mount_point):
mount_point = os.path.realpath(mount_point)
name = 'Partition of %s' % mount_point
dev, fstype, psize, available = get_path(mount_point)
if fstype not in p.get('recommended_types'):
print('Warning: %s fs type not recommended %s(current: %s, recommended: %s)%s.' % (name, YELLOW, fstype, p['recommended_types'], DEF))
dev, fstype, psize, available = get_path_fs(mount_point)
condition = part_info.get('condition')
if condition:
subdev = get_path_fs(condition.strip('!'))[0]
if subdev == dev and not condition.startswith('!'):
print('Skipping check of %s with condition %s.' % (mount_point, condition))
continue
elif subdev != dev and condition.startswith('!'):
print('Skipping check of %s with condition %s.' % (mount_point, condition))
continue
if fstype not in part_info.get('recommended_types'):
print('Warning: %s fs type not recommended %s(current: %s, recommended: %s)%s.' % (name, YELLOW, fstype, part_info['recommended_types'], DEF))
warning = True
if 'nfs' not in fstype:
warning = not check_allocation(dev)
min_available_gbytes = p.get('min_available_gbytes')
min_available_gbytes = part_info.get('min_available_gbytes')
if min_available_gbytes and available < min_available_gbytes:
print('%s has less than %s GB available %s(%s GB available)%s.' % (name, min_available_gbytes, RED, available, DEF))
error = True
else:
print('%s has %s GB available.' % (name, available))
print('%s has more than %s GB available %s(%s GB available)%s.' % (name, min_available_gbytes, GREEN, available, DEF))
else:
print('%s not found, cannot check.' % mount_point)
elif p.get('type') == 'memory':
elif part_info.get('type') == 'memory':
name = 'Memory'
psize = get_memory_gbytes()
if psize:
if 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))
if psize < part_info['min_size_gbytes']:
print('%s is smaller than the minimum required size %s(%s GB < %s GB)%s.' % (name, RED, psize, part_info['min_size_gbytes'], DEF))
error = True
elif psize < p['reco_size_gbytes']:
print('%s is smaller than the recommended size %s(%s GB < %s GB)%s.' % (name, YELLOW, psize, p['reco_size_gbytes'], DEF))
elif psize < part_info['reco_size_gbytes']:
print('%s is smaller than the recommended size %s(%s GB < %s GB)%s.' % (name, YELLOW, psize, part_info['reco_size_gbytes'], DEF))
warning = True
else:
print('%s is bigger than recommended size %s(%s GB >= %s GB)%s.' % (name, GREEN, psize, p['reco_size_gbytes'], DEF))
print('%s is bigger than recommended size %s(%s GB >= %s GB)%s.' % (name, GREEN, psize, part_info['reco_size_gbytes'], DEF))
if error:
print('Errors found.')
......
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