ZFS Collector: Add vdev_cache_stats functionality
Signed-Off-By: Joe Handzik <joseph.t.handzik@hpe.com>
This commit is contained in:
parent
a02ca9502c
commit
3c9e779989
5 changed files with 72 additions and 4 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue