mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
Remove FreeBSD support for zfs plugin.
This also involves removing zfs_zpool code for now. Signed-Off-By: Corey Stewart <stewa169@purdue.edu> Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>
This commit is contained in:
parent
a8c94d48e6
commit
10ba27bf2c
|
@ -1,78 +0,0 @@
|
|||
kstat.zfs.misc.arcstats.arc_meta_max: 1503210048
|
||||
kstat.zfs.misc.arcstats.arc_meta_limit: 393216000
|
||||
kstat.zfs.misc.arcstats.arc_meta_used: 392649848
|
||||
kstat.zfs.misc.arcstats.duplicate_reads: 0
|
||||
kstat.zfs.misc.arcstats.duplicate_buffers_size: 0
|
||||
kstat.zfs.misc.arcstats.duplicate_buffers: 0
|
||||
kstat.zfs.misc.arcstats.memory_throttle_count: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_buffer_list_null_iter: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_buffer_list_iter: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_buffer_bytes_scanned: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_pios: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_buffer_iter: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_full: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_not_cacheable: 29425
|
||||
kstat.zfs.misc.arcstats.l2_write_io_in_progress: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_in_l2: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_spa_mismatch: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_passed_headroom: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_trylock_fail: 0
|
||||
kstat.zfs.misc.arcstats.l2_compress_failures: 0
|
||||
kstat.zfs.misc.arcstats.l2_compress_zeros: 0
|
||||
kstat.zfs.misc.arcstats.l2_compress_successes: 0
|
||||
kstat.zfs.misc.arcstats.l2_hdr_size: 0
|
||||
kstat.zfs.misc.arcstats.l2_asize: 0
|
||||
kstat.zfs.misc.arcstats.l2_size: 0
|
||||
kstat.zfs.misc.arcstats.l2_io_error: 0
|
||||
kstat.zfs.misc.arcstats.l2_cksum_bad: 0
|
||||
kstat.zfs.misc.arcstats.l2_abort_lowmem: 0
|
||||
kstat.zfs.misc.arcstats.l2_cdata_free_on_write: 0
|
||||
kstat.zfs.misc.arcstats.l2_free_on_write: 0
|
||||
kstat.zfs.misc.arcstats.l2_evict_reading: 0
|
||||
kstat.zfs.misc.arcstats.l2_evict_lock_retry: 0
|
||||
kstat.zfs.misc.arcstats.l2_writes_hdr_miss: 0
|
||||
kstat.zfs.misc.arcstats.l2_writes_error: 0
|
||||
kstat.zfs.misc.arcstats.l2_writes_done: 0
|
||||
kstat.zfs.misc.arcstats.l2_writes_sent: 0
|
||||
kstat.zfs.misc.arcstats.l2_write_bytes: 0
|
||||
kstat.zfs.misc.arcstats.l2_read_bytes: 0
|
||||
kstat.zfs.misc.arcstats.l2_rw_clash: 0
|
||||
kstat.zfs.misc.arcstats.l2_feeds: 0
|
||||
kstat.zfs.misc.arcstats.l2_misses: 0
|
||||
kstat.zfs.misc.arcstats.l2_hits: 0
|
||||
kstat.zfs.misc.arcstats.other_size: 166832272
|
||||
kstat.zfs.misc.arcstats.data_size: 1200779776
|
||||
kstat.zfs.misc.arcstats.hdr_size: 27244008
|
||||
kstat.zfs.misc.arcstats.size: 1394856056
|
||||
kstat.zfs.misc.arcstats.c_max: 1572864000
|
||||
kstat.zfs.misc.arcstats.c_min: 196608000
|
||||
kstat.zfs.misc.arcstats.c: 1470553736
|
||||
kstat.zfs.misc.arcstats.p: 665524427
|
||||
kstat.zfs.misc.arcstats.hash_chain_max: 7
|
||||
kstat.zfs.misc.arcstats.hash_chains: 14180
|
||||
kstat.zfs.misc.arcstats.hash_collisions: 2180398
|
||||
kstat.zfs.misc.arcstats.hash_elements_max: 238188
|
||||
kstat.zfs.misc.arcstats.hash_elements: 111458
|
||||
kstat.zfs.misc.arcstats.evict_l2_ineligible: 60262400
|
||||
kstat.zfs.misc.arcstats.evict_l2_eligible: 35702978560
|
||||
kstat.zfs.misc.arcstats.evict_l2_cached: 0
|
||||
kstat.zfs.misc.arcstats.evict_skip: 21716568
|
||||
kstat.zfs.misc.arcstats.mutex_miss: 873
|
||||
kstat.zfs.misc.arcstats.recycle_miss: 5018771
|
||||
kstat.zfs.misc.arcstats.stolen: 1327563
|
||||
kstat.zfs.misc.arcstats.deleted: 1187256
|
||||
kstat.zfs.misc.arcstats.allocated: 10150518
|
||||
kstat.zfs.misc.arcstats.mfu_ghost_hits: 1408986
|
||||
kstat.zfs.misc.arcstats.mfu_hits: 51952454
|
||||
kstat.zfs.misc.arcstats.mru_ghost_hits: 696819
|
||||
kstat.zfs.misc.arcstats.mru_hits: 11115835
|
||||
kstat.zfs.misc.arcstats.prefetch_metadata_misses: 32
|
||||
kstat.zfs.misc.arcstats.prefetch_metadata_hits: 2
|
||||
kstat.zfs.misc.arcstats.prefetch_data_misses: 0
|
||||
kstat.zfs.misc.arcstats.prefetch_data_hits: 0
|
||||
kstat.zfs.misc.arcstats.demand_metadata_misses: 9231542
|
||||
kstat.zfs.misc.arcstats.demand_metadata_hits: 40650947
|
||||
kstat.zfs.misc.arcstats.demand_data_misses: 75230
|
||||
kstat.zfs.misc.arcstats.demand_data_hits: 22417340
|
||||
kstat.zfs.misc.arcstats.misses: 9306804
|
||||
kstat.zfs.misc.arcstats.hits: 63068289
|
|
@ -1,12 +0,0 @@
|
|||
trout size 4294967296 -
|
||||
trout free 1040117248 -
|
||||
trout allocated 70144 -
|
||||
trout capacity 0% -
|
||||
trout dedupratio 1.00x -
|
||||
trout fragmentation 0% -
|
||||
zroot size 118111600640 -
|
||||
zroot free 3990917120 -
|
||||
zroot allocated 114120683520 -
|
||||
zroot capacity 50% -
|
||||
zroot dedupratio 1.00x -
|
||||
zroot fragmentation 67% -
|
|
@ -11,11 +11,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package collector
|
||||
|
||||
// +build linux freebsd
|
||||
// +build linux
|
||||
// +build !nozfs
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/log"
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS:
|
||||
#include <sys/param.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
int zfsModuleLoaded() {
|
||||
int modid = modfind("zfs");
|
||||
return modid < 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func (c *zfsCollector) zfsAvailable() error {
|
||||
if C.zfsModuleLoaded() == 0 {
|
||||
return zfsNotAvailableError
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const zfsArcstatsSysctl = "kstat.zfs.misc.arcstats"
|
||||
|
||||
func (c *zfsCollector) RunOnStdout(cmd *exec.Cmd, handler func(io.Reader) error) (err error) {
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = cmd.Start(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = handler(stdout)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return cmd.Wait()
|
||||
}
|
||||
|
||||
func (c *zfsCollector) updateArcstats(ch chan<- prometheus.Metric) (err error) {
|
||||
|
||||
cmd := exec.Command("sysctl", zfsArcstatsSysctl)
|
||||
|
||||
err = c.RunOnStdout(cmd, func(stdout io.Reader) error {
|
||||
return c.parseArcstatsSysctlOutput(stdout, func(sysctl zfsSysctl, value zfsMetricValue) {
|
||||
ch <- c.constSysctlMetric(arc, sysctl, zfsMetricValue(value))
|
||||
})
|
||||
})
|
||||
return err
|
||||
|
||||
}
|
||||
|
||||
func (c *zfsCollector) parseArcstatsSysctlOutput(reader io.Reader, handler func(zfsSysctl, zfsMetricValue)) (err error) {
|
||||
|
||||
// Decode values
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
|
||||
fields := strings.Fields(scanner.Text())
|
||||
|
||||
if len(fields) != 2 ||
|
||||
!strings.HasPrefix(fields[0], zfsArcstatsSysctl) ||
|
||||
!strings.HasSuffix(fields[0], ":") {
|
||||
|
||||
log.Debugf("Skipping line of unknown format: %q", scanner.Text())
|
||||
continue
|
||||
|
||||
}
|
||||
|
||||
sysctl := zfsSysctl(strings.TrimSuffix(fields[0], ":"))
|
||||
value, err := strconv.Atoi(fields[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
handler(sysctl, zfsMetricValue(value))
|
||||
}
|
||||
return scanner.Err()
|
||||
|
||||
}
|
||||
|
||||
func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) (err error) {
|
||||
|
||||
poolProperties := []string{"size", "free", "allocated", "capacity", "dedupratio", "fragmentation"}
|
||||
|
||||
cmd := exec.Command("zpool", "get", "-pH", strings.Join(poolProperties, ","))
|
||||
|
||||
err = c.RunOnStdout(cmd, func(stdout io.Reader) error {
|
||||
return c.parseZpoolOutput(stdout, func(pool, name string, value float64) {
|
||||
ch <- c.constZpoolMetric(pool, name, value)
|
||||
})
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestArcstatsParsing(t *testing.T) {
|
||||
|
||||
arcstatsOutput, err := os.Open("fixtures/sysctl/freebsd/kstat.zfs.misc.arcstats.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer arcstatsOutput.Close()
|
||||
|
||||
c := zfsCollector{}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseArcstatsSysctlOutput(arcstatsOutput, func(s zfsSysctl, v zfsMetricValue) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.arcstats.hits") {
|
||||
return
|
||||
}
|
||||
|
||||
handlerCalled = true
|
||||
|
||||
if v != zfsMetricValue(63068289) {
|
||||
t.Fatalf("Incorrect value parsed from sysctl output")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !handlerCalled {
|
||||
t.Fatal("Arcstats parsing handler was not called for some expected sysctls")
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright 2016 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// zpool metrics
|
||||
|
||||
func (c *zfsCollector) parseZpoolOutput(reader io.Reader, handler func(string, string, float64)) (err error) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
|
||||
fields := strings.Fields(scanner.Text())
|
||||
if len(fields) != 4 {
|
||||
return fmt.Errorf("unexpected output of zpool command")
|
||||
}
|
||||
|
||||
valueString := fields[2]
|
||||
switch {
|
||||
case strings.HasSuffix(fields[2], "%"):
|
||||
percentage := strings.TrimSuffix(fields[2], "%")
|
||||
valueString = "0." + percentage
|
||||
case strings.HasSuffix(fields[2], "x"):
|
||||
valueString = strings.TrimSuffix(fields[2], "x")
|
||||
}
|
||||
|
||||
value, err := strconv.ParseFloat(valueString, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
handler(fields[0], fields[1], value)
|
||||
|
||||
}
|
||||
return scanner.Err()
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
// Copyright 2016 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestZpoolParsing(t *testing.T) {
|
||||
zpoolOutput, err := os.Open("fixtures/zfs/zpool_stats_stdout.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer zpoolOutput.Close()
|
||||
|
||||
c := zfsCollector{}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
pools := make([]string, 2)
|
||||
troutSize := float64(-1)
|
||||
troutDedupratio := float64(-1)
|
||||
zrootCapacity := float64(-1)
|
||||
|
||||
err = c.parseZpoolOutput(zpoolOutput, func(pool, name string, value float64) {
|
||||
pools = append(pools, pool)
|
||||
if pool == "trout" && name == "size" {
|
||||
troutSize = value
|
||||
}
|
||||
if pool == "trout" && name == "dedupratio" {
|
||||
troutDedupratio = value
|
||||
}
|
||||
if pool == "zroot" && name == "capacity" {
|
||||
zrootCapacity = value
|
||||
}
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if pools[0] == "trout" && pools[1] == "zroot" {
|
||||
t.Fatal("Did not parse all pools in fixture")
|
||||
}
|
||||
|
||||
if troutSize != float64(4294967296) {
|
||||
t.Fatal("Unexpected value for pool 'trout's size value")
|
||||
}
|
||||
|
||||
if troutDedupratio != float64(1.0) {
|
||||
t.Fatal("Unexpected value for pool 'trout's dedupratio value")
|
||||
}
|
||||
|
||||
if zrootCapacity != float64(0.5) {
|
||||
t.Fatal("Unexpected value for pool 'zroot's capacity value")
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue