Skip to content

Commit

Permalink
fix(transform): Add support for ancient ZFS dedupratio metric
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
pdf committed Jan 28, 2023
1 parent 4e44fdf commit 85bdc3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions collector/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,22 @@ zfs_pool_unsupported{pool="testpool"} 1024
`,
},
{
name: `legacy fragmentation`,
name: `legacy fragmentation/dedupratio`,
pools: []string{`testpool`},
propsRequested: []string{`fragmentation`},
metricNames: []string{`zfs_pool_fragmentation_ratio`},
propsRequested: []string{`fragmentation`, `dedupratio`},
metricNames: []string{`zfs_pool_fragmentation_ratio`, `zfs_pool_deduplication_ratio`},
propsResults: map[string]map[string]string{
`testpool`: {
`fragmentation`: `5%`,
`dedupratio`: `2.50x`,
},
},
metricResults: `# HELP zfs_pool_fragmentation_ratio The fragmentation ratio of the pool.
# TYPE zfs_pool_fragmentation_ratio gauge
zfs_pool_fragmentation_ratio{pool="testpool"} 0.05
# HELP zfs_pool_deduplication_ratio The ratio of deduplicated size vs undeduplicated size for data in this pool.
# TYPE zfs_pool_deduplication_ratio gauge
zfs_pool_deduplication_ratio{pool="testpool"} 0.4
`,
},
}
Expand Down
3 changes: 3 additions & 0 deletions collector/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func transformPercentage(value string) (float64, error) {
}

func transformMultiplier(value string) (float64, error) {
if len(value) > 0 && value[len(value)-1] == 'x' {
value = value[:len(value)-1]
}
v, err := transformNumeric(value)
if err != nil {
return -1, err
Expand Down

0 comments on commit 85bdc3b

Please sign in to comment.