Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zfs pool stats collection. #427

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix single dataset test.
The "two pool, one metic" test was only passing because of previous calls to Gather() had already populated the values.
  • Loading branch information
allenpetersen committed Dec 8, 2015
commit e3c8a1131a7cef4110872bbe6c5b535302a40bdd
15 changes: 13 additions & 2 deletions plugins/zfs/zfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
err = ioutil.WriteFile(testKstatPath+"/vdev_cache_stats", []byte(vdev_cache_statsContents), 0644)
require.NoError(t, err)

intMetrics := getKstatMetrics()
intMetrics := getKstatMetricsAll()

var acc testutil.Accumulator

Expand Down Expand Up @@ -225,6 +225,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
}

z = &Zfs{KstatPath: testKstatPath}
acc = testutil.Accumulator{}
err = z.Gather(&acc)
require.NoError(t, err)

Expand All @@ -233,8 +234,11 @@ func TestZfsGeneratesMetrics(t *testing.T) {
assert.True(t, acc.CheckTaggedValue(metric.name, metric.value, tags))
}

intMetrics = getKstatMetricsArcOnly()

//two pools, one metric
z = &Zfs{KstatPath: testKstatPath, KstatMetrics: []string{"arcstats"}}
acc = testutil.Accumulator{}
err = z.Gather(&acc)
require.NoError(t, err)

Expand All @@ -247,7 +251,7 @@ func TestZfsGeneratesMetrics(t *testing.T) {
require.NoError(t, err)
}

func getKstatMetrics() []*metrics {
func getKstatMetricsArcOnly() []*metrics {
return []*metrics{
{
name: "arcstats_hits",
Expand Down Expand Up @@ -593,6 +597,11 @@ func getKstatMetrics() []*metrics {
name: "arcstats_arc_meta_max",
value: 18327165696,
},
}
}

func getKstatMetricsAll() []*metrics {
otherMetrics := []*metrics{
{
name: "zfetchstats_hits",
value: 7812959060,
Expand Down Expand Up @@ -650,6 +659,8 @@ func getKstatMetrics() []*metrics {
value: 0,
},
}

return append(getKstatMetricsArcOnly(), otherMetrics...)
}

func getPoolMetrics() []*metrics {
Expand Down