zpool-status


Namezpool-status JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/gustaebel/zpool-status/
SummaryParse output from zpool status
upload_time2024-11-04 18:57:33
maintainerNone
docs_urlNone
authorLars Gustäbel
requires_python>=3.7
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # zpool-status

Parse output from the `zpool status` ZFS command in Python.

## About

This project contains:

1. A Python module `zpool_status.py` that converts `zpool status` output into a
   Python datastructure.
2. A Python script `zpool-status` that serves as a drop-in replacement
   for the `zpool status` command that produces JSON output.

## Install

Install `zpool-status` using pip:

```sh
$ pip install zpool-status
```

## Command-line interface

The `zpool-status` script provides a command-line interface that is identical
to the one of `zpool-status(1)`. The only difference is that `zpool-status`
produces JSON output.

```
zpool-status [-c [script1[,script2]...]] [-igLpPstv] [-T d|u] [pool] ... [interval [count]]
```

> [!NOTE]
> The `-D` and `-x` options are not supported.

## Example

Suppose we get the following output from `zpool status`:

```
$ zpool status -v tank
  pool: tank
 state: UNAVAIL
status: One or more devices are faulted in response to IO failures.
action: Make sure the affected devices are connected, then run 'zpool clear'.
   see: http://www.sun.com/msg/ZFS-8000-HC
 scrub: scrub completed after 0h0m with 0 errors on Tue Feb  2 13:08:42 2010
config:

        NAME        STATE     READ WRITE CKSUM
        tank        UNAVAIL      0     0     0  insufficient replicas
          c1t0d0    ONLINE       0     0     0
          c1t1d0    UNAVAIL      4     1     0  cannot open

errors: Permanent errors have been detected in the following files: 

/tank/data/aaa
/tank/data/bbb
/tank/data/ccc
```

The following shell command line:

```sh
$ zpool-status -v tank
```

is identical to the this Python code:

```python
import json
from zpool_status import ZPool

zpool = ZPool("tank", options=["-v"])
status = zpool.get_status()

print(json.dumps(status, indent=2))
```

Both produce this output:

