diff options
Diffstat (limited to 'modules/packages.nix')
| -rw-r--r-- | modules/packages.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/packages.nix b/modules/packages.nix new file mode 100644 index 0000000..5e76f10 --- /dev/null +++ b/modules/packages.nix @@ -0,0 +1,45 @@ +# The two textfile collectors, as ordinary packages. +# +# They are wrappers rather than inline `writeShellApplication` bodies in the module so +# that the Python is runnable by hand -- `zfs-metrics --output /tmp/x.prom` behaves +# exactly as the timer does, which is how every one of these metrics was validated. +# Neither wrapper hardcodes an output path; the unit passes it. +{ lib, writeShellApplication, python3, smartmontools, zfs }: + +{ + # Pool capacity and health, vdev errors, scrub history, dataset properties and + # snapshot retention -- none of which node_exporter's built-in zfs collector reports, + # because it reads /proc/spl/kstat/zfs and that only carries ARC statistics and objset + # counters. OpenZFS 2.2+ also dropped the per-pool `io` kstat, so node_zfs_zpool_* is + # largely empty. This shells out to the zpool/zfs CLIs instead. + # + # runtimeInputs is the whole reason for the wrapper: the collector must run against + # the same zfs userland as the running kernel module. + zfs-metrics = writeShellApplication { + name = "zfs-metrics"; + runtimeInputs = [ zfs ]; + text = '' + exec ${python3.interpreter} ${../collectors/zfs-metrics.py} "$@" + ''; + meta = { + description = "Export ZFS pool, dataset and snapshot metrics in Prometheus format"; + mainProgram = "zfs-metrics"; + }; + }; + + # smartctl_exporter reads only the entry *count* out of each drive's self-test log and + # discards the log table, so it cannot say when a drive last ran a short or extended + # test or whether it passed. It also has no way to render a drive's identity as a + # display string, which the dashboards need for row titles. Both come from here. + smart-selftest = writeShellApplication { + name = "smart-selftest"; + runtimeInputs = [ smartmontools ]; + text = '' + exec ${python3.interpreter} ${../collectors/smart-selftest.py} "$@" + ''; + meta = { + description = "Export SMART self-test history and drive identity in Prometheus format"; + mainProgram = "smart-selftest"; + }; + }; +} |
