2015-04-01 16:34:32 +00:00
|
|
|
package plugins
|
|
|
|
|
2015-05-27 05:14:42 +00:00
|
|
|
import "time"
|
|
|
|
|
2015-04-06 16:32:10 +00:00
|
|
|
type Accumulator interface {
|
2015-05-29 20:31:27 +00:00
|
|
|
// Create a point with a value, decorating it with tags
|
2015-05-27 05:14:42 +00:00
|
|
|
// NOTE: tags is expected to be owned by the caller, don't mutate
|
|
|
|
// it after passing to Add.
|
2015-10-16 22:13:32 +00:00
|
|
|
Add(measurement string,
|
|
|
|
value interface{},
|
2015-05-27 05:14:42 +00:00
|
|
|
tags map[string]string,
|
2015-10-16 22:13:32 +00:00
|
|
|
t ...time.Time)
|
|
|
|
|
|
|
|
AddFields(measurement string,
|
|
|
|
fields map[string]interface{},
|
|
|
|
tags map[string]string,
|
|
|
|
t ...time.Time)
|
2015-04-06 16:32:10 +00:00
|
|
|
}
|
2015-04-01 16:34:32 +00:00
|
|
|
|
|
|
|
type Plugin interface {
|
2015-09-24 18:06:11 +00:00
|
|
|
// SampleConfig returns the default configuration of the Plugin
|
2015-05-18 22:10:11 +00:00
|
|
|
SampleConfig() string
|
2015-09-24 18:06:11 +00:00
|
|
|
|
|
|
|
// Description returns a one-sentence description on the Plugin
|
2015-05-18 22:10:11 +00:00
|
|
|
Description() string
|
2015-09-24 18:06:11 +00:00
|
|
|
|
|
|
|
// Gather takes in an accumulator and adds the metrics that the Plugin
|
|
|
|
// gathers. This is called every "interval"
|
2015-04-06 16:32:10 +00:00
|
|
|
Gather(Accumulator) error
|
2015-04-01 16:34:32 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 18:06:11 +00:00
|
|
|
type ServicePlugin interface {
|
|
|
|
// SampleConfig returns the default configuration of the Plugin
|
|
|
|
SampleConfig() string
|
|
|
|
|
|
|
|
// Description returns a one-sentence description on the Plugin
|
|
|
|
Description() string
|
|
|
|
|
|
|
|
// Gather takes in an accumulator and adds the metrics that the Plugin
|
|
|
|
// gathers. This is called every "interval"
|
|
|
|
Gather(Accumulator) error
|
|
|
|
|
|
|
|
// Start starts the ServicePlugin's service, whatever that may be
|
|
|
|
Start() error
|
|
|
|
|
|
|
|
// Stop stops the services and closes any necessary channels and connections
|
|
|
|
Stop()
|
|
|
|
}
|
|
|
|
|
2015-04-01 16:34:32 +00:00
|
|
|
type Creator func() Plugin
|
|
|
|
|
|
|
|
var Plugins = map[string]Creator{}
|
|
|
|
|
|
|
|
func Add(name string, creator Creator) {
|
|
|
|
Plugins[name] = creator
|
|
|
|
}
|