Create public models for telegraf metrics, accumlator, plugins
This will basically make the root directory a place for storing the major telegraf interfaces, which will make telegraf's godoc looks quite a bit nicer. And make it easier for contributors to lookup the few data types that they actually care about. closes #564
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/url"
|
||||
"sync"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
|
||||
"gopkg.in/dancannon/gorethink.v1"
|
||||
@@ -35,7 +36,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 inputs.Accumulator) error {
|
||||
func (r *RethinkDB) Gather(acc telegraf.Accumulator) error {
|
||||
if len(r.Servers) == 0 {
|
||||
r.gatherServer(localhost, acc)
|
||||
return nil
|
||||
@@ -65,7 +66,7 @@ func (r *RethinkDB) Gather(acc inputs.Accumulator) error {
|
||||
return outerr
|
||||
}
|
||||
|
||||
func (r *RethinkDB) gatherServer(server *Server, acc inputs.Accumulator) error {
|
||||
func (r *RethinkDB) gatherServer(server *Server, acc telegraf.Accumulator) error {
|
||||
var err error
|
||||
connectOpts := gorethink.ConnectOpts{
|
||||
Address: server.Url.Host,
|
||||
@@ -87,7 +88,7 @@ func (r *RethinkDB) gatherServer(server *Server, acc inputs.Accumulator) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("rethinkdb", func() inputs.Input {
|
||||
inputs.Add("rethinkdb", func() telegraf.Input {
|
||||
return &RethinkDB{}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
type serverStatus struct {
|
||||
@@ -88,7 +88,7 @@ var engineStats = map[string]string{
|
||||
|
||||
func (e *Engine) AddEngineStats(
|
||||
keys []string,
|
||||
acc inputs.Accumulator,
|
||||
acc telegraf.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 inputs.Accumulator, tags map[string]string) {
|
||||
func (s *Storage) AddStats(acc telegraf.Accumulator, tags map[string]string) {
|
||||
fields := map[string]interface{}{
|
||||
"cache_bytes_in_use": s.Cache.BytesInUse,
|
||||
"disk_read_bytes_per_sec": s.Disk.ReadBytesPerSec,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
"github.com/influxdata/telegraf"
|
||||
|
||||
"gopkg.in/dancannon/gorethink.v1"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ type Server struct {
|
||||
serverStatus serverStatus
|
||||
}
|
||||
|
||||
func (s *Server) gatherData(acc inputs.Accumulator) error {
|
||||
func (s *Server) gatherData(acc telegraf.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 inputs.Accumulator) error {
|
||||
func (s *Server) addClusterStats(acc telegraf.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 inputs.Accumulator) error {
|
||||
func (s *Server) addMemberStats(acc telegraf.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 inputs.Accumulator) error {
|
||||
func (s *Server) addTableStats(acc telegraf.Accumulator) error {
|
||||
tablesCursor, err := gorethink.DB("rethinkdb").Table("table_status").Run(s.session)
|
||||
defer tablesCursor.Close()
|
||||
var tables []tableStatus
|
||||
|
||||
Reference in New Issue
Block a user