Skip to content

Commit

Permalink
fix(zfs) zfs arcstats.p on FreeBSD 14.0+ (#2754)
Browse files Browse the repository at this point in the history
* dongjiang, fix zfs arcstats.p

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>

* dongjiang, fix gofmt -s

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>

* change warn log to debug log by code review

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>

---------

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
  • Loading branch information
dongjiang1989 committed Sep 20, 2023
1 parent 446b3e6 commit e8c5110
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion collector/zfs_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e8c5110

Please sign in to comment.