zfs: prometheus metrics

refs #67
This commit is contained in:
Christian Schwarz
2018-04-05 22:12:25 +02:00
parent 30057d4e59
commit 0764f8824e
3 changed files with 71 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
"context"
"github.com/problame/go-rwccmd"
"github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/util"
)
@ -386,6 +387,9 @@ func zfsBuildBookmarkName(fs *DatasetPath, name string) string { // TODO defensi
func ZFSSnapshot(fs *DatasetPath, name string, recursive bool) (err error) {
promTimer := prometheus.NewTimer(prom.ZFSSnapshotDuration.WithLabelValues(fs.ToString()))
defer promTimer.ObserveDuration()
snapname := zfsBuildSnapName(fs, name)
cmd := exec.Command(ZFS_BINARY, "snapshot", snapname)
@ -409,6 +413,9 @@ func ZFSSnapshot(fs *DatasetPath, name string, recursive bool) (err error) {
func ZFSBookmark(fs *DatasetPath, snapshot, bookmark string) (err error) {
promTimer := prometheus.NewTimer(prom.ZFSBookmarkDuration.WithLabelValues(fs.ToString()))
defer promTimer.ObserveDuration()
snapname := zfsBuildSnapName(fs, snapshot)
bookmarkname := zfsBuildBookmarkName(fs, bookmark)