-
Notifications
You must be signed in to change notification settings - Fork 183
/
cpu.go
47 lines (37 loc) · 1.33 KB
/
cpu.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
// +build linux
package cpu
//go:generate collectd-template-to-go cpu.tmpl
import (
"github.com/signalfx/signalfx-agent/internal/core/config"
"github.com/signalfx/signalfx-agent/internal/monitors"
"github.com/signalfx/signalfx-agent/internal/monitors/collectd"
)
const monitorType = "collectd/cpu"
// MONITOR(collectd/cpu): This monitor collects cpu usage data using the
// collectd `cpu` plugin. It aggregates the per-core CPU data into a single
// metric and sends it to the SignalFx Metadata plugin in collectd, where the
// raw jiffy counts from the `cpu` plugin are converted to percent utilization
// (the `cpu.utilization` metric).
//
// See https://collectd.org/wiki/index.php/Plugin:CPU
// GAUGE(cpu.utilization): Percentage of total CPU used within the last metric
// interval cycle.
func init() {
monitors.Register(monitorType, func() interface{} {
return &Monitor{
MonitorCore: *collectd.NewMonitorCore(CollectdTemplate),
}
}, &Config{})
}
// Config is the monitor-specific config with the generic config embedded
type Config struct {
config.MonitorConfig `singleInstance:"true"`
}
// Monitor is the main type that represents the monitor
type Monitor struct {
collectd.MonitorCore
}
// Configure configures and runs the plugin in collectd
func (m *Monitor) Configure(conf *Config) error {
return m.SetConfigurationAndRun(conf)
}