|
|
|
@ -17,13 +17,9 @@
|
|
|
|
|
package collector |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
"github.com/go-kit/log" |
|
|
|
|
"github.com/go-kit/log/level" |
|
|
|
|
"github.com/prometheus/client_golang/prometheus" |
|
|
|
|
|
|
|
|
|
"golang.org/x/sys/unix" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type zfsCollector struct { |
|
|
|
@ -48,7 +44,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.linear_cnt", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "abdstats_linear_data_bytes", |
|
|
|
@ -56,7 +51,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.linear_data_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "abdstats_scatter_chunk_waste_bytes", |
|
|
|
@ -64,7 +58,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.scatter_chunk_waste", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "abdstats_scatter_count_total", |
|
|
|
@ -72,7 +65,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.scatter_cnt", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "abdstats_scatter_data_bytes", |
|
|
|
@ -80,7 +72,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.scatter_data_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "abdstats_struct_bytes", |
|
|
|
@ -88,7 +79,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.abdstats.struct_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_anon_bytes", |
|
|
|
@ -96,7 +86,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.anon_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_c_bytes", |
|
|
|
@ -104,7 +93,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.c", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_c_max_bytes", |
|
|
|
@ -112,7 +100,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.c_max", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_c_min_bytes", |
|
|
|
@ -120,7 +107,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.c_min", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_data_bytes", |
|
|
|
@ -128,7 +114,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.data_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_demand_data_hits_total", |
|
|
|
@ -136,7 +121,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.demand_data_hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_demand_data_misses_total", |
|
|
|
@ -144,7 +128,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.demand_data_misses", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_demand_metadata_hits_total", |
|
|
|
@ -152,7 +135,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.demand_metadata_hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_demand_metadata_misses_total", |
|
|
|
@ -160,7 +142,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.demand_metadata_misses", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_hdr_bytes", |
|
|
|
@ -168,7 +149,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.hdr_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_hits_total", |
|
|
|
@ -176,7 +156,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_misses_total", |
|
|
|
@ -184,7 +163,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.misses", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mfu_ghost_hits_total", |
|
|
|
@ -192,7 +170,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mfu_ghost_hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mfu_ghost_size", |
|
|
|
@ -200,7 +177,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mfu_ghost_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mfu_bytes", |
|
|
|
@ -208,7 +184,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mfu_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mru_ghost_hits_total", |
|
|
|
@ -216,7 +191,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mru_ghost_hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mru_ghost_bytes", |
|
|
|
@ -224,7 +198,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mru_ghost_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_mru_bytes", |
|
|
|
@ -232,7 +205,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.mru_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_other_bytes", |
|
|
|
@ -240,7 +212,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.other_size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
// when FreeBSD 14.0+, `meta/pm/pd` install of `p`.
|
|
|
|
|
{ |
|
|
|
@ -249,7 +220,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.p", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "arcstats_meta_bytes", |
|
|
|
@ -278,7 +248,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.arcstats.size", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.GaugeValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "zfetchstats_hits_total", |
|
|
|
@ -286,7 +255,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.zfetchstats.hits", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "zfetchstats_misses_total", |
|
|
|
@ -294,7 +262,6 @@ func NewZfsCollector(logger log.Logger) (Collector, error) {
|
|
|
|
|
mib: "kstat.zfs.misc.zfetchstats.misses", |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: nil, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
logger: logger, |
|
|
|
@ -320,42 +287,3 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *zfsCollector) parseFreeBSDPoolObjsetStats() error { |
|
|
|
|
|
|
|
|
|
sysCtlMetrics := []string{ |
|
|
|
|
"nunlinked", "nunlinks", "nread", "reads", "nwritten", "writes", |
|
|
|
|
} |
|
|
|
|
zfsPoolMibPrefix := "kstat.zfs.pool.dataset" |
|
|
|
|
zfsDatasetNames := []string{} |
|
|
|
|
|
|
|
|
|
zfsDatasets, err := unix.Sysctl(zfsPoolMibPrefix) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("couldn't get sysctl: %w", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for dataset, _ := range zfsDatasets { |
|
|
|
|
if strings.HasSuffix(dataset, ".dataset_name") { |
|
|
|
|
zfsDatasetNames = append(zfsDatasetNames, strings.SplitAfter(dataset, ".")[3]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for zpoolDataset := range zfsDatasetsNames { |
|
|
|
|
zfsDatasetLabels := map[string]string{ |
|
|
|
|
"dataset": zpoolDataset, |
|
|
|
|
"zpool": strings.SplitAfter(zpoolDataset, "/")[0], |
|
|
|
|
} |
|
|
|
|
for metric := range sysCtlMetrics { |
|
|
|
|
c.sysctls = append(c.sysctls, bsdSysctl{ |
|
|
|
|
name: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), |
|
|
|
|
description: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), |
|
|
|
|
mib: fmt.Sprintf("%s.%s.%s", zfsPoolMibPrefix, poolObj, metric), |
|
|
|
|
dataType: bsdSysctlTypeUint64, |
|
|
|
|
valueType: prometheus.CounterValue, |
|
|
|
|
labels: zfsDatasetLabels, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|