Skip to content

boinkor-net/zpool-exporter-textfile

Folders and files

NameName
Last commit message
Last commit date
Feb 12, 2021
Feb 13, 2025
Nov 5, 2023
Feb 4, 2025
Feb 12, 2021
Aug 27, 2023
Feb 12, 2021
Feb 12, 2021
Feb 18, 2025
Feb 18, 2025
Feb 12, 2021
Feb 12, 2021
Nov 5, 2023
Feb 12, 2021
Feb 16, 2025
Feb 4, 2025
Feb 12, 2021

Repository files navigation

Build Status Docs crates.io

zpool-exporter-textfile

This program can export metrics about the health of ZFS zpools into a text file that can be picked up by prometheus's node_collector via the textfile collector.

Usage

You'll want to regularly run this program. It automatically collects data about all active zpools.

$ zpool-exporter-textfile -o .../zpool_stats.txt

Installation

To build this, you need libzfs, as that's a compile time dependency. If you use nix, the included flake.nix will result in a binary that you can use.

Use in a flake

You can use this in a flake like so (I hope!):

{
  description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    zpool-exporter.url = "github:antifuchs/zpool-exporter-textfile";
  };

  outputs = { zpool-exporter, nixpkgs, ... }: {
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem rec {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix
          zpool-exporter.nixosModules.zpool-exporter-textfile
          {config, ...}: {
            zpool-exporter-textfile = {
              enable = true;
              textfileDir = "node_exporter_textfiles";
            };
            services.prometheus.exporters.node.extraFlags = [
              "--collector.textfile.directory=/etc/node_exporter_textfiles/"
            ];
          }
        ];
      };
    };
  };
}

Example metrics

# HELP zpool_health_level Overall health level of a pool. 0 if unhealthy, 1 if healthy.
# TYPE zpool_health_level gauge
zpool_health_level{pool="bpool"} 1
zpool_health_level{pool="data"} 1
zpool_health_level{pool="rpool"} 1
# HELP zpool_health_state Health status (1 if the <pool> is at health <state>)
# TYPE zpool_health_state gauge
zpool_health_state{pool="bpool",state="Available"} 0
zpool_health_state{pool="bpool",state="Degraded"} 0
zpool_health_state{pool="bpool",state="Faulted"} 0
zpool_health_state{pool="bpool",state="Offline"} 0
zpool_health_state{pool="bpool",state="Online"} 1
zpool_health_state{pool="bpool",state="Removed"} 0
zpool_health_state{pool="bpool",state="Unavailable"} 0
zpool_health_state{pool="data",state="Available"} 0
zpool_health_state{pool="data",state="Degraded"} 0
zpool_health_state{pool="data",state="Faulted"} 0
zpool_health_state{pool="data",state="Offline"} 0
zpool_health_state{pool="data",state="Online"} 1
zpool_health_state{pool="data",state="Removed"} 0
zpool_health_state{pool="data",state="Unavailable"} 0
zpool_health_state{pool="rpool",state="Available"} 0
zpool_health_state{pool="rpool",state="Degraded"} 0
zpool_health_state{pool="rpool",state="Faulted"} 0
zpool_health_state{pool="rpool",state="Offline"} 0
zpool_health_state{pool="rpool",state="Online"} 1
zpool_health_state{pool="rpool",state="Removed"} 0
zpool_health_state{pool="rpool",state="Unavailable"} 0