Skip to content

Commit e8c5110

Browse files
fix(zfs) zfs arcstats.p on FreeBSD 14.0+ (prometheus#2754)
* dongjiang, fix zfs arcstats.p Signed-off-by: dongjiang1989 <[email protected]> * dongjiang, fix gofmt -s Signed-off-by: dongjiang1989 <[email protected]> * change warn log to debug log by code review Signed-off-by: dongjiang1989 <[email protected]> --------- Signed-off-by: dongjiang1989 <[email protected]>
1 parent 446b3e6 commit e8c5110

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

collector/zfs_freebsd.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121

2222
"github.com/go-kit/log"
23+
"github.com/go-kit/log/level"
2324
"github.com/prometheus/client_golang/prometheus"
2425

2526
"golang.org/x/sys/unix"
@@ -241,6 +242,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
241242
valueType: prometheus.GaugeValue,
242243
labels: nil,
243244
},
245+
// when FreeBSD 14.0+, `meta/pm/pd` install of `p`.
244246
{
245247
name: "arcstats_p_bytes",
246248
description: "ZFS ARC MRU target size",
@@ -249,6 +251,27 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
249251
valueType: prometheus.GaugeValue,
250252
labels: nil,
251253
},
254+
{
255+
name: "arcstats_meta_bytes",
256+
description: "ZFS ARC metadata target frac ",
257+
mib: "kstat.zfs.misc.arcstats.meta",
258+
dataType: bsdSysctlTypeUint64,
259+
valueType: prometheus.GaugeValue,
260+
},
261+
{
262+
name: "arcstats_pd_bytes",
263+
description: "ZFS ARC data MRU target frac",
264+
mib: "kstat.zfs.misc.arcstats.pd",
265+
dataType: bsdSysctlTypeUint64,
266+
valueType: prometheus.GaugeValue,
267+
},
268+
{
269+
name: "arcstats_pm_bytes",
270+
description: "ZFS ARC meta MRU target frac",
271+
mib: "kstat.zfs.misc.arcstats.pm",
272+
dataType: bsdSysctlTypeUint64,
273+
valueType: prometheus.GaugeValue,
274+
},
252275
{
253276
name: "arcstats_size_bytes",
254277
description: "ZFS ARC size",
@@ -282,7 +305,9 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
282305
for _, m := range c.sysctls {
283306
v, err := m.Value()
284307
if err != nil {
285-
return fmt.Errorf("couldn't get sysctl: %w", err)
308+
// debug logging
309+
level.Debug(c.logger).Log("name", m.name, "couldn't get sysctl:", err)
310+
continue
286311
}
287312

288313
ch <- prometheus.MustNewConstMetric(

0 commit comments

Comments
 (0)