diff --git a/jc/parsers/mount.py b/jc/parsers/mount.py index ef8a49dc..65cd5ebc 100644 --- a/jc/parsers/mount.py +++ b/jc/parsers/mount.py @@ -70,6 +70,8 @@ Example: ... ] """ +import re + import jc.utils @@ -133,15 +135,25 @@ def _linux_parse(data): for entry in data: output_line = {} - parsed_line = entry.split() - output_line['filesystem'] = parsed_line[0] - output_line['mount_point'] = parsed_line[2] - output_line['type'] = parsed_line[4] - output_line['options'] = parsed_line[5].lstrip('(').rstrip(')').split(',') + pattern = re.compile( + r''' + (?P\S+)\s+ + on\s+ + (?P.*?)\s+ + type\s+ + (?P\S+)\s+ + \((?P.*?)\)\s*''', + re.VERBOSE) + match = pattern.match(entry) + groups = match.groupdict() + + output_line['filesystem'] = groups["filesystem"] + output_line['mount_point'] = groups["mount_point"] + output_line['type'] = groups["type"] + output_line['options'] = groups["options"].split(',') output.append(output_line) - return output def _aix_parse(data):