ZFS Collector: Add vdev_cache_stats functionality

Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>
This commit is contained in:
Joe Handzik 2017-01-23 12:19:51 -06:00
commit 3c9e779989
5 changed files with 72 additions and 4 deletions

View file

@ -27,10 +27,11 @@ import (
)
const (
zfsProcpathBase = "spl/kstat/zfs/"
zfsArcstatsExt = "arcstats"
zfsFetchstatsExt = "zfetchstats"
zfsZilExt = "zil"
zfsProcpathBase = "spl/kstat/zfs/"
zfsArcstatsExt = "arcstats"
zfsFetchstatsExt = "zfetchstats"
zfsVdevCacheStatsExt = "vdev_cache_stats"
zfsZilExt = "zil"
)
func (c *zfsCollector) openProcFile(path string) (file *os.File, err error) {
@ -78,6 +79,18 @@ func (c *zfsCollector) updateZil(ch chan<- prometheus.Metric) (err error) {
})
}
func (c *zfsCollector) updateVdevCacheStats(ch chan<- prometheus.Metric) (err error) {
file, err := c.openProcFile(filepath.Join(zfsProcpathBase, zfsVdevCacheStatsExt))
if err != nil {
return err
}
defer file.Close()
return c.parseProcfsFile(file, zfsVdevCacheStatsExt, func(s zfsSysctl, v zfsMetricValue) {
ch <- c.constSysctlMetric(vdevCache, s, v)
})
}
func (c *zfsCollector) parseProcfsFile(reader io.Reader, fmt_ext string, handler func(zfsSysctl, zfsMetricValue)) (err error) {
scanner := bufio.NewScanner(reader)