Skip to content

Commit

Permalink
fix: Check return code of zfs command for FreeBSD. (#9956)
Browse files Browse the repository at this point in the history
(cherry picked from commit aa2f1b1)
  • Loading branch information
srebhan authored and powersj committed Oct 27, 2021
1 parent c03469e commit 436ef47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/inputs/zfs/zfs_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ func run(command string, args ...string) ([]string, error) {
stdout := strings.TrimSpace(outbuf.String())
stderr := strings.TrimSpace(errbuf.String())

if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("%s error: %s", command, stderr)
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("%s error: %s", command, stderr)
}
return nil, fmt.Errorf("%s error: %s", command, err)
}
return strings.Split(stdout, "\n"), nil
}
Expand Down

0 comments on commit 436ef47

Please sign in to comment.