move plugin interfaces into separate package

This commit is contained in:
David Norton
2016-12-23 10:18:27 -05:00
parent 3e6c4a53a4
commit 81caa56859
182 changed files with 817 additions and 817 deletions

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/shirou/gopsutil/cpu"
)
@@ -42,7 +42,7 @@ func (_ *CPUStats) SampleConfig() string {
return sampleConfig
}
func (s *CPUStats) Gather(acc telegraf.Accumulator) error {
func (s *CPUStats) Gather(acc plugins.Accumulator) error {
times, err := s.ps.CPUTimes(s.PerCPU, s.TotalCPU)
if err != nil {
return fmt.Errorf("error getting CPU info: %s", err)
@@ -117,7 +117,7 @@ func totalCpuTime(t cpu.TimesStat) float64 {
}
func init() {
inputs.Add("cpu", func() telegraf.Input {
inputs.Add("cpu", func() plugins.Input {
return &CPUStats{
PerCPU: true,
TotalCPU: true,

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -36,7 +36,7 @@ func (_ *DiskStats) SampleConfig() string {
return diskSampleConfig
}
func (s *DiskStats) Gather(acc telegraf.Accumulator) error {
func (s *DiskStats) Gather(acc plugins.Accumulator) error {
// Legacy support:
if len(s.Mountpoints) != 0 {
s.MountPoints = s.Mountpoints
@@ -102,7 +102,7 @@ func (_ *DiskIOStats) SampleConfig() string {
return diskIoSampleConfig
}
func (s *DiskIOStats) Gather(acc telegraf.Accumulator) error {
func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
diskio, err := s.ps.DiskIO()
if err != nil {
return fmt.Errorf("error getting disk io info: %s", err)
@@ -149,11 +149,11 @@ func (s *DiskIOStats) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("disk", func() telegraf.Input {
inputs.Add("disk", func() plugins.Input {
return &DiskStats{ps: &systemPS{}}
})
inputs.Add("diskio", func() telegraf.Input {
inputs.Add("diskio", func() plugins.Input {
return &DiskIOStats{ps: &systemPS{}, SkipSerialNumber: true}
})
}

View File

@@ -9,7 +9,7 @@ import (
"os"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -32,7 +32,7 @@ func (k *Kernel) Description() string {
func (k *Kernel) SampleConfig() string { return "" }
func (k *Kernel) Gather(acc telegraf.Accumulator) error {
func (k *Kernel) Gather(acc plugins.Accumulator) error {
data, err := k.getProcStat()
if err != nil {
return err
@@ -102,7 +102,7 @@ func (k *Kernel) getProcStat() ([]byte, error) {
}
func init() {
inputs.Add("kernel", func() telegraf.Input {
inputs.Add("kernel", func() plugins.Input {
return &Kernel{
statFile: "/proc/stat",
}

View File

@@ -3,7 +3,7 @@
package system
import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -16,12 +16,12 @@ func (k *Kernel) Description() string {
func (k *Kernel) SampleConfig() string { return "" }
func (k *Kernel) Gather(acc telegraf.Accumulator) error {
func (k *Kernel) Gather(acc plugins.Accumulator) error {
return nil
}
func init() {
inputs.Add("kernel", func() telegraf.Input {
inputs.Add("kernel", func() plugins.Input {
return &Kernel{}
})
}

View File

@@ -9,7 +9,7 @@ import (
"os"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -25,7 +25,7 @@ func (k *KernelVmstat) SampleConfig() string {
return ""
}
func (k *KernelVmstat) Gather(acc telegraf.Accumulator) error {
func (k *KernelVmstat) Gather(acc plugins.Accumulator) error {
data, err := k.getProcVmstat()
if err != nil {
return err
@@ -70,7 +70,7 @@ func (k *KernelVmstat) getProcVmstat() ([]byte, error) {
}
func init() {
inputs.Add("kernel_vmstat", func() telegraf.Input {
inputs.Add("kernel_vmstat", func() plugins.Input {
return &KernelVmstat{
statFile: "/proc/vmstat",
}

View File

@@ -3,7 +3,7 @@ package system
import (
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -17,7 +17,7 @@ func (_ *MemStats) Description() string {
func (_ *MemStats) SampleConfig() string { return "" }
func (s *MemStats) Gather(acc telegraf.Accumulator) error {
func (s *MemStats) Gather(acc plugins.Accumulator) error {
vm, err := s.ps.VMStat()
if err != nil {
return fmt.Errorf("error getting virtual memory info: %s", err)
@@ -50,7 +50,7 @@ func (_ *SwapStats) Description() string {
func (_ *SwapStats) SampleConfig() string { return "" }
func (s *SwapStats) Gather(acc telegraf.Accumulator) error {
func (s *SwapStats) Gather(acc plugins.Accumulator) error {
swap, err := s.ps.SwapStat()
if err != nil {
return fmt.Errorf("error getting swap memory info: %s", err)
@@ -73,11 +73,11 @@ func (s *SwapStats) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("mem", func() telegraf.Input {
inputs.Add("mem", func() plugins.Input {
return &MemStats{ps: &systemPS{}}
})
inputs.Add("swap", func() telegraf.Input {
inputs.Add("swap", func() plugins.Input {
return &SwapStats{ps: &systemPS{}}
})
}

View File

@@ -5,7 +5,7 @@ import (
"net"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -32,7 +32,7 @@ func (_ *NetIOStats) SampleConfig() string {
return netSampleConfig
}
func (s *NetIOStats) Gather(acc telegraf.Accumulator) error {
func (s *NetIOStats) Gather(acc plugins.Accumulator) error {
netio, err := s.ps.NetIO()
if err != nil {
return fmt.Errorf("error getting net io info: %s", err)
@@ -104,7 +104,7 @@ func (s *NetIOStats) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("net", func() telegraf.Input {
inputs.Add("net", func() plugins.Input {
return &NetIOStats{ps: &systemPS{}}
})
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"syscall"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -22,7 +22,7 @@ func (_ *NetStats) SampleConfig() string {
return tcpstatSampleConfig
}
func (s *NetStats) Gather(acc telegraf.Accumulator) error {
func (s *NetStats) Gather(acc plugins.Accumulator) error {
netconns, err := s.ps.NetConnections()
if err != nil {
return fmt.Errorf("error getting net connections info: %s", err)
@@ -65,7 +65,7 @@ func (s *NetStats) Gather(acc telegraf.Accumulator) error {
}
func init() {
inputs.Add("netstat", func() telegraf.Input {
inputs.Add("netstat", func() plugins.Input {
return &NetStats{ps: &systemPS{}}
})
}

View File

@@ -13,7 +13,7 @@ import (
"runtime"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -31,7 +31,7 @@ func (p *Processes) Description() string {
func (p *Processes) SampleConfig() string { return "" }
func (p *Processes) Gather(acc telegraf.Accumulator) error {
func (p *Processes) Gather(acc plugins.Accumulator) error {
// Get an empty map of metric fields
fields := getEmptyFields()
@@ -211,7 +211,7 @@ func execPS() ([]byte, error) {
}
func init() {
inputs.Add("processes", func() telegraf.Input {
inputs.Add("processes", func() plugins.Input {
return &Processes{
execPS: execPS,
readProcFile: readProcFile,

View File

@@ -3,7 +3,7 @@ package system
import (
"os"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/internal"
"github.com/shirou/gopsutil/cpu"
@@ -23,7 +23,7 @@ type PS interface {
NetConnections() ([]net.ConnectionStat, error)
}
func add(acc telegraf.Accumulator,
func add(acc plugins.Accumulator,
name string, val float64, tags map[string]string) {
if val >= 0 {
acc.AddFields(name, map[string]interface{}{"value": val}, tags)

View File

@@ -9,7 +9,7 @@ import (
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/load"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -21,7 +21,7 @@ func (_ *SystemStats) Description() string {
func (_ *SystemStats) SampleConfig() string { return "" }
func (_ *SystemStats) Gather(acc telegraf.Accumulator) error {
func (_ *SystemStats) Gather(acc plugins.Accumulator) error {
loadavg, err := load.Avg()
if err != nil {
return err
@@ -78,7 +78,7 @@ func format_uptime(uptime uint64) string {
}
func init() {
inputs.Add("system", func() telegraf.Input {
inputs.Add("system", func() plugins.Input {
return &SystemStats{}
})
}