From cd589deb96817f46c204f91f966ae328739aa390 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Sat, 16 Jul 2016 11:19:19 -0400 Subject: [PATCH] Add pool.RefreshStats() method, needed for iostat-like functionality. --- zpool.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zpool.go b/zpool.go index 75f810e..3a3e975 100644 --- a/zpool.go +++ b/zpool.go @@ -443,6 +443,18 @@ func PoolStateToName(state PoolState) (name string) { return } +// Refresh the pool's vdev statistics, e.g. bytes read/written. +func (pool *Pool) RefreshStats() (err error) { + var missing C.boolean_t + if 0 != C.zpool_refresh_stats(pool.list.zph, &missing) { + return errors.New("error refreshing stats") + } + if missing == C.B_TRUE { + return errors.New("pool has gone missing") + } + return nil +} + // ReloadProperties re-read ZFS pool properties and features, refresh // Pool.Properties and Pool.Features map func (pool *Pool) ReloadProperties() (err error) {