Document and add support to input plugins for logging alias (#6357)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user