From b65d758bbd8f2b2738dd2c16a626f85bebde5a63 Mon Sep 17 00:00:00 2001 From: Enzo Hamelin Date: Mon, 23 Nov 2020 09:55:00 +0100 Subject: [PATCH] Add log --- plugins/inputs/zfs/zfs.go | 5 +++++ plugins/inputs/zfs/zfs_freebsd.go | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/zfs/zfs.go b/plugins/inputs/zfs/zfs.go index 0fde1950bc13c..297e3cc07ec42 100644 --- a/plugins/inputs/zfs/zfs.go +++ b/plugins/inputs/zfs/zfs.go @@ -1,5 +1,9 @@ package zfs +import ( + "github.com/influxdata/telegraf" +) + type Sysctl func(metric string) ([]string, error) type Zpool func() ([]string, error) type Zdataset func(properties []string) ([]string, error) @@ -12,6 +16,7 @@ type Zfs struct { sysctl Sysctl zpool Zpool zdataset Zdataset + Log telegraf.Logger `toml:"-"` } var sampleConfig = ` diff --git a/plugins/inputs/zfs/zfs_freebsd.go b/plugins/inputs/zfs/zfs_freebsd.go index 1a7455bf0b568..91da244d14946 100644 --- a/plugins/inputs/zfs/zfs_freebsd.go +++ b/plugins/inputs/zfs/zfs_freebsd.go @@ -106,6 +106,7 @@ func (z *Zfs) gatherDatasetStats(acc telegraf.Accumulator) (string, error) { for _, line := range lines { col := strings.Split(line, "\t") if len(col) != len(properties) { + z.Log.Warnf("Invalid number of columns for line: %s", line) continue } @@ -183,7 +184,7 @@ func zpool() ([]string, error) { } func zdataset(properties []string) ([]string, error) { - return run("zfs", []string{"list", "-Hp", "-o", strings.join(properties, ',')}...) + return run("zfs", []string{"list", "-Hp", "-o", strings.Join(properties, ",")}...) } func sysctl(metric string) ([]string, error) {