Skip to content

Commit

Permalink
zpool: Split after \t instead of any space
Browse files Browse the repository at this point in the history
Without things like dates (Wed Feb 21 12:51 2018) are split into multiple fields.
  • Loading branch information
timaebi authored and mmlb committed Apr 1, 2022
1 parent 81c92b4 commit 82ca81a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *command) Run(arg ...string) ([][]string, error) {
output := make([][]string, len(lines))

for i, l := range lines {
output[i] = strings.Fields(l)
output[i] = strings.Split(l, "\t")
}

return output, nil
Expand Down
2 changes: 1 addition & 1 deletion utils_notsolaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ var (
zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio", "fragmentation", "freeing", "leaked"}

zpoolPropListOptions = strings.Join(zpoolPropList, ",")
zpoolArgs = []string{"get", "-p", zpoolPropListOptions}
zpoolArgs = []string{"get", "-Hp", zpoolPropListOptions}
)
2 changes: 1 addition & 1 deletion utils_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ var (
zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio"}

zpoolPropListOptions = strings.Join(zpoolPropList, ",")
zpoolArgs = []string{"get", "-p", zpoolPropListOptions}
zpoolArgs = []string{"get", "-Hp", zpoolPropListOptions}
)
3 changes: 0 additions & 3 deletions zpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ func GetZpool(name string) (*Zpool, error) {
return nil, err
}

// there is no -H
out = out[1:]

z := &Zpool{Name: name}
for _, line := range out {
if err := z.parseLine(line); err != nil {
Expand Down

0 comments on commit 82ca81a

Please sign in to comment.