From e8c5110ada6152ec0efb8b2dc8be7e493624d232 Mon Sep 17 00:00:00 2001 From: dongjiang Date: Wed, 20 Sep 2023 17:49:56 +0800 Subject: [PATCH] fix(zfs) zfs `arcstats.p` on FreeBSD 14.0+ (#2754) * dongjiang, fix zfs arcstats.p Signed-off-by: dongjiang1989 * dongjiang, fix gofmt -s Signed-off-by: dongjiang1989 * change warn log to debug log by code review Signed-off-by: dongjiang1989 --------- Signed-off-by: dongjiang1989 --- collector/zfs_freebsd.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 2b3948a50a..38379039d6 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -20,6 +20,7 @@ import ( "fmt" "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" "golang.org/x/sys/unix" @@ -241,6 +242,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { valueType: prometheus.GaugeValue, labels: nil, }, + // when FreeBSD 14.0+, `meta/pm/pd` install of `p`. { name: "arcstats_p_bytes", description: "ZFS ARC MRU target size", @@ -249,6 +251,27 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { valueType: prometheus.GaugeValue, labels: nil, }, + { + name: "arcstats_meta_bytes", + description: "ZFS ARC metadata target frac ", + mib: "kstat.zfs.misc.arcstats.meta", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, + { + name: "arcstats_pd_bytes", + description: "ZFS ARC data MRU target frac", + mib: "kstat.zfs.misc.arcstats.pd", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, + { + name: "arcstats_pm_bytes", + description: "ZFS ARC meta MRU target frac", + mib: "kstat.zfs.misc.arcstats.pm", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, { name: "arcstats_size_bytes", description: "ZFS ARC size", @@ -282,7 +305,9 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { for _, m := range c.sysctls { v, err := m.Value() if err != nil { - return fmt.Errorf("couldn't get sysctl: %w", err) + // debug logging + level.Debug(c.logger).Log("name", m.name, "couldn't get sysctl:", err) + continue } ch <- prometheus.MustNewConstMetric(