Skip to main content

Parse output from zpool status

Project description

zpool_status.py

Parse output from zpool-status(1).

About

The zpool_status.py Python module calls the zpool status command, parses its output and returns the information as a dictionary.

Install

Install zpool_status.py using pip:

$ pip install zpool-status

Command-line interface

zpool_status.py provides a limited command-line interface. For each pool name argument it prints the pool information as a json object. When called with no arguments, it prints pool information for all imported pools.

$ python -m zpool_status tank

Example

$ 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
import zpool_status

zpool = ZPool("tank")
status = zpool.get_status()

print(json.dumps(status, indent=2))
{
  "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.1.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file zpool-status-0.1.tar.gz.

File metadata

  • Download URL: zpool-status-0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for zpool-status-0.1.tar.gz
Algorithm Hash digest
SHA256 c7c8926a07d93919b120507b7df4ce0fec5955999ae39967130e8300435584a0
MD5 a40d639284f29a2d9d04713b019e3892
BLAKE2b-256 1f4cfd0419538ef6117487314d8b7ffb6901ca01eb41d6e3ceb59a24eff1c625

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