diff --git a/plugins/system/ps/disk/disk_darwin.go b/plugins/system/ps/disk/disk_darwin.go index cbd94bdab..9c5995b9b 100644 --- a/plugins/system/ps/disk/disk_darwin.go +++ b/plugins/system/ps/disk/disk_darwin.go @@ -9,9 +9,14 @@ import ( "github.com/influxdb/telegraf/plugins/system/ps/common" ) -func DiskPartitions(all bool) ([]DiskPartitionStat, error) { +func DiskPartitions(fstypes []string) ([]DiskPartitionStat, error) { var ret []DiskPartitionStat + set := make(map[string]struct{}, len(fstypes)) + for _, s := range fstypes { + set[s] = struct{}{} + } + count, err := Getfsstat(nil, MntWait) if err != nil { return ret, err @@ -74,7 +79,10 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) { Fstype: common.IntToString(stat.Fstypename[:]), Opts: opts, } - ret = append(ret, d) + _, ok := set[d.Fstype] + if ok || len(fstypes) == 0 { + ret = append(ret, d) + } } return ret, nil diff --git a/plugins/system/ps/disk/disk_freebsd.go b/plugins/system/ps/disk/disk_freebsd.go index 5193f3568..7b54c7911 100644 --- a/plugins/system/ps/disk/disk_freebsd.go +++ b/plugins/system/ps/disk/disk_freebsd.go @@ -18,9 +18,14 @@ const ( KernDevstatAll = 772 ) -func DiskPartitions(all bool) ([]DiskPartitionStat, error) { +func DiskPartitions(fstypes []string) ([]DiskPartitionStat, error) { var ret []DiskPartitionStat + set := make(map[string]struct{}, len(fstypes)) + for _, s := range fstypes { + set[s] = struct{}{} + } + // get length count, err := syscall.Getfsstat(nil, MNT_WAIT) if err != nil { @@ -87,7 +92,12 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) { Fstype: common.IntToString(stat.Fstypename[:]), Opts: opts, } - ret = append(ret, d) + + _, ok := set[d.Fstype] + if ok || len(fstypes) == 0 { + ret = append(ret, d) + } + } return ret, nil