ZFS Collector: Add zil functionality

Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>
This commit is contained in:
Joe Handzik 2017-01-23 11:56:39 -06:00
commit a02ca9502c
5 changed files with 108 additions and 0 deletions

View file

@ -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)