MDAdm parsers
Classes to parse mdadm
commands information.
Parsers provided by this module include:
MDAdm - command /usr/sbin/mdadm -E {device}
MDAdmDetail - command /usr/sbin/mdadm -D /dev/md*
- class insights.parsers.mdadm.MDAdmDetail(context, extra_bad_lines=None)[source]
Bases:
CommandParser
,list
Parser for output of command
mdadm -D /dev/md*
.Each MD arrry device will be wrapped in :class:
MDAdmDetailDevice
.The md device’s properties in <property name> : <property value> format will be stored seprately, and are accessable via <property name>.
- unparsable_device_list
the name of unparsable devices
- Type:
list
Sample output:
/dev/md2: Version : 1.2 Creation Time : Sun Sep 5 23:19:18 2021 Raid Level : raid1 Array Size : 7501333824 (7153.83 GiB 7681.37 GB) Used Dev Size : 7501333824 (7153.83 GiB 7681.37 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Intent Bitmap : Internal Update Time : Sun Sep 26 22:18:13 2021 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Consistency Policy : bitmap Name : hostname:2 (local to host hostname) UUID : 245e1231:245e1231:245e1231:245e1231 Events : 1821 Number Major Minor RaidDevice State 0 259 1 0 active sync /dev/nvme2n1 1 259 0 1 active sync /dev/nvme3n1 /dev/md3: Version : 1.2 Creation Time : Sun Sep 5 23:19:18 2021 ...
Examples
>>> len(mdadm_d) 2 >>> mdadm_d[0].device_name '/dev/md2' >>> mdadm_d[0]["UUID"] '245e1231:245e1231:245e1231:245e1231' >>> mdadm_d[0].is_internal_bitmap True >>> len(mdadm_d[0].device_table) 2 >>> mdadm_d[1].get("Version") '1.2'
- class insights.parsers.mdadm.MDAdmDetailDevice[source]
Bases:
dict
Parser for single MD device data from
mdadm -D /dev/md*
output.MD arrry device’s full path name will be reside in /dev/ and start with “md”, or reside in /dev/md/. For examples: /dev/md0, /dev/md/home .
The md device’s properties in <property name> : <property value> format will be stored seprately, and are accessable via <property name>.
- property device_name
the name of the device, e.g. /dev/md0
- Type:
str
- property device_table
the devices info table
- Type:
list
- property is_internal_bitmap
True if using “Internal” for Intent Bitmap
- Type:
bool
- class insights.parsers.mdadm.MDAdmMetadata(context, extra_bad_lines=None)[source]
Bases:
CommandParser
,dict
Parser for output of
mdadm -E
for each MD device in system.This stores the information from the output in the following properties: *
device
- the name of the device after /dev/ - e.g. loop0Sample output:
/dev/loop0: Magic : a92b4efc Version : 1.0 Feature Map : 0x0 Array UUID : 98e098ef:c8662ce2:2ed2aa5f:7f0416a9 Name : 0 Creation Time : Mon Jun 29 02:16:52 2020 Raid Level : raid1 Raid Devices : 2 Avail Dev Size : 16383968 sectors (7.81 GiB 8.39 GB) Array Size : 1048576 KiB (1024.00 MiB 1073.74 MB) Used Dev Size : 2097152 sectors (1024.00 MiB 1073.74 MB) Super Offset : 16383984 sectors Unused Space : before=0 sectors, after=14286824 sectors State : clean Device UUID : 5e249ed9:a9ee800a:c09c963f:363a18d2 Update Time : Mon Jun 29 02:19:56 2020 Bad Block Log : 512 entries available at offset -8 sectors Checksum : 395066e8 - correct Events : 60 Device Role : Active device 0 Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
Examples
>>> mdadm.device '/dev/loop0' >>> mdadm["Device UUID"] '5e249ed9:a9ee800a:c09c963f:363a18d2' >>> mdadm["Events"] 60