Skip to main content

Parse output from zpool status

Project description

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:

$ 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:

$ zpool-status -v tank

is identical to the this Python code:

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:

{
  "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"
  ]
}

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

zpool_status-0.2.3.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file zpool_status-0.2.3.tar.gz.

File metadata

  • Download URL: zpool_status-0.2.3.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for zpool_status-0.2.3.tar.gz
Algorithm Hash digest
SHA256 a7d5617a01f9f71819f314789aa33f3f5206a2ba3681f1f7dc5894b7ed45ba9a
MD5 c049ee9a6414959df0032791542a3abf
BLAKE2b-256 53d812051c602c12501004ae850ec8f18a493f3f540b56e4157dcf89e8a714dc

See more details on using hashes here.

Supported by

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