ZFS Collector: Add zil functionality
Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>pull/432/head
parent
a3125ab4d9
commit
a02ca9502c
|
@ -2383,6 +2383,45 @@ node_zfsFetch_stride_hits 7.06799e+06
|
|||
# HELP node_zfsFetch_stride_misses kstat.zfs.misc.zfetchstats.stride_misses
|
||||
# TYPE node_zfsFetch_stride_misses untyped
|
||||
node_zfsFetch_stride_misses 0
|
||||
# HELP node_zfsZil_zil_commit_count kstat.zfs.misc.zil.zil_commit_count
|
||||
# TYPE node_zfsZil_zil_commit_count untyped
|
||||
node_zfsZil_zil_commit_count 10
|
||||
# HELP node_zfsZil_zil_commit_writer_count kstat.zfs.misc.zil.zil_commit_writer_count
|
||||
# TYPE node_zfsZil_zil_commit_writer_count untyped
|
||||
node_zfsZil_zil_commit_writer_count 0
|
||||
# HELP node_zfsZil_zil_itx_copied_bytes kstat.zfs.misc.zil.zil_itx_copied_bytes
|
||||
# TYPE node_zfsZil_zil_itx_copied_bytes untyped
|
||||
node_zfsZil_zil_itx_copied_bytes 0
|
||||
# HELP node_zfsZil_zil_itx_copied_count kstat.zfs.misc.zil.zil_itx_copied_count
|
||||
# TYPE node_zfsZil_zil_itx_copied_count untyped
|
||||
node_zfsZil_zil_itx_copied_count 0
|
||||
# HELP node_zfsZil_zil_itx_count kstat.zfs.misc.zil.zil_itx_count
|
||||
# TYPE node_zfsZil_zil_itx_count untyped
|
||||
node_zfsZil_zil_itx_count 0
|
||||
# HELP node_zfsZil_zil_itx_indirect_bytes kstat.zfs.misc.zil.zil_itx_indirect_bytes
|
||||
# TYPE node_zfsZil_zil_itx_indirect_bytes untyped
|
||||
node_zfsZil_zil_itx_indirect_bytes 0
|
||||
# HELP node_zfsZil_zil_itx_indirect_count kstat.zfs.misc.zil.zil_itx_indirect_count
|
||||
# TYPE node_zfsZil_zil_itx_indirect_count untyped
|
||||
node_zfsZil_zil_itx_indirect_count 0
|
||||
# HELP node_zfsZil_zil_itx_metaslab_normal_bytes kstat.zfs.misc.zil.zil_itx_metaslab_normal_bytes
|
||||
# TYPE node_zfsZil_zil_itx_metaslab_normal_bytes untyped
|
||||
node_zfsZil_zil_itx_metaslab_normal_bytes 0
|
||||
# HELP node_zfsZil_zil_itx_metaslab_normal_count kstat.zfs.misc.zil.zil_itx_metaslab_normal_count
|
||||
# TYPE node_zfsZil_zil_itx_metaslab_normal_count untyped
|
||||
node_zfsZil_zil_itx_metaslab_normal_count 0
|
||||
# HELP node_zfsZil_zil_itx_metaslab_slog_bytes kstat.zfs.misc.zil.zil_itx_metaslab_slog_bytes
|
||||
# TYPE node_zfsZil_zil_itx_metaslab_slog_bytes untyped
|
||||
node_zfsZil_zil_itx_metaslab_slog_bytes 0
|
||||
# HELP node_zfsZil_zil_itx_metaslab_slog_count kstat.zfs.misc.zil.zil_itx_metaslab_slog_count
|
||||
# TYPE node_zfsZil_zil_itx_metaslab_slog_count untyped
|
||||
node_zfsZil_zil_itx_metaslab_slog_count 0
|
||||
# HELP node_zfsZil_zil_itx_needcopy_bytes kstat.zfs.misc.zil.zil_itx_needcopy_bytes
|
||||
# TYPE node_zfsZil_zil_itx_needcopy_bytes untyped
|
||||
node_zfsZil_zil_itx_needcopy_bytes 0
|
||||
# HELP node_zfsZil_zil_itx_needcopy_count kstat.zfs.misc.zil.zil_itx_needcopy_count
|
||||
# TYPE node_zfsZil_zil_itx_needcopy_count untyped
|
||||
node_zfsZil_zil_itx_needcopy_count 0
|
||||
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
|
||||
# TYPE process_cpu_seconds_total counter
|
||||
# HELP process_max_fds Maximum number of open file descriptors.
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
7 1 0x01 13 624 8012538347 351689526932992
|
||||
name type data
|
||||
zil_commit_count 4 10
|
||||
zil_commit_writer_count 4 0
|
||||
zil_itx_count 4 0
|
||||
zil_itx_indirect_count 4 0
|
||||
zil_itx_indirect_bytes 4 0
|
||||
zil_itx_copied_count 4 0
|
||||
zil_itx_copied_bytes 4 0
|
||||
zil_itx_needcopy_count 4 0
|
||||
zil_itx_needcopy_bytes 4 0
|
||||
zil_itx_metaslab_normal_count 4 0
|
||||
zil_itx_metaslab_normal_bytes 4 0
|
||||
zil_itx_metaslab_slog_count 4 0
|
||||
zil_itx_metaslab_slog_bytes 4 0
|
|
@ -36,6 +36,7 @@ type zfsSubsystemName string
|
|||
const (
|
||||
arc = zfsSubsystemName("zfsArc")
|
||||
zfetch = zfsSubsystemName("zfsFetch")
|
||||
zil = zfsSubsystemName("zfsZil")
|
||||
zpoolSubsystem = zfsSubsystemName("zfsPool")
|
||||
)
|
||||
|
||||
|
@ -76,6 +77,10 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|||
err = c.updateZfetchstats(ch)
|
||||
if err != nil { return err }
|
||||
|
||||
// Zil
|
||||
err = c.updateZil(ch)
|
||||
if err != nil { return err }
|
||||
|
||||
// Pool stats
|
||||
return c.updatePoolStats(ch)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ const (
|
|||
zfsProcpathBase = "spl/kstat/zfs/"
|
||||
zfsArcstatsExt = "arcstats"
|
||||
zfsFetchstatsExt = "zfetchstats"
|
||||
zfsZilExt = "zil"
|
||||
)
|
||||
|
||||
func (c *zfsCollector) openProcFile(path string) (file *os.File, err error) {
|
||||
|
@ -65,6 +66,18 @@ func (c *zfsCollector) updateZfetchstats(ch chan<- prometheus.Metric) (err error
|
|||
})
|
||||
}
|
||||
|
||||
func (c *zfsCollector) updateZil(ch chan<- prometheus.Metric) (err error) {
|
||||
file, err := c.openProcFile(filepath.Join(zfsProcpathBase, zfsZilExt))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
return c.parseProcfsFile(file, zfsZilExt, func(s zfsSysctl, v zfsMetricValue) {
|
||||
ch <- c.constSysctlMetric(zil, s, v)
|
||||
})
|
||||
}
|
||||
|
||||
func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmt_ext string, handler func(zfsSysctl, zfsMetricValue)) (err error) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
|
||||
|
|
|
@ -89,3 +89,39 @@ func TestZfetchstatsParsing(t *testing.T) {
|
|||
t.Fatal("Zfetchstats parsing handler was not called for some expected sysctls")
|
||||
}
|
||||
}
|
||||
|
||||
func TestZilParsing(t *testing.T) {
|
||||
zilFile, err := os.Open("fixtures/proc/spl/kstat/zfs/zil")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer zilFile.Close()
|
||||
|
||||
c := zfsCollector{}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handlerCalled := false
|
||||
err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v zfsMetricValue) {
|
||||
|
||||
if s != zfsSysctl("kstat.zfs.misc.zil.zil_commit_count") {
|
||||
return
|
||||
}
|
||||
|
||||
handlerCalled = true
|
||||
|
||||
if v != zfsMetricValue(10) {
|
||||
t.Fatalf("Incorrect value parsed from procfs data")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !handlerCalled {
|
||||
t.Fatal("Zil parsing handler was not called for some expected sysctls")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue