-
Notifications
You must be signed in to change notification settings - Fork 183
/
etcd.go
81 lines (69 loc) · 2.56 KB
/
etcd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// +build !windows
package etcd
import (
"github.com/signalfx/signalfx-agent/internal/monitors/collectd"
"github.com/signalfx/signalfx-agent/internal/core/config"
"github.com/signalfx/signalfx-agent/internal/monitors"
"github.com/signalfx/signalfx-agent/internal/monitors/collectd/python"
"github.com/signalfx/signalfx-agent/internal/monitors/pyrunner"
)
const monitorType = "collectd/etcd"
// MONITOR(collectd/etcd): Monitors an etcd key/value store.
//
// See https://github.com/signalfx/integrations/tree/master/collectd-etcd and
// https://github.com/signalfx/collectd-etcd
func init() {
monitors.Register(monitorType, func() interface{} {
return &Monitor{
python.PyMonitor{
MonitorCore: pyrunner.New("sfxcollectd"),
},
}
}, &Config{})
}
// Config is the monitor-specific config with the generic config embedded
type Config struct {
config.MonitorConfig `yaml:",inline" acceptsEndpoints:"true"`
pyConf *python.Config
Host string `yaml:"host" validate:"required"`
Port uint16 `yaml:"port" validate:"required"`
// An arbitrary name of the etcd cluster to make it easier to group
// together and identify instances.
ClusterName string `yaml:"clusterName" validate:"required"`
SSLKeyFile string `yaml:"sslKeyFile"`
SSLCertificate string `yaml:"sslCertificate"`
SSLCACerts string `yaml:"sslCACerts"`
SkipSSLValidation *bool `yaml:"skipSSLValidation"`
EnhancedMetrics *bool `yaml:"enhancedMetrics"`
}
// PythonConfig returns the embedded python.Config struct from the interface
func (c *Config) PythonConfig() *python.Config {
return c.pyConf
}
// Monitor is the main type that represents the monitor
type Monitor struct {
python.PyMonitor
}
// Configure configures and runs the plugin in collectd
func (m *Monitor) Configure(conf *Config) error {
conf.pyConf = &python.Config{
MonitorConfig: conf.MonitorConfig,
Host: conf.Host,
Port: conf.Port,
ModuleName: "etcd_plugin",
ModulePaths: []string{collectd.MakePath("etcd")},
TypesDBPaths: []string{collectd.MakePath("types.db")},
PluginConfig: map[string]interface{}{
"Host": conf.Host,
"Port": conf.Port,
"Interval": conf.IntervalSeconds,
"Cluster": conf.ClusterName,
"ssl_cert_validation": conf.SkipSSLValidation,
"EnhancedMetrics": conf.EnhancedMetrics,
"ssl_keyfile": conf.SSLKeyFile,
"ssl_certificate": conf.SSLCertificate,
"ssl_ca_certs": conf.SSLCACerts,
},
}
return m.PyMonitor.Configure(conf)
}