From 507d214e462779cc453e4f57e1a676c5fd8a23c4 Mon Sep 17 00:00:00 2001 From: Super User Date: Wed, 28 Feb 2024 15:27:16 +0300 Subject: [PATCH] Add pools ignore in exclude option --- README.md | 2 +- collector/zfs.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd9ca3e..cf0159a 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Flags: be set to a value shorter than your scrape timeout duration. The current collection run will continue and update the cache when complete (default: 8s) --pool=POOL ... Name of the pool(s) to collect, repeat for multiple pools (default: all pools). - --exclude=EXCLUDE ... Exclude datasets/snapshots/volumes that match the provided regex (e.g. + --exclude=EXCLUDE ... Exclude pools/datasets/snapshots/volumes that match the provided regex (e.g. '^rpool/docker/'), may be specified multiple times. --log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error] diff --git a/collector/zfs.go b/collector/zfs.go index c44524c..06c63f8 100644 --- a/collector/zfs.go +++ b/collector/zfs.go @@ -121,7 +121,17 @@ func (c *ZFS) Collect(ch chan<- prometheus.Metric) { c.ready <- struct{}{} }() - pools, poolErr := c.getPools(c.Pools) + pools0, poolErr := c.getPools(c.Pools) + + var pools []string + + for _, p := range pools0 { + if c.excludes.MatchString(p) { + continue + } + + pools = append(pools, p) + } for name, state := range c.Collectors { if !*state.Enabled {