```json
{
  "pool": "tank",
  "state": "UNAVAIL",
  "status": "One or more devices are faulted in response to IO failures.",
  "action": "Make sure the affected devices are connected, then run 'zpool clear'.",
  "see": "http://www.sun.com/msg/ZFS-8000-HC",
  "scrub": "scrub completed after 0h0m with 0 errors on Tue Feb 2 13:08:42 2010",
  "config": [
    {
      "name": "tank",
      "state": "UNAVAIL",
      "read": 0,
      "write": 0,
      "cksum": 0,
      "message": "insufficient replicas",
      "type": "pool",
      "devices": [
        {
          "name": "c1t0d0",
          "state": "ONLINE",
          "read": 0,
          "write": 0,
          "cksum": 0,
          "type": "device"
        },
        {
          "name": "c1t1d0",
          "state": "UNAVAIL",
          "read": 4,
          "write": 1,
          "cksum": 0,
          "message": "cannot open",
          "type": "device"
        }
      ]
    }
  ],
  "errors": [
    "Permanent errors have been detected in the following files:",
    "",
    "/tank/data/aaa",
    "/tank/data/bbb",
    "/tank/data/ccc"
  ]
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gustaebel/zpool-status/",
    "name": "zpool-status",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Lars Gust\u00e4bel",
    "author_email": "lars@gustaebel.de",
    "download_url": "https://files.pythonhosted.org/packages/53/d8/12051c602c12501004ae850ec8f18a493f3f540b56e4157dcf89e8a714dc/zpool_status-0.2.3.tar.gz",
    "platform": null,
    "description": "# zpool-status\n\nParse output from the `zpool status` ZFS command in Python.\n\n## About\n\nThis project contains:\n\n1. A Python module `zpool_status.py` that converts `zpool status` output into a\n   Python datastructure.\n2. A Python script `zpool-status` that serves as a drop-in replacement\n   for the `zpool status` command that produces JSON output.\n\n## Install\n\nInstall `zpool-status` using pip:\n\n```sh\n$ pip install zpool-status\n```\n\n## Command-line interface\n\nThe `zpool-status` script provides a command-line interface that is identical\nto the one of `zpool-status(1)`. The only difference is that `zpool-status`\nproduces JSON output.\n\n```\nzpool-status [-c [script1[,script2]...]] [-igLpPstv] [-T d|u] [pool] ... [interval [count]]\n```\n\n> [!NOTE]\n> The `-D` and `-x` options are not supported.\n\n## Example\n\nSuppose we get the following output from `zpool status`:\n\n```\n$ zpool status -v tank\n  pool: tank\n state: UNAVAIL\nstatus: One or more devices are faulted in response to IO failures.\naction: Make sure the affected devices are connected, then run 'zpool clear'.\n   see: http://www.sun.com/msg/ZFS-8000-HC\n scrub: scrub completed after 0h0m with 0 errors on Tue Feb  2 13:08:42 2010\nconfig:\n\n        NAME        STATE     READ WRITE CKSUM\n        tank        UNAVAIL      0     0     0  insufficient replicas\n          c1t0d0    ONLINE       0     0     0\n          c1t1d0    UNAVAIL      4     1     0  cannot open\n\nerrors: Permanent errors have been detected in the following files: \n\n/tank/data/aaa\n/tank/data/bbb\n/tank/data/ccc\n```\n\nThe following shell command line:\n\n```sh\n$ zpool-status -v tank\n```\n\nis identical to the this Python code:\n\n```python\nimport json\nfrom zpool_status import ZPool\n\nzpool = ZPool(\"tank\", options=[\"-v\"])\nstatus = zpool.get_status()\n\nprint(json.dumps(status, indent=2))\n```\n\nBoth produce this output:\n\n```json\n{\n  \"pool\": \"tank\",\n  \"state\": \"UNAVAIL\",\n  \"status\": \"One or more devices are faulted in response to IO failures.\",\n  \"action\": \"Make sure the affected devices are connected, then run 'zpool clear'.\",\n  \"see\": \"http://www.sun.com/msg/ZFS-8000-HC\",\n  \"scrub\": \"scrub completed after 0h0m with 0 errors on Tue Feb 2 13:08:42 2010\",\n  \"config\": [\n    {\n      \"name\": \"tank\",\n      \"state\": \"UNAVAIL\",\n      \"read\": 0,\n      \"write\": 0,\n      \"cksum\": 0,\n      \"message\": \"insufficient replicas\",\n      \"type\": \"pool\",\n      \"devices\": [\n        {\n          \"name\": \"c1t0d0\",\n          \"state\": \"ONLINE\",\n          \"read\": 0,\n          \"write\": 0,\n          \"cksum\": 0,\n          \"type\": \"device\"\n        },\n        {\n          \"name\": \"c1t1d0\",\n          \"state\": \"UNAVAIL\",\n          \"read\": 4,\n          \"write\": 1,\n          \"cksum\": 0,\n          \"message\": \"cannot open\",\n          \"type\": \"device\"\n        }\n      ]\n    }\n  ],\n  \"errors\": [\n    \"Permanent errors have been detected in the following files:\",\n    \"\",\n    \"/tank/data/aaa\",\n    \"/tank/data/bbb\",\n    \"/tank/data/ccc\"\n  ]\n}\n```\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Parse output from zpool status",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/gustaebel/zpool-status/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53d812051c602c12501004ae850ec8f18a493f3f540b56e4157dcf89e8a714dc",
                "md5": "c049ee9a6414959df0032791542a3abf",
                "sha256": "a7d5617a01f9f71819f314789aa33f3f5206a2ba3681f1f7dc5894b7ed45ba9a"
            },
            "downloads": -1,
            "filename": "zpool_status-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c049ee9a6414959df0032791542a3abf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7809,
            "upload_time": "2024-11-04T18:57:33",
            "upload_time_iso_8601": "2024-11-04T18:57:33.045203Z",
            "url": "https://files.pythonhosted.org/packages/53/d8/12051c602c12501004ae850ec8f18a493f3f540b56e4157dcf89e8a714dc/zpool_status-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 18:57:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gustaebel",
    "github_project": "zpool-status",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "zpool-status"
}
        
Elapsed time: 0.38538s