Document and add support to input plugins for logging alias (#6357)

This commit is contained in:
Greg
2019-09-23 16:39:50 -06:00
committed by Daniel Nelson
parent e42d2e39c6
commit 817c9a69a9
111 changed files with 961 additions and 659 deletions

View File

@@ -3,7 +3,6 @@ package smart
import (
"bufio"
"fmt"
"log"
"os/exec"
"path"
"regexp"
@@ -120,6 +119,7 @@ type Smart struct {
Devices []string
UseSudo bool
Timeout internal.Duration
Log telegraf.Logger
}
var sampleConfig = `
@@ -209,10 +209,10 @@ func (m *Smart) scan() ([]string, error) {
for _, line := range strings.Split(string(out), "\n") {
dev := strings.Split(line, " ")
if len(dev) > 1 && !excludedDev(m.Excludes, strings.TrimSpace(dev[0])) {
log.Printf("D! [inputs.smart] adding device: %+#v", dev)
m.Log.Debugf("Adding device: %+#v", dev)
devices = append(devices, strings.TrimSpace(dev[0]))
} else {
log.Printf("D! [inputs.smart] skipping device: %+#v", dev)
m.Log.Debugf("Skipping device: %+#v", dev)
}
}
return devices, nil

View File

@@ -15,6 +15,7 @@ import (
func TestGatherAttributes(t *testing.T) {
s := NewSmart()
s.Log = testutil.Logger{}
s.Path = "smartctl"
s.Attributes = true
@@ -330,6 +331,7 @@ func TestGatherAttributes(t *testing.T) {
func TestGatherNoAttributes(t *testing.T) {
s := NewSmart()
s.Log = testutil.Logger{}
s.Path = "smartctl"
s.Attributes = false