mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-29 23:30:08 +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.
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
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")
|
|
}
|
|
|
|
}
|