diff options
author | Johannes 'fish' Ziemke <github@freigeist.org> | 2016-12-28 15:21:31 +0100 |
---|---|---|
committer | Johannes 'fish' Ziemke <github@freigeist.org> | 2017-01-03 14:11:10 +0100 |
commit | 8e50b80d1285be8334066aca7a9f7ec26221f7c1 (patch) | |
tree | 71ca4eb02d97823134567ef8956c5b1e5124afde /collector/interrupts_openbsd.go | |
parent | c53bc168fe759d84ab8a031f2eae0777b221506d (diff) | |
download | prometheus_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/interrupts_openbsd.go')
-rw-r--r-- | collector/interrupts_openbsd.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/collector/interrupts_openbsd.go b/collector/interrupts_openbsd.go index 787bea8..c0fca98 100644 --- a/collector/interrupts_openbsd.go +++ b/collector/interrupts_openbsd.go | |||
@@ -98,23 +98,22 @@ var ( | |||
98 | interruptLabelNames = []string{"CPU", "type", "devices"} | 98 | interruptLabelNames = []string{"CPU", "type", "devices"} |
99 | ) | 99 | ) |
100 | 100 | ||
101 | func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) (err error) { | 101 | func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error { |
102 | interrupts, err := getInterrupts() | 102 | interrupts, err := getInterrupts() |
103 | if err != nil { | 103 | if err != nil { |
104 | return fmt.Errorf("couldn't get interrupts: %s", err) | 104 | return fmt.Errorf("couldn't get interrupts: %s", err) |
105 | } | 105 | } |
106 | for dev, interrupt := range interrupts { | 106 | for dev, interrupt := range interrupts { |
107 | for cpuNo, value := range interrupt.values { | 107 | for cpuNo, value := range interrupt.values { |
108 | labels := prometheus.Labels{ | 108 | ch <- c.desc.mustNewConstMetric( |
109 | "CPU": strconv.Itoa(cpuNo), | 109 | value, |
110 | "type": fmt.Sprintf("%d", interrupt.vector), | 110 | strconv.Itoa(cpuNo), |
111 | "devices": dev, | 111 | fmt.Sprintf("%d", interrupt.vector), |
112 | } | 112 | dev, |
113 | c.metric.With(labels).Set(value) | 113 | ) |
114 | } | 114 | } |
115 | } | 115 | } |
116 | c.metric.Collect(ch) | 116 | return nil |
117 | return err | ||
118 | } | 117 | } |
119 | 118 | ||
120 | type interrupt struct { | 119 | type interrupt struct { |