def _parse_mdstat(self):
        """
        Parse /proc/mdstat.

        File format:
        The first line is the "Personalities" line.
        It won't get parsed since it contains only string metrics.
        The second to second-last lines contain raid array information.
        The last line contains the unused devices.
        It won't get parsed since it contains only string metrics.

        :return: Parsed information
        :rtype: dict
        """

        arrays = {}
        mdstat_array_blocks = ''

        try:
            with open(self.MDSTAT_PATH, 'r') as f:
                lines = f.readlines()
        except IOError as err:
            self.log.exception(
                'Error opening {mdstat_path} for reading: {err}'.format(
                    mdstat_path=self.MDSTAT_PATH,
                    err=err
                )
            )
            return arrays

        # concatenate all lines except the first and last one
        for line in lines[1:-1]:
            mdstat_array_blocks += line

        if mdstat_array_blocks == '':
            # no md arrays found
            return arrays
        for block in mdstat_array_blocks.split('\n\n'):
            md_device_name = self._parse_device_name(block)
            if md_device_name:
                # this block begins with a md device name

                # 'member_count' and 'status' are mandatory keys
                arrays[md_device_name] = {
                    'member_count': self._parse_array_member_state(block),
                    'status': self._parse_array_status(block),
                }

                # 'bitmap' and 'recovery' are optional keys
                bitmap_status = self._parse_array_bitmap(block)
                recovery_status = self._parse_array_recovery(block)
                if bitmap_status:
                    arrays[md_device_name].update(
                        {'bitmap': bitmap_status}
                    )
                if recovery_status:
                    arrays[md_device_name].update(
                        {'recovery': recovery_status}
                    )

        return arrays

        Parse /proc/mdstat.

        File format:
        The first line is the "Personalities" line.
        It won't get parsed since it contains only string metrics.
        The second to second-last lines contain raid array information.
        The last line contains the unused devices.
        It won't get parsed since it contains only string metrics.

        :return: Parsed information
        :rtype: dict
        
src/collectors/mdstat/mdstat.py