Add ability to generate config from available plugins

This commit is contained in:
Evan Phoenix
2015-05-18 15:10:11 -07:00
parent b2c5d95737
commit 82cbc4daa2
7 changed files with 195 additions and 23 deletions

View File

@@ -14,17 +14,27 @@ type Server struct {
}
type Mysql struct {
Disabled bool
Servers []*Server
Servers []*Server
}
var sampleConfig = `
# specify servers via a url matching:
# [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]]
#
# If no servers are specified, then localhost is used as the host.
servers = ["localhost"]`
func (m *Mysql) SampleConfig() string {
return sampleConfig
}
func (m *Mysql) Description() string {
return "Read metrics from one or many mysql servers"
}
var localhost = &Server{}
func (m *Mysql) Gather(acc plugins.Accumulator) error {
if m.Disabled {
return nil
}
if len(m.Servers) == 0 {
// if we can't get stats in this case, thats fine, don't report
// an error.