renaming plugins -> inputs

This commit is contained in:
Cameron Sparr
2016-01-07 13:39:43 -07:00
parent 30d24a3c1c
commit 9c5db1057d
175 changed files with 606 additions and 572 deletions

View File

@@ -1,37 +0,0 @@
package all
import (
_ "github.com/influxdb/telegraf/plugins/aerospike"
_ "github.com/influxdb/telegraf/plugins/apache"
_ "github.com/influxdb/telegraf/plugins/bcache"
_ "github.com/influxdb/telegraf/plugins/disque"
_ "github.com/influxdb/telegraf/plugins/elasticsearch"
_ "github.com/influxdb/telegraf/plugins/exec"
_ "github.com/influxdb/telegraf/plugins/haproxy"
_ "github.com/influxdb/telegraf/plugins/httpjson"
_ "github.com/influxdb/telegraf/plugins/influxdb"
_ "github.com/influxdb/telegraf/plugins/jolokia"
_ "github.com/influxdb/telegraf/plugins/kafka_consumer"
_ "github.com/influxdb/telegraf/plugins/leofs"
_ "github.com/influxdb/telegraf/plugins/lustre2"
_ "github.com/influxdb/telegraf/plugins/mailchimp"
_ "github.com/influxdb/telegraf/plugins/memcached"
_ "github.com/influxdb/telegraf/plugins/mongodb"
_ "github.com/influxdb/telegraf/plugins/mysql"
_ "github.com/influxdb/telegraf/plugins/nginx"
_ "github.com/influxdb/telegraf/plugins/phpfpm"
_ "github.com/influxdb/telegraf/plugins/ping"
_ "github.com/influxdb/telegraf/plugins/postgresql"
_ "github.com/influxdb/telegraf/plugins/procstat"
_ "github.com/influxdb/telegraf/plugins/prometheus"
_ "github.com/influxdb/telegraf/plugins/puppetagent"
_ "github.com/influxdb/telegraf/plugins/rabbitmq"
_ "github.com/influxdb/telegraf/plugins/redis"
_ "github.com/influxdb/telegraf/plugins/rethinkdb"
_ "github.com/influxdb/telegraf/plugins/statsd"
_ "github.com/influxdb/telegraf/plugins/system"
_ "github.com/influxdb/telegraf/plugins/trig"
_ "github.com/influxdb/telegraf/plugins/twemproxy"
_ "github.com/influxdb/telegraf/plugins/zfs"
_ "github.com/influxdb/telegraf/plugins/zookeeper"
)

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/binary"
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"net"
"strconv"
"strings"
@@ -119,7 +119,7 @@ func (a *Aerospike) Description() string {
return "Read stats from an aerospike server"
}
func (a *Aerospike) Gather(acc plugins.Accumulator) error {
func (a *Aerospike) Gather(acc inputs.Accumulator) error {
if len(a.Servers) == 0 {
return a.gatherServer("127.0.0.1:3000", acc)
}
@@ -140,7 +140,7 @@ func (a *Aerospike) Gather(acc plugins.Accumulator) error {
return outerr
}
func (a *Aerospike) gatherServer(host string, acc plugins.Accumulator) error {
func (a *Aerospike) gatherServer(host string, acc inputs.Accumulator) error {
aerospikeInfo, err := getMap(STATISTICS_COMMAND, host)
if err != nil {
return fmt.Errorf("Aerospike info failed: %s", err)
@@ -249,7 +249,7 @@ func get(key []byte, host string) (map[string]string, error) {
func readAerospikeStats(
stats map[string]string,
acc plugins.Accumulator,
acc inputs.Accumulator,
host string,
namespace string,
) {
@@ -336,7 +336,7 @@ func msgLenFromBytes(buf [6]byte) int64 {
}
func init() {
plugins.Add("aerospike", func() plugins.Plugin {
inputs.Add("aerospike", func() inputs.Input {
return &Aerospike{}
})
}

37
plugins/inputs/all/all.go Normal file
View File

@@ -0,0 +1,37 @@
package all
import (
_ "github.com/influxdb/telegraf/plugins/inputs/aerospike"
_ "github.com/influxdb/telegraf/plugins/inputs/apache"
_ "github.com/influxdb/telegraf/plugins/inputs/bcache"
_ "github.com/influxdb/telegraf/plugins/inputs/disque"
_ "github.com/influxdb/telegraf/plugins/inputs/elasticsearch"
_ "github.com/influxdb/telegraf/plugins/inputs/exec"
_ "github.com/influxdb/telegraf/plugins/inputs/haproxy"
_ "github.com/influxdb/telegraf/plugins/inputs/httpjson"
_ "github.com/influxdb/telegraf/plugins/inputs/influxdb"
_ "github.com/influxdb/telegraf/plugins/inputs/jolokia"
_ "github.com/influxdb/telegraf/plugins/inputs/kafka_consumer"
_ "github.com/influxdb/telegraf/plugins/inputs/leofs"
_ "github.com/influxdb/telegraf/plugins/inputs/lustre2"
_ "github.com/influxdb/telegraf/plugins/inputs/mailchimp"
_ "github.com/influxdb/telegraf/plugins/inputs/memcached"
_ "github.com/influxdb/telegraf/plugins/inputs/mongodb"
_ "github.com/influxdb/telegraf/plugins/inputs/mysql"
_ "github.com/influxdb/telegraf/plugins/inputs/nginx"
_ "github.com/influxdb/telegraf/plugins/inputs/phpfpm"
_ "github.com/influxdb/telegraf/plugins/inputs/ping"
_ "github.com/influxdb/telegraf/plugins/inputs/postgresql"
_ "github.com/influxdb/telegraf/plugins/inputs/procstat"
_ "github.com/influxdb/telegraf/plugins/inputs/prometheus"
_ "github.com/influxdb/telegraf/plugins/inputs/puppetagent"
_ "github.com/influxdb/telegraf/plugins/inputs/rabbitmq"
_ "github.com/influxdb/telegraf/plugins/inputs/redis"
_ "github.com/influxdb/telegraf/plugins/inputs/rethinkdb"
_ "github.com/influxdb/telegraf/plugins/inputs/statsd"
_ "github.com/influxdb/telegraf/plugins/inputs/system"
_ "github.com/influxdb/telegraf/plugins/inputs/trig"
_ "github.com/influxdb/telegraf/plugins/inputs/twemproxy"
_ "github.com/influxdb/telegraf/plugins/inputs/zfs"
_ "github.com/influxdb/telegraf/plugins/inputs/zookeeper"
)

View File

@@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Apache struct {
@@ -31,7 +31,7 @@ func (n *Apache) Description() string {
return "Read Apache status information (mod_status)"
}
func (n *Apache) Gather(acc plugins.Accumulator) error {
func (n *Apache) Gather(acc inputs.Accumulator) error {
var wg sync.WaitGroup
var outerr error
@@ -59,7 +59,7 @@ var tr = &http.Transport{
var client = &http.Client{Transport: tr}
func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
func (n *Apache) gatherUrl(addr *url.URL, acc inputs.Accumulator) error {
resp, err := client.Get(addr.String())
if err != nil {
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
@@ -164,7 +164,7 @@ func getTags(addr *url.URL) map[string]string {
}
func init() {
plugins.Add("apache", func() plugins.Plugin {
inputs.Add("apache", func() inputs.Input {
return &Apache{}
})
}

View File

@@ -26,27 +26,27 @@ Measurement names:
dirty_data
Amount of dirty data for this backing device in the cache. Continuously
updated unlike the cache set's version, but may be slightly off.
bypassed
Amount of IO (both reads and writes) that has bypassed the cache
cache_bypass_hits
cache_bypass_misses
Hits and misses for IO that is intended to skip the cache are still counted,
but broken out here.
cache_hits
cache_misses
cache_hit_ratio
Hits and misses are counted per individual IO as bcache sees them; a
partial hit is counted as a miss.
cache_miss_collisions
Counts instances where data was going to be inserted into the cache from a
cache miss, but raced with a write and data was already present (usually 0
since the synchronization for cache misses was rewritten)
cache_readaheads
Count of times readahead occurred.
```
@@ -70,7 +70,7 @@ Using this configuration:
When run with:
```
./telegraf -config telegraf.conf -filter bcache -test
./telegraf -config telegraf.conf -input-filter bcache -test
```
It produces:

View File

@@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Bcache struct {
@@ -69,7 +69,7 @@ func prettyToBytes(v string) uint64 {
return uint64(result)
}
func (b *Bcache) gatherBcache(bdev string, acc plugins.Accumulator) error {
func (b *Bcache) gatherBcache(bdev string, acc inputs.Accumulator) error {
tags := getTags(bdev)
metrics, err := filepath.Glob(bdev + "/stats_total/*")
if len(metrics) < 0 {
@@ -104,7 +104,7 @@ func (b *Bcache) gatherBcache(bdev string, acc plugins.Accumulator) error {
return nil
}
func (b *Bcache) Gather(acc plugins.Accumulator) error {
func (b *Bcache) Gather(acc inputs.Accumulator) error {
bcacheDevsChecked := make(map[string]bool)
var restrictDevs bool
if len(b.BcacheDevs) != 0 {
@@ -135,7 +135,7 @@ func (b *Bcache) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("bcache", func() plugins.Plugin {
inputs.Add("bcache", func() inputs.Input {
return &Bcache{}
})
}

View File

@@ -10,7 +10,7 @@ import (
"strings"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Disque struct {
@@ -61,7 +61,7 @@ var ErrProtocolError = errors.New("disque protocol error")
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *Disque) Gather(acc plugins.Accumulator) error {
func (g *Disque) Gather(acc inputs.Accumulator) error {
if len(g.Servers) == 0 {
url := &url.URL{
Host: ":7711",
@@ -98,7 +98,7 @@ func (g *Disque) Gather(acc plugins.Accumulator) error {
const defaultPort = "7711"
func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
func (g *Disque) gatherServer(addr *url.URL, acc inputs.Accumulator) error {
if g.c == nil {
_, _, err := net.SplitHostPort(addr.Host)
@@ -198,7 +198,7 @@ func (g *Disque) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
}
func init() {
plugins.Add("disque", func() plugins.Plugin {
inputs.Add("disque", func() inputs.Input {
return &Disque{}
})
}

View File

@@ -7,7 +7,7 @@ import (
"time"
"github.com/influxdb/telegraf/internal"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
const statsPath = "/_nodes/stats"
@@ -92,7 +92,7 @@ func (e *Elasticsearch) Description() string {
// Gather reads the stats from Elasticsearch and writes it to the
// Accumulator.
func (e *Elasticsearch) Gather(acc plugins.Accumulator) error {
func (e *Elasticsearch) Gather(acc inputs.Accumulator) error {
for _, serv := range e.Servers {
var url string
if e.Local {
@@ -110,7 +110,7 @@ func (e *Elasticsearch) Gather(acc plugins.Accumulator) error {
return nil
}
func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) error {
func (e *Elasticsearch) gatherNodeStats(url string, acc inputs.Accumulator) error {
nodeStats := &struct {
ClusterName string `json:"cluster_name"`
Nodes map[string]*node `json:"nodes"`
@@ -155,7 +155,7 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) err
return nil
}
func (e *Elasticsearch) gatherClusterStats(url string, acc plugins.Accumulator) error {
func (e *Elasticsearch) gatherClusterStats(url string, acc inputs.Accumulator) error {
clusterStats := &clusterHealth{}
if err := e.gatherData(url, clusterStats); err != nil {
return err
@@ -220,7 +220,7 @@ func (e *Elasticsearch) gatherData(url string, v interface{}) error {
}
func init() {
plugins.Add("elasticsearch", func() plugins.Plugin {
inputs.Add("elasticsearch", func() inputs.Input {
return NewElasticsearch()
})
}

View File

@@ -9,20 +9,19 @@ import (
"github.com/gonuts/go-shellquote"
"github.com/influxdb/telegraf/internal"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
const sampleConfig = `
# the command to run
command = "/usr/bin/mycollector --foo=bar"
# name of the command (used as a prefix for measurements)
name = "mycollector"
# measurement name suffix (for separating different commands)
name_suffix = "_mycollector"
`
type Exec struct {
Command string
Name string
runner Runner
}
@@ -62,7 +61,7 @@ func (e *Exec) Description() string {
return "Read flattened metrics from one or more commands that output JSON to stdout"
}
func (e *Exec) Gather(acc plugins.Accumulator) error {
func (e *Exec) Gather(acc inputs.Accumulator) error {
out, err := e.runner.Run(e)
if err != nil {
return err
@@ -81,18 +80,12 @@ func (e *Exec) Gather(acc plugins.Accumulator) error {
return err
}
var msrmnt_name string
if e.Name == "" {
msrmnt_name = "exec"
} else {
msrmnt_name = "exec_" + e.Name
}
acc.AddFields(msrmnt_name, f.Fields, nil)
acc.AddFields("exec", f.Fields, nil)
return nil
}
func init() {
plugins.Add("exec", func() plugins.Plugin {
inputs.Add("exec", func() inputs.Input {
return NewExec()
})
}

View File

@@ -54,7 +54,6 @@ func TestExec(t *testing.T) {
e := &Exec{
runner: newRunnerMock([]byte(validJson), nil),
Command: "testcommand arg1",
Name: "mycollector",
}
var acc testutil.Accumulator
@@ -68,14 +67,13 @@ func TestExec(t *testing.T) {
"cpu_free": float64(32),
"percent": float64(0.81),
}
acc.AssertContainsFields(t, "exec_mycollector", fields)
acc.AssertContainsFields(t, "exec", fields)
}
func TestExecMalformed(t *testing.T) {
e := &Exec{
runner: newRunnerMock([]byte(malformedJson), nil),
Command: "badcommand arg1",
Name: "mycollector",
}
var acc testutil.Accumulator
@@ -88,7 +86,6 @@ func TestCommandError(t *testing.T) {
e := &Exec{
runner: newRunnerMock(nil, fmt.Errorf("exit status code 1")),
Command: "badcommand",
Name: "mycollector",
}
var acc testutil.Accumulator

View File

@@ -3,7 +3,7 @@ package haproxy
import (
"encoding/csv"
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"io"
"net/http"
"net/url"
@@ -104,7 +104,7 @@ func (r *haproxy) Description() string {
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *haproxy) Gather(acc plugins.Accumulator) error {
func (g *haproxy) Gather(acc inputs.Accumulator) error {
if len(g.Servers) == 0 {
return g.gatherServer("http://127.0.0.1:1936", acc)
}
@@ -126,7 +126,7 @@ func (g *haproxy) Gather(acc plugins.Accumulator) error {
return outerr
}
func (g *haproxy) gatherServer(addr string, acc plugins.Accumulator) error {
func (g *haproxy) gatherServer(addr string, acc inputs.Accumulator) error {
if g.client == nil {
client := &http.Client{}
@@ -156,7 +156,7 @@ func (g *haproxy) gatherServer(addr string, acc plugins.Accumulator) error {
return importCsvResult(res.Body, acc, u.Host)
}
func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error {
func importCsvResult(r io.Reader, acc inputs.Accumulator, host string) error {
csv := csv.NewReader(r)
result, err := csv.ReadAll()
now := time.Now()
@@ -358,7 +358,7 @@ func importCsvResult(r io.Reader, acc plugins.Accumulator, host string) error {
}
func init() {
plugins.Add("haproxy", func() plugins.Plugin {
inputs.Add("haproxy", func() inputs.Input {
return &haproxy{}
})
}

View File

@@ -11,7 +11,7 @@ import (
"sync"
"github.com/influxdb/telegraf/internal"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type HttpJson struct {
@@ -63,7 +63,7 @@ var sampleConfig = `
# ]
# HTTP parameters (all values must be strings)
[plugins.httpjson.parameters]
[inputs.httpjson.parameters]
event_type = "cpu_spike"
threshold = "0.75"
`
@@ -77,7 +77,7 @@ func (h *HttpJson) Description() string {
}
// Gathers data for all servers.
func (h *HttpJson) Gather(acc plugins.Accumulator) error {
func (h *HttpJson) Gather(acc inputs.Accumulator) error {
var wg sync.WaitGroup
errorChannel := make(chan error, len(h.Servers))
@@ -116,7 +116,7 @@ func (h *HttpJson) Gather(acc plugins.Accumulator) error {
// Returns:
// error: Any error that may have occurred
func (h *HttpJson) gatherServer(
acc plugins.Accumulator,
acc inputs.Accumulator,
serverURL string,
) error {
resp, err := h.sendRequest(serverURL)
@@ -210,7 +210,7 @@ func (h *HttpJson) sendRequest(serverURL string) (string, error) {
}
func init() {
plugins.Add("httpjson", func() plugins.Plugin {
inputs.Add("httpjson", func() inputs.Input {
return &HttpJson{client: RealHTTPClient{client: &http.Client{}}}
})
}

View File

@@ -5,7 +5,7 @@ The influxdb plugin collects InfluxDB-formatted data from JSON endpoints.
With a configuration of:
```toml
[[plugins.influxdb]]
[[inputs.influxdb]]
urls = [
"http://127.0.0.1:8086/debug/vars",
"http://192.168.2.1:8086/debug/vars"

View File

@@ -8,7 +8,7 @@ import (
"strings"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type InfluxDB struct {
@@ -32,7 +32,7 @@ func (*InfluxDB) SampleConfig() string {
`
}
func (i *InfluxDB) Gather(acc plugins.Accumulator) error {
func (i *InfluxDB) Gather(acc inputs.Accumulator) error {
errorChannel := make(chan error, len(i.URLs))
var wg sync.WaitGroup
@@ -77,7 +77,7 @@ type point struct {
// Returns:
// error: Any error that may have occurred
func (i *InfluxDB) gatherURL(
acc plugins.Accumulator,
acc inputs.Accumulator,
url string,
) error {
resp, err := http.Get(url)
@@ -140,7 +140,7 @@ func (i *InfluxDB) gatherURL(
}
func init() {
plugins.Add("influxdb", func() plugins.Plugin {
inputs.Add("influxdb", func() inputs.Input {
return &InfluxDB{}
})
}

View File

@@ -5,7 +5,7 @@ import (
"net/http/httptest"
"testing"
"github.com/influxdb/telegraf/plugins/influxdb"
"github.com/influxdb/telegraf/plugins/inputs/influxdb"
"github.com/influxdb/telegraf/testutil"
"github.com/stretchr/testify/require"
)

View File

@@ -8,7 +8,7 @@ import (
"net/http"
"net/url"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Server struct {
@@ -49,7 +49,7 @@ func (j *Jolokia) SampleConfig() string {
context = "/jolokia/read"
# List of servers exposing jolokia read service
[[plugins.jolokia.servers]]
[[inputs.jolokia.servers]]
name = "stable"
host = "192.168.103.2"
port = "8180"
@@ -59,7 +59,7 @@ func (j *Jolokia) SampleConfig() string {
# List of metrics collected on above servers
# Each metric consists in a name, a jmx path and either a pass or drop slice attributes
# This collect all heap memory usage metrics
[[plugins.jolokia.metrics]]
[[inputs.jolokia.metrics]]
name = "heap_memory_usage"
jmx = "/java.lang:type=Memory/HeapMemoryUsage"
`
@@ -108,7 +108,7 @@ func (j *Jolokia) getAttr(requestUrl *url.URL) (map[string]interface{}, error) {
return jsonOut, nil
}
func (j *Jolokia) Gather(acc plugins.Accumulator) error {
func (j *Jolokia) Gather(acc inputs.Accumulator) error {
context := j.Context //"/jolokia/read"
servers := j.Servers
metrics := j.Metrics
@@ -157,7 +157,7 @@ func (j *Jolokia) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("jolokia", func() plugins.Plugin {
inputs.Add("jolokia", func() inputs.Input {
return &Jolokia{jClient: &JolokiaClientImpl{client: &http.Client{}}}
})
}

View File

@@ -6,7 +6,7 @@ import (
"sync"
"github.com/influxdb/influxdb/models"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"github.com/Shopify/sarama"
"github.com/wvanbergen/kafka/consumergroup"
@@ -148,7 +148,7 @@ func (k *Kafka) Stop() {
}
}
func (k *Kafka) Gather(acc plugins.Accumulator) error {
func (k *Kafka) Gather(acc inputs.Accumulator) error {
k.Lock()
defer k.Unlock()
npoints := len(k.pointChan)
@@ -160,7 +160,7 @@ func (k *Kafka) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("kafka_consumer", func() plugins.Plugin {
inputs.Add("kafka_consumer", func() inputs.Input {
return &Kafka{}
})
}

View File

@@ -3,7 +3,7 @@ package leofs
import (
"bufio"
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"net/url"
"os/exec"
"strconv"
@@ -146,7 +146,7 @@ func (l *LeoFS) Description() string {
return "Read metrics from a LeoFS Server via SNMP"
}
func (l *LeoFS) Gather(acc plugins.Accumulator) error {
func (l *LeoFS) Gather(acc inputs.Accumulator) error {
if len(l.Servers) == 0 {
l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc)
return nil
@@ -176,7 +176,7 @@ func (l *LeoFS) Gather(acc plugins.Accumulator) error {
return outerr
}
func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc plugins.Accumulator) error {
func (l *LeoFS) gatherServer(endpoint string, serverType ServerType, acc inputs.Accumulator) error {
cmd := exec.Command("snmpwalk", "-v2c", "-cpublic", endpoint, oid)
stdout, err := cmd.StdoutPipe()
if err != nil {
@@ -225,7 +225,7 @@ func retrieveTokenAfterColon(line string) (string, error) {
}
func init() {
plugins.Add("leofs", func() plugins.Plugin {
inputs.Add("leofs", func() inputs.Input {
return &LeoFS{}
})
}

View File

@@ -14,7 +14,7 @@ import (
"strings"
"github.com/influxdb/telegraf/internal"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
// Lustre proc files can change between versions, so we want to future-proof
@@ -129,7 +129,7 @@ var wanted_mds_fields = []*mapping{
},
}
func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc plugins.Accumulator) error {
func (l *Lustre2) GetLustreProcStats(fileglob string, wanted_fields []*mapping, acc inputs.Accumulator) error {
files, err := filepath.Glob(fileglob)
if err != nil {
return err
@@ -193,7 +193,7 @@ func (l *Lustre2) Description() string {
}
// Gather reads stats from all lustre targets
func (l *Lustre2) Gather(acc plugins.Accumulator) error {
func (l *Lustre2) Gather(acc inputs.Accumulator) error {
l.allFields = make(map[string]map[string]interface{})
if len(l.Ost_procfiles) == 0 {
@@ -244,7 +244,7 @@ func (l *Lustre2) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("lustre2", func() plugins.Plugin {
inputs.Add("lustre2", func() inputs.Input {
return &Lustre2{}
})
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type MailChimp struct {
@@ -34,7 +34,7 @@ func (m *MailChimp) Description() string {
return "Gathers metrics from the /3.0/reports MailChimp API"
}
func (m *MailChimp) Gather(acc plugins.Accumulator) error {
func (m *MailChimp) Gather(acc inputs.Accumulator) error {
if m.api == nil {
m.api = NewChimpAPI(m.ApiKey)
}
@@ -71,7 +71,7 @@ func (m *MailChimp) Gather(acc plugins.Accumulator) error {
return nil
}
func gatherReport(acc plugins.Accumulator, report Report, now time.Time) {
func gatherReport(acc inputs.Accumulator, report Report, now time.Time) {
tags := make(map[string]string)
tags["id"] = report.ID
tags["campaign_title"] = report.CampaignTitle
@@ -110,7 +110,7 @@ func gatherReport(acc plugins.Accumulator, report Report, now time.Time) {
}
func init() {
plugins.Add("mailchimp", func() plugins.Plugin {
inputs.Add("mailchimp", func() inputs.Input {
return &MailChimp{}
})
}

View File

@@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
// Memcached is a memcached plugin
@@ -69,7 +69,7 @@ func (m *Memcached) Description() string {
}
// Gather reads stats from all configured servers accumulates stats
func (m *Memcached) Gather(acc plugins.Accumulator) error {
func (m *Memcached) Gather(acc inputs.Accumulator) error {
if len(m.Servers) == 0 && len(m.UnixSockets) == 0 {
return m.gatherServer(":11211", false, acc)
}
@@ -92,7 +92,7 @@ func (m *Memcached) Gather(acc plugins.Accumulator) error {
func (m *Memcached) gatherServer(
address string,
unix bool,
acc plugins.Accumulator,
acc inputs.Accumulator,
) error {
var conn net.Conn
if unix {
@@ -178,7 +178,7 @@ func parseResponse(r *bufio.Reader) (map[string]string, error) {
}
func init() {
plugins.Add("memcached", func() plugins.Plugin {
inputs.Add("memcached", func() inputs.Input {
return &Memcached{}
})
}

View File

@@ -1,4 +1,4 @@
package plugins
package inputs
import "github.com/stretchr/testify/mock"

View File

@@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"gopkg.in/mgo.v2"
)
@@ -45,7 +45,7 @@ var localhost = &url.URL{Host: "127.0.0.1:27017"}
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (m *MongoDB) Gather(acc plugins.Accumulator) error {
func (m *MongoDB) Gather(acc inputs.Accumulator) error {
if len(m.Servers) == 0 {
m.gatherServer(m.getMongoServer(localhost), acc)
return nil
@@ -88,7 +88,7 @@ func (m *MongoDB) getMongoServer(url *url.URL) *Server {
return m.mongos[url.Host]
}
func (m *MongoDB) gatherServer(server *Server, acc plugins.Accumulator) error {
func (m *MongoDB) gatherServer(server *Server, acc inputs.Accumulator) error {
if server.Session == nil {
var dialAddrs []string
if server.Url.User != nil {
@@ -138,7 +138,7 @@ func (m *MongoDB) gatherServer(server *Server, acc plugins.Accumulator) error {
}
func init() {
plugins.Add("mongodb", func() plugins.Plugin {
inputs.Add("mongodb", func() inputs.Input {
return &MongoDB{
mongos: make(map[string]*Server),
}

View File

@@ -5,7 +5,7 @@ import (
"reflect"
"strconv"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type MongodbData struct {
@@ -97,7 +97,7 @@ func (d *MongodbData) add(key string, val interface{}) {
d.Fields[key] = val
}
func (d *MongodbData) flush(acc plugins.Accumulator) {
func (d *MongodbData) flush(acc inputs.Accumulator) {
acc.AddFields(
"mongodb",
d.Fields,

View File

@@ -4,7 +4,7 @@ import (
"net/url"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
@@ -21,7 +21,7 @@ func (s *Server) getDefaultTags() map[string]string {
return tags
}
func (s *Server) gatherData(acc plugins.Accumulator) error {
func (s *Server) gatherData(acc inputs.Accumulator) error {
s.Session.SetMode(mgo.Eventual, true)
s.Session.SetSocketTimeout(0)
result := &ServerStatus{}

View File

@@ -6,7 +6,7 @@ import (
"strings"
_ "github.com/go-sql-driver/mysql"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Mysql struct {
@@ -35,7 +35,7 @@ func (m *Mysql) Description() string {
var localhost = ""
func (m *Mysql) Gather(acc plugins.Accumulator) error {
func (m *Mysql) Gather(acc inputs.Accumulator) error {
if len(m.Servers) == 0 {
// if we can't get stats in this case, thats fine, don't report
// an error.
@@ -113,7 +113,7 @@ var mappings = []*mapping{
},
}
func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
func (m *Mysql) gatherServer(serv string, acc inputs.Accumulator) error {
// If user forgot the '/', add it
if strings.HasSuffix(serv, ")") {
serv = serv + "/"
@@ -207,7 +207,7 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
}
func init() {
plugins.Add("mysql", func() plugins.Plugin {
inputs.Add("mysql", func() inputs.Input {
return &Mysql{}
})
}

View File

@@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Nginx struct {
@@ -31,7 +31,7 @@ func (n *Nginx) Description() string {
return "Read Nginx's basic status information (ngx_http_stub_status_module)"
}
func (n *Nginx) Gather(acc plugins.Accumulator) error {
func (n *Nginx) Gather(acc inputs.Accumulator) error {
var wg sync.WaitGroup
var outerr error
@@ -59,7 +59,7 @@ var tr = &http.Transport{
var client = &http.Client{Transport: tr}
func (n *Nginx) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
func (n *Nginx) gatherUrl(addr *url.URL, acc inputs.Accumulator) error {
resp, err := client.Get(addr.String())
if err != nil {
return fmt.Errorf("error making HTTP request to %s: %s", addr.String(), err)
@@ -159,7 +159,7 @@ func getTags(addr *url.URL) map[string]string {
}
func init() {
plugins.Add("nginx", func() plugins.Plugin {
inputs.Add("nginx", func() inputs.Input {
return &Nginx{}
})
}

View File

@@ -43,7 +43,7 @@ Using this configuration:
When run with:
```
./telegraf -config telegraf.conf -filter phpfpm -test
./telegraf -config telegraf.conf -input-filter phpfpm -test
```
It produces:

View File

@@ -11,7 +11,7 @@ import (
"strings"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
const (
@@ -67,7 +67,7 @@ func (r *phpfpm) Description() string {
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *phpfpm) Gather(acc plugins.Accumulator) error {
func (g *phpfpm) Gather(acc inputs.Accumulator) error {
if len(g.Urls) == 0 {
return g.gatherServer("http://127.0.0.1/status", acc)
}
@@ -90,7 +90,7 @@ func (g *phpfpm) Gather(acc plugins.Accumulator) error {
}
// Request status page to get stat raw data
func (g *phpfpm) gatherServer(addr string, acc plugins.Accumulator) error {
func (g *phpfpm) gatherServer(addr string, acc inputs.Accumulator) error {
if g.client == nil {
client := &http.Client{}
@@ -153,7 +153,7 @@ func (g *phpfpm) gatherServer(addr string, acc plugins.Accumulator) error {
}
// Import HTTP stat data into Telegraf system
func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat, error) {
func importMetric(r io.Reader, acc inputs.Accumulator, host string) (poolStat, error) {
stats := make(poolStat)
var currentPool string
@@ -209,7 +209,7 @@ func importMetric(r io.Reader, acc plugins.Accumulator, host string) (poolStat,
}
func init() {
plugins.Add("phpfpm", func() plugins.Plugin {
inputs.Add("phpfpm", func() inputs.Input {
return &phpfpm{}
})
}

View File

@@ -7,7 +7,7 @@ import (
"strings"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
// HostPinger is a function that runs the "ping" function using a list of
@@ -56,7 +56,7 @@ func (_ *Ping) SampleConfig() string {
return sampleConfig
}
func (p *Ping) Gather(acc plugins.Accumulator) error {
func (p *Ping) Gather(acc inputs.Accumulator) error {
var wg sync.WaitGroup
errorChannel := make(chan error, len(p.Urls)*2)
@@ -64,7 +64,7 @@ func (p *Ping) Gather(acc plugins.Accumulator) error {
// Spin off a go routine for each url to ping
for _, url := range p.Urls {
wg.Add(1)
go func(url string, acc plugins.Accumulator) {
go func(url string, acc inputs.Accumulator) {
defer wg.Done()
args := p.args(url)
out, err := p.pingHost(args...)
@@ -174,7 +174,7 @@ func processPingOutput(out string) (int, int, float64, error) {
}
func init() {
plugins.Add("ping", func() plugins.Plugin {
inputs.Add("ping", func() inputs.Input {
return &Ping{pingHost: hostPinger}
})
}

View File

@@ -6,7 +6,7 @@ import (
"fmt"
"strings"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
_ "github.com/lib/pq"
)
@@ -53,7 +53,7 @@ func (p *Postgresql) IgnoredColumns() map[string]bool {
var localhost = "host=localhost sslmode=disable"
func (p *Postgresql) Gather(acc plugins.Accumulator) error {
func (p *Postgresql) Gather(acc inputs.Accumulator) error {
var query string
if p.Address == "" || p.Address == "localhost" {
@@ -101,7 +101,7 @@ type scanner interface {
Scan(dest ...interface{}) error
}
func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
func (p *Postgresql) accRow(row scanner, acc inputs.Accumulator) error {
var columnVars []interface{}
var dbname bytes.Buffer
@@ -145,7 +145,7 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
}
func init() {
plugins.Add("postgresql", func() plugins.Plugin {
inputs.Add("postgresql", func() inputs.Input {
return &Postgresql{}
})
}

View File

@@ -10,7 +10,7 @@ import (
"github.com/shirou/gopsutil/process"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Procstat struct {
@@ -45,7 +45,7 @@ func (_ *Procstat) Description() string {
return "Monitor process cpu and memory usage"
}
func (p *Procstat) Gather(acc plugins.Accumulator) error {
func (p *Procstat) Gather(acc inputs.Accumulator) error {
procs, err := p.createProcesses()
if err != nil {
log.Printf("Error: procstat getting process, exe: [%s] pidfile: [%s] pattern: [%s] %s",
@@ -161,7 +161,7 @@ func pidsFromPattern(pattern string) ([]int32, error) {
}
func init() {
plugins.Add("procstat", func() plugins.Plugin {
inputs.Add("procstat", func() inputs.Input {
return NewProcstat()
})
}

View File

@@ -6,14 +6,14 @@ import (
"github.com/shirou/gopsutil/process"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type SpecProcessor struct {
Prefix string
tags map[string]string
fields map[string]interface{}
acc plugins.Accumulator
acc inputs.Accumulator
proc *process.Process
}
@@ -34,7 +34,7 @@ func (p *SpecProcessor) flush() {
func NewSpecProcessor(
prefix string,
acc plugins.Accumulator,
acc inputs.Accumulator,
p *process.Process,
) *SpecProcessor {
tags := make(map[string]string)

View File

@@ -3,7 +3,7 @@ package prometheus
import (
"errors"
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
"io"
@@ -32,7 +32,7 @@ var ErrProtocolError = errors.New("prometheus protocol error")
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (g *Prometheus) Gather(acc plugins.Accumulator) error {
func (g *Prometheus) Gather(acc inputs.Accumulator) error {
var wg sync.WaitGroup
var outerr error
@@ -50,7 +50,7 @@ func (g *Prometheus) Gather(acc plugins.Accumulator) error {
return outerr
}
func (g *Prometheus) gatherURL(url string, acc plugins.Accumulator) error {
func (g *Prometheus) gatherURL(url string, acc inputs.Accumulator) error {
resp, err := http.Get(url)
if err != nil {
return fmt.Errorf("error making HTTP request to %s: %s", url, err)
@@ -97,7 +97,7 @@ func (g *Prometheus) gatherURL(url string, acc plugins.Accumulator) error {
}
func init() {
plugins.Add("prometheus", func() plugins.Plugin {
inputs.Add("prometheus", func() inputs.Input {
return &Prometheus{}
})
}

View File

@@ -8,7 +8,7 @@ import (
"reflect"
"strings"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
// PuppetAgent is a PuppetAgent plugin
@@ -82,7 +82,7 @@ func (pa *PuppetAgent) Description() string {
}
// Gather reads stats from all configured servers accumulates stats
func (pa *PuppetAgent) Gather(acc plugins.Accumulator) error {
func (pa *PuppetAgent) Gather(acc inputs.Accumulator) error {
if len(pa.Location) == 0 {
pa.Location = "/var/lib/puppet/state/last_run_summary.yaml"
@@ -110,7 +110,7 @@ func (pa *PuppetAgent) Gather(acc plugins.Accumulator) error {
return nil
}
func structPrinter(s *State, acc plugins.Accumulator, tags map[string]string) {
func structPrinter(s *State, acc inputs.Accumulator, tags map[string]string) {
e := reflect.ValueOf(s).Elem()
fields := make(map[string]interface{})
@@ -131,7 +131,7 @@ func structPrinter(s *State, acc plugins.Accumulator, tags map[string]string) {
}
func init() {
plugins.Add("puppetagent", func() plugins.Plugin {
inputs.Add("puppetagent", func() inputs.Input {
return &PuppetAgent{}
})
}

View File

@@ -7,7 +7,7 @@ import (
"strconv"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
const DefaultUsername = "guest"
@@ -91,7 +91,7 @@ type Node struct {
SocketsUsed int64 `json:"sockets_used"`
}
type gatherFunc func(r *RabbitMQ, acc plugins.Accumulator, errChan chan error)
type gatherFunc func(r *RabbitMQ, acc inputs.Accumulator, errChan chan error)
var gatherFunctions = []gatherFunc{gatherOverview, gatherNodes, gatherQueues}
@@ -114,7 +114,7 @@ func (r *RabbitMQ) Description() string {
return "Read metrics from one or many RabbitMQ servers via the management API"
}
func (r *RabbitMQ) Gather(acc plugins.Accumulator) error {
func (r *RabbitMQ) Gather(acc inputs.Accumulator) error {
if r.Client == nil {
r.Client = &http.Client{}
}
@@ -167,7 +167,7 @@ func (r *RabbitMQ) requestJSON(u string, target interface{}) error {
return nil
}
func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
func gatherOverview(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) {
overview := &OverviewResponse{}
err := r.requestJSON("/api/overview", &overview)
@@ -203,7 +203,7 @@ func gatherOverview(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
errChan <- nil
}
func gatherNodes(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
func gatherNodes(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) {
nodes := make([]Node, 0)
// Gather information about nodes
err := r.requestJSON("/api/nodes", &nodes)
@@ -240,7 +240,7 @@ func gatherNodes(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
errChan <- nil
}
func gatherQueues(r *RabbitMQ, acc plugins.Accumulator, errChan chan error) {
func gatherQueues(r *RabbitMQ, acc inputs.Accumulator, errChan chan error) {
// Gather information about queues
queues := make([]Queue, 0)
err := r.requestJSON("/api/queues", &queues)
@@ -320,7 +320,7 @@ func (r *RabbitMQ) shouldGatherQueue(queue Queue) bool {
}
func init() {
plugins.Add("rabbitmq", func() plugins.Plugin {
inputs.Add("rabbitmq", func() inputs.Input {
return &RabbitMQ{}
})
}

View File

@@ -10,7 +10,7 @@ import (
"strings"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type Redis struct {
@@ -76,7 +76,7 @@ var ErrProtocolError = errors.New("redis protocol error")
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (r *Redis) Gather(acc plugins.Accumulator) error {
func (r *Redis) Gather(acc inputs.Accumulator) error {
if len(r.Servers) == 0 {
url := &url.URL{
Host: ":6379",
@@ -113,7 +113,7 @@ func (r *Redis) Gather(acc plugins.Accumulator) error {
const defaultPort = "6379"
func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
func (r *Redis) gatherServer(addr *url.URL, acc inputs.Accumulator) error {
_, _, err := net.SplitHostPort(addr.Host)
if err != nil {
addr.Host = addr.Host + ":" + defaultPort
@@ -158,7 +158,7 @@ func (r *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
// gatherInfoOutput gathers
func gatherInfoOutput(
rdr *bufio.Reader,
acc plugins.Accumulator,
acc inputs.Accumulator,
tags map[string]string,
) error {
var keyspace_hits, keyspace_misses uint64 = 0, 0
@@ -227,7 +227,7 @@ func gatherInfoOutput(
func gatherKeyspaceLine(
name string,
line string,
acc plugins.Accumulator,
acc inputs.Accumulator,
tags map[string]string,
) {
if strings.Contains(line, "keys=") {
@@ -246,7 +246,7 @@ func gatherKeyspaceLine(
}
func init() {
plugins.Add("redis", func() plugins.Plugin {
inputs.Add("redis", func() inputs.Input {
return &Redis{}
})
}

View File

@@ -1,4 +1,4 @@
package plugins
package inputs
import "time"
@@ -17,40 +17,40 @@ type Accumulator interface {
t ...time.Time)
}
type Plugin interface {
// SampleConfig returns the default configuration of the Plugin
type Input interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
// Description returns a one-sentence description on the Plugin
// Description returns a one-sentence description on the Input
Description() string
// Gather takes in an accumulator and adds the metrics that the Plugin
// Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval"
Gather(Accumulator) error
}
type ServicePlugin interface {
// SampleConfig returns the default configuration of the Plugin
type ServiceInput interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
// Description returns a one-sentence description on the Plugin
// Description returns a one-sentence description on the Input
Description() string
// Gather takes in an accumulator and adds the metrics that the Plugin
// Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval"
Gather(Accumulator) error
// Start starts the ServicePlugin's service, whatever that may be
// Start starts the ServiceInput's service, whatever that may be
Start() error
// Stop stops the services and closes any necessary channels and connections
Stop()
}
type Creator func() Plugin
type Creator func() Input
var Plugins = map[string]Creator{}
var Inputs = map[string]Creator{}
func Add(name string, creator Creator) {
Plugins[name] = creator
Inputs[name] = creator
}

View File

@@ -5,7 +5,7 @@ import (
"net/url"
"sync"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"gopkg.in/dancannon/gorethink.v1"
)
@@ -35,7 +35,7 @@ var localhost = &Server{Url: &url.URL{Host: "127.0.0.1:28015"}}
// Reads stats from all configured servers accumulates stats.
// Returns one of the errors encountered while gather stats (if any).
func (r *RethinkDB) Gather(acc plugins.Accumulator) error {
func (r *RethinkDB) Gather(acc inputs.Accumulator) error {
if len(r.Servers) == 0 {
r.gatherServer(localhost, acc)
return nil
@@ -65,7 +65,7 @@ func (r *RethinkDB) Gather(acc plugins.Accumulator) error {
return outerr
}
func (r *RethinkDB) gatherServer(server *Server, acc plugins.Accumulator) error {
func (r *RethinkDB) gatherServer(server *Server, acc inputs.Accumulator) error {
var err error
connectOpts := gorethink.ConnectOpts{
Address: server.Url.Host,
@@ -87,7 +87,7 @@ func (r *RethinkDB) gatherServer(server *Server, acc plugins.Accumulator) error
}
func init() {
plugins.Add("rethinkdb", func() plugins.Plugin {
inputs.Add("rethinkdb", func() inputs.Input {
return &RethinkDB{}
})
}

View File

@@ -4,7 +4,7 @@ import (
"reflect"
"time"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type serverStatus struct {
@@ -88,7 +88,7 @@ var engineStats = map[string]string{
func (e *Engine) AddEngineStats(
keys []string,
acc plugins.Accumulator,
acc inputs.Accumulator,
tags map[string]string,
) {
engine := reflect.ValueOf(e).Elem()
@@ -99,7 +99,7 @@ func (e *Engine) AddEngineStats(
acc.AddFields("rethinkdb_engine", fields, tags)
}
func (s *Storage) AddStats(acc plugins.Accumulator, tags map[string]string) {
func (s *Storage) AddStats(acc inputs.Accumulator, tags map[string]string) {
fields := map[string]interface{}{
"cache_bytes_in_use": s.Cache.BytesInUse,
"disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,

View File

@@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
"gopkg.in/dancannon/gorethink.v1"
)
@@ -20,7 +20,7 @@ type Server struct {
serverStatus serverStatus
}
func (s *Server) gatherData(acc plugins.Accumulator) error {
func (s *Server) gatherData(acc inputs.Accumulator) error {
if err := s.getServerStatus(); err != nil {
return fmt.Errorf("Failed to get server_status, %s\n", err)
}
@@ -110,7 +110,7 @@ var ClusterTracking = []string{
"written_docs_per_sec",
}
func (s *Server) addClusterStats(acc plugins.Accumulator) error {
func (s *Server) addClusterStats(acc inputs.Accumulator) error {
cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"cluster"}).Run(s.session)
if err != nil {
return fmt.Errorf("cluster stats query error, %s\n", err.Error())
@@ -138,7 +138,7 @@ var MemberTracking = []string{
"total_writes",
}
func (s *Server) addMemberStats(acc plugins.Accumulator) error {
func (s *Server) addMemberStats(acc inputs.Accumulator) error {
cursor, err := gorethink.DB("rethinkdb").Table("stats").Get([]string{"server", s.serverStatus.Id}).Run(s.session)
if err != nil {
return fmt.Errorf("member stats query error, %s\n", err.Error())
@@ -162,7 +162,7 @@ var TableTracking = []string{
"total_writes",
}
func (s *Server) addTableStats(acc plugins.Accumulator) error {
func (s *Server) addTableStats(acc inputs.Accumulator) error {
tablesCursor, err := gorethink.DB("rethinkdb").Table("table_status").Run(s.session)
defer tablesCursor.Close()
var tables []tableStatus

View File

@@ -12,7 +12,7 @@ import (
"github.com/influxdb/influxdb/services/graphite"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
var dropwarn = "ERROR: Message queue full. Discarding line [%s] " +
@@ -139,7 +139,7 @@ func (_ *Statsd) SampleConfig() string {
return sampleConfig
}
func (s *Statsd) Gather(acc plugins.Accumulator) error {
func (s *Statsd) Gather(acc inputs.Accumulator) error {
s.Lock()
defer s.Unlock()
@@ -490,7 +490,7 @@ func (s *Statsd) Stop() {
}
func init() {
plugins.Add("statsd", func() plugins.Plugin {
inputs.Add("statsd", func() inputs.Input {
return &Statsd{}
})
}

View File

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

View File

@@ -3,7 +3,7 @@ package system
import (
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type DiskStats struct {
@@ -26,7 +26,7 @@ func (_ *DiskStats) SampleConfig() string {
return diskSampleConfig
}
func (s *DiskStats) Gather(acc plugins.Accumulator) error {
func (s *DiskStats) Gather(acc inputs.Accumulator) error {
disks, err := s.ps.DiskUsage()
if err != nil {
return fmt.Errorf("error getting disk usage info: %s", err)
@@ -88,7 +88,7 @@ func (_ *DiskIOStats) SampleConfig() string {
return diskIoSampleConfig
}
func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
func (s *DiskIOStats) Gather(acc inputs.Accumulator) error {
diskio, err := s.ps.DiskIO()
if err != nil {
return fmt.Errorf("error getting disk io info: %s", err)
@@ -134,11 +134,11 @@ func (s *DiskIOStats) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("disk", func() plugins.Plugin {
inputs.Add("disk", func() inputs.Input {
return &DiskStats{ps: &systemPS{}}
})
plugins.Add("diskio", func() plugins.Plugin {
inputs.Add("diskio", func() inputs.Input {
return &DiskIOStats{ps: &systemPS{}}
})
}

View File

@@ -5,7 +5,7 @@ package system
import (
"fmt"
"github.com/influxdb/telegraf/plugins"
"github.com/influxdb/telegraf/plugins/inputs"
)
type DockerStats struct {
@@ -18,7 +18,7 @@ func (_ *DockerStats) Description() string {
func (_ *DockerStats) SampleConfig() string { return "" }
func (s *DockerStats) Gather(acc plugins.Accumulator) error {
func (s *DockerStats) Gather(acc inputs.Accumulator) error {
containers, err := s.ps.DockerStat()
if err != nil {
return fmt.Errorf("error getting docker info: %s", err)
@@ -83,7 +83,7 @@ func (s *DockerStats) Gather(acc plugins.Accumulator) error {
}
func init() {
plugins.Add("docker", func() plugins.Plugin {
inputs.Add("docker", func() inputs.Input {
return &DockerStats{ps: &systemPS{}}
})
}

Some files were not shown because too many files have changed in this diff Show More