mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 06:59:44 -08:00
ZFS Collector: Add dmu_tx functionality
Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>
This commit is contained in:
parent
07c7ae733a
commit
94fb93a9f3
|
@ -2350,6 +2350,39 @@ node_zfsArc_prefetch_metadata_misses 16071
|
|||
# HELP node_zfsArc_size kstat.zfs.misc.arcstats.size
|
||||
# TYPE node_zfsArc_size untyped
|
||||
node_zfsArc_size 1.603939792e+09
|
||||
# HELP node_zfsDmuTx_dmu_tx_assigned kstat.zfs.misc.dmu_tx.dmu_tx_assigned
|
||||
# TYPE node_zfsDmuTx_dmu_tx_assigned untyped
|
||||
node_zfsDmuTx_dmu_tx_assigned 3.532844e+06
|
||||
# HELP node_zfsDmuTx_dmu_tx_delay kstat.zfs.misc.dmu_tx.dmu_tx_delay
|
||||
# TYPE node_zfsDmuTx_dmu_tx_delay untyped
|
||||
node_zfsDmuTx_dmu_tx_delay 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_dirty_delay kstat.zfs.misc.dmu_tx.dmu_tx_dirty_delay
|
||||
# TYPE node_zfsDmuTx_dmu_tx_dirty_delay untyped
|
||||
node_zfsDmuTx_dmu_tx_dirty_delay 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_dirty_over_max kstat.zfs.misc.dmu_tx.dmu_tx_dirty_over_max
|
||||
# TYPE node_zfsDmuTx_dmu_tx_dirty_over_max untyped
|
||||
node_zfsDmuTx_dmu_tx_dirty_over_max 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_dirty_throttle kstat.zfs.misc.dmu_tx.dmu_tx_dirty_throttle
|
||||
# TYPE node_zfsDmuTx_dmu_tx_dirty_throttle untyped
|
||||
node_zfsDmuTx_dmu_tx_dirty_throttle 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_error kstat.zfs.misc.dmu_tx.dmu_tx_error
|
||||
# TYPE node_zfsDmuTx_dmu_tx_error untyped
|
||||
node_zfsDmuTx_dmu_tx_error 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_group kstat.zfs.misc.dmu_tx.dmu_tx_group
|
||||
# TYPE node_zfsDmuTx_dmu_tx_group untyped
|
||||
node_zfsDmuTx_dmu_tx_group 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_memory_reclaim kstat.zfs.misc.dmu_tx.dmu_tx_memory_reclaim
|
||||
# TYPE node_zfsDmuTx_dmu_tx_memory_reclaim untyped
|
||||
node_zfsDmuTx_dmu_tx_memory_reclaim 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_memory_reserve kstat.zfs.misc.dmu_tx.dmu_tx_memory_reserve
|
||||
# TYPE node_zfsDmuTx_dmu_tx_memory_reserve untyped
|
||||
node_zfsDmuTx_dmu_tx_memory_reserve 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_quota kstat.zfs.misc.dmu_tx.dmu_tx_quota
|
||||
# TYPE node_zfsDmuTx_dmu_tx_quota untyped
|
||||
node_zfsDmuTx_dmu_tx_quota 0
|
||||
# HELP node_zfsDmuTx_dmu_tx_suspended kstat.zfs.misc.dmu_tx.dmu_tx_suspended
|
||||
# TYPE node_zfsDmuTx_dmu_tx_suspended untyped
|
||||
node_zfsDmuTx_dmu_tx_suspended 0
|
||||
# HELP node_zfsFetch_bogus_streams kstat.zfs.misc.zfetchstats.bogus_streams
|
||||
# TYPE node_zfsFetch_bogus_streams untyped
|
||||
node_zfsFetch_bogus_streams 0
|
||||
|
|
13
collector/fixtures/proc/spl/kstat/zfs/dmu_tx
Normal file
13
collector/fixtures/proc/spl/kstat/zfs/dmu_tx
Normal file
|
@ -0,0 +1,13 @@
|
|||
5 1 0x01 11 528 8010436841 354962070418194
|
||||
name type data
|
||||
dmu_tx_assigned 4 3532844
|
||||
dmu_tx_delay 4 0
|
||||
dmu_tx_error 4 0
|
||||
dmu_tx_suspended 4 0
|
||||
dmu_tx_group 4 0
|
||||
dmu_tx_memory_reserve 4 0
|
||||
dmu_tx_memory_reclaim 4 0
|
||||
dmu_tx_dirty_throttle 4 0
|
||||
dmu_tx_dirty_delay 4 0
|
||||
dmu_tx_dirty_over_max 4 0
|
||||
dmu_tx_quota 4 0
|
|
@ -35,6 +35,7 @@ type zfsSubsystemName string
|
|||
|
||||
const (
|
||||
arc = zfsSubsystemName("zfsArc")
|
||||
dmuTx = zfsSubsystemName("zfsDmuTx")
|
||||
fm = zfsSubsystemName("zfsFm")
|
||||
vdevCache = zfsSubsystemName("zfsVdevCache")
|
||||
xuio = zfsSubsystemName("zfsXuio")
|
||||
|
@ -78,23 +79,39 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|||
|
||||
// Zfetchstats
|
||||
err = c.updateZfetchstats(ch)
|
||||
if err != nil { return err }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Zil
|
||||
err = c.updateZil(ch)
|
||||
if err != nil { return err }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// VdevCacheStats
|
||||
err = c.updateVdevCacheStats(ch)
|
||||
if err != nil { return err }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// XuioStats
|
||||
err = c.updateXuioStats(ch)
|
||||
if err != nil { return err }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Fm
|
||||
err = c.updateFm(ch)
|
||||
if err != nil { return err }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// DmuTx
|
||||
err = c.updateDmuTx(ch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pool stats
|
||||
return c.updatePoolStats(ch)
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
const (
|
||||
zfsProcpathBase = "spl/kstat/zfs/"
|
||||
zfsArcstatsExt = "arcstats"
|
||||
zfsDmuTxExt = "dmu_tx"
|
||||
zfsFmExt = "fm"
|
||||
zfsFetchstatsExt = "zfetchstats"
|
||||
zfsVdevCacheStatsExt = "vdev_cache_stats"
|
||||
|
@ -117,7 +118,19 @@ func (c *zfsCollector) updateFm(ch chan<- prometheus.Metric) (err error) {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmt_ext string, handler func(zfsSysctl, zfsMetricValue)) (err error) {
|
||||
func (c *zfsCollector) updateDmuTx(ch chan<- prometheus.Metric) (err error) {
|
||||
file, err := c.openProcFile(filepath.Join(zfsProcpathBase, zfsDmuTxExt))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
return c.parseProcfsFile(file, zfsDmuTxExt, func(s zfsSysctl, v zfsMetricValue) {
|
||||
ch <- c.constSysctlMetric(dmuTx, s, v)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmtExt string, handler func(zfsSysctl, zfsMetricValue)) (err error) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
|
||||
parseLine := false
|
||||
|
@ -135,7 +148,7 @@ func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmt_ext string, handler
|
|||
continue
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("kstat.zfs.misc.%s.%s", fmt_ext, parts[0])
|
||||
key := fmt.Sprintf("kstat.zfs.misc.%s.%s", fmtExt, parts[0])
|
||||
|
||||
value, err := strconv.Atoi(parts[2])
|
||||
if err != nil {
|
||||
|
@ -145,7 +158,7 @@ func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmt_ext string, handler
|
|||
|
||||
}
|
||||
if !parseLine {
|
||||
return fmt.Errorf("did not parse a single %q metric", fmt_ext)
|
||||
return fmt.Errorf("did not parse a single %q metric", fmtExt)
|
||||
}
|
||||
|
||||
return scanner.Err()
|
||||
|
|
|
@ -233,3 +233,39 @@ func TestFmParsing(t *testing.T) {
|
|||
t.Fatal("Fm parsing handler was not called for some expected sysctls")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDmuTxParsing(t *testing.T) {
|
||||
dmuTxFile, err := os.Open("fixtures/proc/spl/kstat/zfs/dmu_tx")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer dmuTxFile.Close()
|
||||
|
||||
c := zfsCollector{}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(dmuTxFile, "dmu_tx", func(s zfsSysctl, v zfsMetricValue) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.dmu_tx.dmu_tx_assigned") {
|
||||
return
|
||||
}
|
||||
|
||||
handlerCalled = true
|
||||
|
||||
if v != zfsMetricValue(3532844) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !handlerCalled {
|
||||
t.Fatal("DmuTx parsing handler was not called for some expected sysctls")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue