From 6d18ce7bcae7102ebb13049915c7e31789f8382d Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Wed, 14 Feb 2024 03:13:18 -0500 Subject: [PATCH] Revert "Add ZFS freebsd per dataset stats (#2753)" (#2925) This reverts commit f34aaa61092fe7e3c6618fdb0b0d16a68a291ff7. Signed-off-by: Caleb Webber --- collector/exec_bsd.go | 6 ---- collector/memory_bsd.go | 12 ------- collector/netisr_freebsd.go | 6 ---- collector/sysctl_bsd.go | 3 -- collector/zfs_freebsd.go | 72 ------------------------------------- collector/zfs_linux.go | 4 +-- collector/zfs_linux_test.go | 2 +- 7 files changed, 3 insertions(+), 102 deletions(-) diff --git a/collector/exec_bsd.go b/collector/exec_bsd.go index 9c123991..87cb3cee 100644 --- a/collector/exec_bsd.go +++ b/collector/exec_bsd.go @@ -49,37 +49,31 @@ func NewExecCollector(logger log.Logger) (Collector, error) { name: "exec_context_switches_total", description: "Context switches since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_swtch", - labels: nil, }, { name: "exec_traps_total", description: "Traps since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_trap", - labels: nil, }, { name: "exec_system_calls_total", description: "System calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_syscall", - labels: nil, }, { name: "exec_device_interrupts_total", description: "Device interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_intr", - labels: nil, }, { name: "exec_software_interrupts_total", description: "Software interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_soft", - labels: nil, }, { name: "exec_forks_total", description: "Number of fork() calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.vm.v_forks", - labels: nil, }, }, logger: logger, diff --git a/collector/memory_bsd.go b/collector/memory_bsd.go index 6f16ac89..6af9d8aa 100644 --- a/collector/memory_bsd.go +++ b/collector/memory_bsd.go @@ -69,21 +69,18 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { description: "Recently used by userland", mib: "vm.stats.vm.v_active_count", conversion: fromPage, - labels: nil, }, { name: "inactive_bytes", description: "Not recently used by userland", mib: "vm.stats.vm.v_inactive_count", conversion: fromPage, - labels: nil, }, { name: "wired_bytes", description: "Locked in memory by kernel, mlock, etc", mib: "vm.stats.vm.v_wire_count", conversion: fromPage, - labels: nil, }, { name: "user_wired_bytes", @@ -91,49 +88,42 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_user_wire_count", conversion: fromPage, dataType: bsdSysctlTypeCLong, - labels: nil, }, { name: "cache_bytes", description: "Almost free, backed by swap or files, available for re-allocation", mib: "vm.stats.vm.v_cache_count", conversion: fromPage, - labels: nil, }, { name: "buffer_bytes", description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel", mib: "vfs.bufspace", dataType: bsdSysctlTypeCLong, - labels: nil, }, { name: "free_bytes", description: "Unallocated, available for allocation", mib: "vm.stats.vm.v_free_count", conversion: fromPage, - labels: nil, }, { name: "laundry_bytes", description: "Dirty not recently used by userland", mib: "vm.stats.vm.v_laundry_count", conversion: fromPage, - labels: nil, }, { name: "size_bytes", description: "Total physical memory size", mib: "vm.stats.vm.v_page_count", conversion: fromPage, - labels: nil, }, { name: "swap_size_bytes", description: "Total swap memory size", mib: mibSwapTotal, dataType: bsdSysctlTypeUint64, - labels: nil, }, // Descriptions via: top(1) { @@ -142,7 +132,6 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsin", valueType: prometheus.CounterValue, conversion: fromPage, - labels: nil, }, { name: "swap_out_bytes_total", @@ -150,7 +139,6 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsout", valueType: prometheus.CounterValue, conversion: fromPage, - labels: nil, }, }, }, nil diff --git a/collector/netisr_freebsd.go b/collector/netisr_freebsd.go index 43991f3a..442bcdc6 100644 --- a/collector/netisr_freebsd.go +++ b/collector/netisr_freebsd.go @@ -45,7 +45,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.numthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxprot", @@ -53,7 +52,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxprot", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "defaultqlimit", @@ -61,7 +59,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.defaultqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxqlimit", @@ -69,7 +66,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "bindthreads", @@ -77,7 +73,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.bindthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, { name: "maxthreads", @@ -85,7 +80,6 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, - labels: nil, }, }, logger: logger, diff --git a/collector/sysctl_bsd.go b/collector/sysctl_bsd.go index df5c9f93..2ab248ed 100644 --- a/collector/sysctl_bsd.go +++ b/collector/sysctl_bsd.go @@ -59,9 +59,6 @@ type bsdSysctl struct { // Post-retrieval conversion hooks conversion func(float64) float64 - - // Prometheus labels - labels prometheus.Labels } func (b bsdSysctl) Value() (float64, error) { diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 0e4d9692..bc4aa1c3 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -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 -} diff --git a/collector/zfs_linux.go b/collector/zfs_linux.go index e7be4a98..ec195b3d 100644 --- a/collector/zfs_linux.go +++ b/collector/zfs_linux.go @@ -104,7 +104,7 @@ func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { return errZFSNotAvailable } - err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { ch <- c.constPoolObjsetMetric(poolName, datasetName, s, v) }) file.Close() @@ -220,7 +220,7 @@ func (c *zfsCollector) parsePoolProcfsFile(reader io.Reader, zpoolPath string, h return scanner.Err() } -func (c *zfsCollector) parseLinuxPoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { +func (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { scanner := bufio.NewScanner(reader) parseLine := false diff --git a/collector/zfs_linux_test.go b/collector/zfs_linux_test.go index f6ce8d94..69e4ed8f 100644 --- a/collector/zfs_linux_test.go +++ b/collector/zfs_linux_test.go @@ -332,7 +332,7 @@ func TestZpoolObjsetParsing(t *testing.T) { t.Fatal(err) } - err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { if s != zfsSysctl("kstat.zfs.misc.objset.writes") { return }