Skip to main content

mdstat parser

Project description

This short library is used to convert your /proc/mdstat file into an object usable in Python. It comes with a short mdjson script that dumps your file in a JSON format.

Requirements

  • Linux (or at least get mdstat files from a Linux machine)

  • Python 2.6+ (or 3.2+)

Example usage

For most use cases, you can simple run mdstat.parse() to get nested dictionaries repesenting your local /proc/mdstat file. If you fetch the file remotely or need to run the parser on a stream, use parse_stream.

$ mdjson
{
    "personalities": [
        "raid10"
    ],
    "unused_devices": [],
    "devices": {
        "md127": {
            "read_only": true,
            "status": {
                "near_copies": 2,
                "blocks": 34359475200,
                "raid_disks": 4,
                "offset_copies": 0,
                "far_copies": 1,
                "synced": [
                    true,
                    true,
                    true,
                    true
                ],
                "chunks": "512K",
                "super": "1.2",
                "non_degraded_disks": 4
            },
            "bitmap": null,
            "resync": null,
            "active": true,
            "disks": {
                "xvdf": {
                    "spare": true,
                    "faulty": false,
                    "write_mostly": false,
                    "number": 4,
                    "replacement": false
                },
                "xvdd": {
                    "spare": false,
                    "faulty": false,
                    "write_mostly": false,
                    "number": 2,
                    "replacement": false
                },
                "xvde": {
                    "spare": false,
                    "faulty": false,
                    "write_mostly": false,
                    "number": 3,
                    "replacement": false
                },
                "xvdb": {
                    "spare": false,
                    "faulty": false,
                    "write_mostly": false,
                    "number": 0,
                    "replacement": false
                },
                "xvdc": {
                    "spare": false,
                    "faulty": false,
                    "write_mostly": false,
                    "number": 1,
                    "replacement": false
                }
            },
            "personality": "raid10"
        }
    }
}

You can also use the python interface to generate a nested dictionary:

>>> import mdstat
>>> mdstat.parse()
{
    "personalities": [
        "raid1",
        "raid5",
        "raid10",
    ],
    "devices": {
        "md0": {
            "active": True,
            [... snip ...]
        }
    }
    "unused_devices": []
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdstat-1.0.4.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file mdstat-1.0.4.tar.gz.

File metadata

  • Download URL: mdstat-1.0.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mdstat-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f5587357f65f5f5ca016b125914bbdcb5ff23ed1f2649f47ee4736e5eaa7a2a9
MD5 653aa6b1bdf1ea56d427c2bf6331bc10
BLAKE2b-256 6157879865d489c7f56d1b1687866f4e9eaecbc7dce7072bcf5bb4877c66c492

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page