aboutsummaryrefslogtreecommitdiff
path: root/collector/cpu_freebsd.go
diff options
context:
space:
mode:
authorJohannes 'fish' Ziemke <github@freigeist.org>2016-12-28 15:21:31 +0100
committerJohannes 'fish' Ziemke <github@freigeist.org>2017-01-03 14:11:10 +0100
commit8e50b80d1285be8334066aca7a9f7ec26221f7c1 (patch)
tree71ca4eb02d97823134567ef8956c5b1e5124afde /collector/cpu_freebsd.go
parentc53bc168fe759d84ab8a031f2eae0777b221506d (diff)
downloadprometheus_node_collector-8e50b80d1285be8334066aca7a9f7ec26221f7c1.tar.bz2
prometheus_node_collector-8e50b80d1285be8334066aca7a9f7ec26221f7c1.tar.xz
prometheus_node_collector-8e50b80d1285be8334066aca7a9f7ec26221f7c1.zip
Convert remaining collectors to use ConstMetrics
Diffstat (limited to 'collector/cpu_freebsd.go')
-rw-r--r--collector/cpu_freebsd.go24
1 files changed, 10 insertions, 14 deletions
diff --git a/collector/cpu_freebsd.go b/collector/cpu_freebsd.go
index a5bc33f..f22b027 100644
--- a/collector/cpu_freebsd.go
+++ b/collector/cpu_freebsd.go
@@ -89,14 +89,11 @@ func init() {
89// CPU stats. 89// CPU stats.
90func NewStatCollector() (Collector, error) { 90func NewStatCollector() (Collector, error) {
91 return &statCollector{ 91 return &statCollector{
92 cpu: prometheus.NewCounterVec( 92 cpu: typedDesc{prometheus.NewDesc(
93 prometheus.CounterOpts{ 93 prometheus.BuildFQName(Namespace, "cpu", "seconds_total"),
94 Namespace: Namespace, 94 "Seconds the CPU spent in each mode.",
95 Name: "cpu_seconds_total", 95 []string{"cpu", "mode"}, nil,
96 Help: "Seconds the CPU spent in each mode.", 96 ), prometheus.CounterValue},
97 },
98 []string{"cpu", "mode"},
99 ),
100 }, nil 97 }, nil
101} 98}
102 99
@@ -118,12 +115,11 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) (err error) {
118 return err 115 return err
119 } 116 }
120 for cpu, t := range cpuTimes { 117 for cpu, t := range cpuTimes {
121 c.cpu.With(prometheus.Labels{"cpu": strconv.Itoa(cpu), "mode": "user"}).Set(t.user) 118 ch <- c.cpu.mustNewConstMetric(float64(cpuTimes[base_idx+C.CP_USER]), strconv.Itoa(cpu), "user")
122 c.cpu.With(prometheus.Labels{"cpu": strconv.Itoa(cpu), "mode": "nice"}).Set(t.nice) 119 ch <- c.cpu.mustNewConstMetric(float64(cpuTimes[base_idx+C.CP_NICE]), strconv.Itoa(cpu), "nice")
123 c.cpu.With(prometheus.Labels{"cpu": strconv.Itoa(cpu), "mode": "system"}).Set(t.sys) 120 ch <- c.cpu.mustNewConstMetric(float64(cpuTimes[base_idx+C.CP_SYS]), strconv.Itoa(cpu), "system")
124 c.cpu.With(prometheus.Labels{"cpu": strconv.Itoa(cpu), "mode": "interrupt"}).Set(t.intr) 121 ch <- c.cpu.mustNewConstMetric(float64(cpuTimes[base_idx+C.CP_INTR]), strconv.Itoa(cpu), "interrupt")
125 c.cpu.With(prometheus.Labels{"cpu": strconv.Itoa(cpu), "mode": "idle"}).Set(t.idle) 122 ch <- c.cpu.mustNewConstMetric(float64(cpuTimes[base_idx+C.CP_IDLE]), strconv.Itoa(cpu), "idle")
126 } 123 }
127 c.cpu.Collect(ch)
128 return err 124 return err
129} 125}