mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-20 15:36:07 +01:00
f29f3873ea
It is tested on FreeBSD 10.2-RELEASE and Linux (ZFS on Linux 0.6.5.4). On FreeBSD, Solaris, etc. ZFS metrics are exposed through sysctls. ZFS on Linux exposes the same metrics through procfs `/proc/spl/...`. In addition to sysctl metrics, 'computed metrics' are exposed by the collector, which are based on several sysctl values. There is some conditional logic involved in computing these metrics which cannot be easily mapped to PromQL. Not all 92 ARC sysctls are exposed right now but this can be changed with one additional LOC each.
45 lines
753 B
Go
45 lines
753 B
Go
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")
|
|
}
|
|
|
|
}
|