diff options
author | mknapphrt <39998367+mknapphrt@users.noreply.github.com> | 2019-02-04 10:54:41 -0500 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-02-04 16:54:41 +0100 |
commit | 7fbdd0ae93bc792d103b39ffcd5bb92b270f8e35 (patch) | |
tree | f77f62301d684e588ea9e6afe101e7a6a295577f /collector | |
parent | 7d150d578232f9fe4847035d0dd4b9ae9126d146 (diff) | |
download | prometheus_node_collector-7fbdd0ae93bc792d103b39ffcd5bb92b270f8e35.tar.bz2 prometheus_node_collector-7fbdd0ae93bc792d103b39ffcd5bb92b270f8e35.tar.xz prometheus_node_collector-7fbdd0ae93bc792d103b39ffcd5bb92b270f8e35.zip |
Update procfs vendor (#1248)
Signed-off-by: Mark Knapp <mknapp@hudson-trading.com>
Diffstat (limited to 'collector')
-rw-r--r-- | collector/cpu_linux.go | 84 | ||||
-rw-r--r-- | collector/fixtures/e2e-64k-page-output.txt | 36 | ||||
-rw-r--r-- | collector/fixtures/e2e-output.txt | 36 |
3 files changed, 102 insertions, 54 deletions
diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index 640873f..50d8a3b 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go | |||
@@ -32,6 +32,9 @@ type cpuCollector struct { | |||
32 | cpuFreq *prometheus.Desc | 32 | cpuFreq *prometheus.Desc |
33 | cpuFreqMin *prometheus.Desc | 33 | cpuFreqMin *prometheus.Desc |
34 | cpuFreqMax *prometheus.Desc | 34 | cpuFreqMax *prometheus.Desc |
35 | scalingFreq *prometheus.Desc | ||
36 | scalingFreqMin *prometheus.Desc | ||
37 | scalingFreqMax *prometheus.Desc | ||
35 | cpuCoreThrottle *prometheus.Desc | 38 | cpuCoreThrottle *prometheus.Desc |
36 | cpuPackageThrottle *prometheus.Desc | 39 | cpuPackageThrottle *prometheus.Desc |
37 | } | 40 | } |
@@ -64,6 +67,21 @@ func NewCPUCollector() (Collector, error) { | |||
64 | "Maximum cpu thread frequency in hertz.", | 67 | "Maximum cpu thread frequency in hertz.", |
65 | []string{"cpu"}, nil, | 68 | []string{"cpu"}, nil, |
66 | ), | 69 | ), |
70 | scalingFreq: prometheus.NewDesc( | ||
71 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_hertz"), | ||
72 | "Current scaled cpu thread frequency in hertz.", | ||
73 | []string{"cpu"}, nil, | ||
74 | ), | ||
75 | scalingFreqMin: prometheus.NewDesc( | ||
76 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_min_hrts"), | ||
77 | "Minimum scaled cpu thread frequency in hertz.", | ||
78 | []string{"cpu"}, nil, | ||
79 | ), | ||
80 | scalingFreqMax: prometheus.NewDesc( | ||
81 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "scaling_frequency_max_hrts"), | ||
82 | "Maximum scaled cpu thread frequency in hertz.", | ||
83 | []string{"cpu"}, nil, | ||
84 | ), | ||
67 | cpuCoreThrottle: prometheus.NewDesc( | 85 | cpuCoreThrottle: prometheus.NewDesc( |
68 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"), | 86 | prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"), |
69 | "Number of times this cpu core has been throttled.", | 87 | "Number of times this cpu core has been throttled.", |
@@ -106,24 +124,54 @@ func (c *cpuCollector) updateCPUfreq(ch chan<- prometheus.Metric) error { | |||
106 | // sysfs cpufreq values are kHz, thus multiply by 1000 to export base units (hz). | 124 | // sysfs cpufreq values are kHz, thus multiply by 1000 to export base units (hz). |
107 | // See https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt | 125 | // See https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt |
108 | for _, stats := range cpuFreqs { | 126 | for _, stats := range cpuFreqs { |
109 | ch <- prometheus.MustNewConstMetric( | 127 | if stats.CpuinfoCurrentFrequency != nil { |
110 | c.cpuFreq, | 128 | ch <- prometheus.MustNewConstMetric( |
111 | prometheus.GaugeValue, | 129 | c.cpuFreq, |
112 | float64(stats.CurrentFrequency)*1000.0, | 130 | prometheus.GaugeValue, |
113 | stats.Name, | 131 | float64(*stats.CpuinfoCurrentFrequency)*1000.0, |
114 | ) | 132 | stats.Name, |
115 | ch <- prometheus.MustNewConstMetric( | 133 | ) |
116 | c.cpuFreqMin, | 134 | } |
117 | prometheus.GaugeValue, | 135 | if stats.CpuinfoMinimumFrequency != nil { |
118 | float64(stats.MinimumFrequency)*1000.0, | 136 | ch <- prometheus.MustNewConstMetric( |
119 | stats.Name, | 137 | c.cpuFreqMin, |
120 | ) | 138 | prometheus.GaugeValue, |
121 | ch <- prometheus.MustNewConstMetric( | 139 | float64(*stats.CpuinfoMinimumFrequency)*1000.0, |
122 | c.cpuFreqMax, | 140 | stats.Name, |
123 | prometheus.GaugeValue, | 141 | ) |
124 | float64(stats.MaximumFrequency)*1000.0, | 142 | } |
125 | stats.Name, | 143 | if stats.CpuinfoMaximumFrequency != nil { |
126 | ) | 144 | ch <- prometheus.MustNewConstMetric( |
145 | c.cpuFreqMax, | ||
146 | prometheus.GaugeValue, | ||
147 | float64(*stats.CpuinfoMaximumFrequency)*1000.0, | ||
148 | stats.Name, | ||
149 | ) | ||
150 | } | ||
151 | if stats.ScalingCurrentFrequency != nil { | ||
152 | ch <- prometheus.MustNewConstMetric( | ||
153 | c.scalingFreq, | ||
154 | prometheus.GaugeValue, | ||
155 | float64(*stats.ScalingCurrentFrequency)*1000.0, | ||
156 | stats.Name, | ||
157 | ) | ||
158 | } | ||
159 | if stats.ScalingMinimumFrequency != nil { | ||
160 | ch <- prometheus.MustNewConstMetric( | ||
161 | c.scalingFreqMin, | ||
162 | prometheus.GaugeValue, | ||
163 | float64(*stats.ScalingMinimumFrequency)*1000.0, | ||
164 | stats.Name, | ||
165 | ) | ||
166 | } | ||
167 | if stats.ScalingMaximumFrequency != nil { | ||
168 | ch <- prometheus.MustNewConstMetric( | ||
169 | c.scalingFreqMax, | ||
170 | prometheus.GaugeValue, | ||
171 | float64(*stats.ScalingMaximumFrequency)*1000.0, | ||
172 | stats.Name, | ||
173 | ) | ||
174 | } | ||
127 | } | 175 | } |
128 | return nil | 176 | return nil |
129 | } | 177 | } |
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index feb6b37..7e61462 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt | |||
@@ -184,24 +184,6 @@ node_cpu_core_throttles_total{core="0",package="0"} 5 | |||
184 | node_cpu_core_throttles_total{core="0",package="1"} 0 | 184 | node_cpu_core_throttles_total{core="0",package="1"} 0 |
185 | node_cpu_core_throttles_total{core="1",package="0"} 0 | 185 | node_cpu_core_throttles_total{core="1",package="0"} 0 |
186 | node_cpu_core_throttles_total{core="1",package="1"} 9 | 186 | node_cpu_core_throttles_total{core="1",package="1"} 9 |
187 | # HELP node_cpu_frequency_hertz Current cpu thread frequency in hertz. | ||
188 | # TYPE node_cpu_frequency_hertz gauge | ||
189 | node_cpu_frequency_hertz{cpu="0"} 1.699981e+09 | ||
190 | node_cpu_frequency_hertz{cpu="1"} 1.699981e+09 | ||
191 | node_cpu_frequency_hertz{cpu="2"} 8e+06 | ||
192 | node_cpu_frequency_hertz{cpu="3"} 8e+06 | ||
193 | # HELP node_cpu_frequency_max_hertz Maximum cpu thread frequency in hertz. | ||
194 | # TYPE node_cpu_frequency_max_hertz gauge | ||
195 | node_cpu_frequency_max_hertz{cpu="0"} 3.7e+09 | ||
196 | node_cpu_frequency_max_hertz{cpu="1"} 3.7e+09 | ||
197 | node_cpu_frequency_max_hertz{cpu="2"} 4.2e+09 | ||
198 | node_cpu_frequency_max_hertz{cpu="3"} 4.2e+09 | ||
199 | # HELP node_cpu_frequency_min_hertz Minimum cpu thread frequency in hertz. | ||
200 | # TYPE node_cpu_frequency_min_hertz gauge | ||
201 | node_cpu_frequency_min_hertz{cpu="0"} 8e+08 | ||
202 | node_cpu_frequency_min_hertz{cpu="1"} 8e+08 | ||
203 | node_cpu_frequency_min_hertz{cpu="2"} 1e+06 | ||
204 | node_cpu_frequency_min_hertz{cpu="3"} 1e+06 | ||
205 | # HELP node_cpu_guest_seconds_total Seconds the cpus spent in guests (VMs) for each mode. | 187 | # HELP node_cpu_guest_seconds_total Seconds the cpus spent in guests (VMs) for each mode. |
206 | # TYPE node_cpu_guest_seconds_total counter | 188 | # TYPE node_cpu_guest_seconds_total counter |
207 | node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0.01 | 189 | node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0.01 |
@@ -224,6 +206,24 @@ node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09 | |||
224 | # TYPE node_cpu_package_throttles_total counter | 206 | # TYPE node_cpu_package_throttles_total counter |
225 | node_cpu_package_throttles_total{package="0"} 30 | 207 | node_cpu_package_throttles_total{package="0"} 30 |
226 | node_cpu_package_throttles_total{package="1"} 6 | 208 | node_cpu_package_throttles_total{package="1"} 6 |
209 | # HELP node_cpu_scaling_frequency_hertz Current scaled cpu thread frequency in hertz. | ||
210 | # TYPE node_cpu_scaling_frequency_hertz gauge | ||
211 | node_cpu_scaling_frequency_hertz{cpu="0"} 1.699981e+09 | ||
212 | node_cpu_scaling_frequency_hertz{cpu="1"} 1.699981e+09 | ||
213 | node_cpu_scaling_frequency_hertz{cpu="2"} 8e+06 | ||
214 | node_cpu_scaling_frequency_hertz{cpu="3"} 8e+06 | ||
215 | # HELP node_cpu_scaling_frequency_max_hrts Maximum scaled cpu thread frequency in hertz. | ||
216 | # TYPE node_cpu_scaling_frequency_max_hrts gauge | ||
217 | node_cpu_scaling_frequency_max_hrts{cpu="0"} 3.7e+09 | ||
218 | node_cpu_scaling_frequency_max_hrts{cpu="1"} 3.7e+09 | ||
219 | node_cpu_scaling_frequency_max_hrts{cpu="2"} 4.2e+09 | ||
220 | node_cpu_scaling_frequency_max_hrts{cpu="3"} 4.2e+09 | ||
221 | # HELP node_cpu_scaling_frequency_min_hrts Minimum scaled cpu thread frequency in hertz. | ||
222 | # TYPE node_cpu_scaling_frequency_min_hrts gauge | ||
223 | node_cpu_scaling_frequency_min_hrts{cpu="0"} 8e+08 | ||
224 | node_cpu_scaling_frequency_min_hrts{cpu="1"} 8e+08 | ||
225 | node_cpu_scaling_frequency_min_hrts{cpu="2"} 1e+06 | ||
226 | node_cpu_scaling_frequency_min_hrts{cpu="3"} 1e+06 | ||
227 | # HELP node_cpu_seconds_total Seconds the cpus spent in each mode. | 227 | # HELP node_cpu_seconds_total Seconds the cpus spent in each mode. |
228 | # TYPE node_cpu_seconds_total counter | 228 | # TYPE node_cpu_seconds_total counter |
229 | node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69 | 229 | node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69 |
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 588a587..ba11e23 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt | |||
@@ -184,24 +184,6 @@ node_cpu_core_throttles_total{core="0",package="0"} 5 | |||
184 | node_cpu_core_throttles_total{core="0",package="1"} 0 | 184 | node_cpu_core_throttles_total{core="0",package="1"} 0 |
185 | node_cpu_core_throttles_total{core="1",package="0"} 0 | 185 | node_cpu_core_throttles_total{core="1",package="0"} 0 |
186 | node_cpu_core_throttles_total{core="1",package="1"} 9 | 186 | node_cpu_core_throttles_total{core="1",package="1"} 9 |
187 | # HELP node_cpu_frequency_hertz Current cpu thread frequency in hertz. | ||
188 | # TYPE node_cpu_frequency_hertz gauge | ||
189 | node_cpu_frequency_hertz{cpu="0"} 1.699981e+09 | ||
190 | node_cpu_frequency_hertz{cpu="1"} 1.699981e+09 | ||
191 | node_cpu_frequency_hertz{cpu="2"} 8e+06 | ||
192 | node_cpu_frequency_hertz{cpu="3"} 8e+06 | ||
193 | # HELP node_cpu_frequency_max_hertz Maximum cpu thread frequency in hertz. | ||
194 | # TYPE node_cpu_frequency_max_hertz gauge | ||
195 | node_cpu_frequency_max_hertz{cpu="0"} 3.7e+09 | ||
196 | node_cpu_frequency_max_hertz{cpu="1"} 3.7e+09 | ||
197 | node_cpu_frequency_max_hertz{cpu="2"} 4.2e+09 | ||
198 | node_cpu_frequency_max_hertz{cpu="3"} 4.2e+09 | ||
199 | # HELP node_cpu_frequency_min_hertz Minimum cpu thread frequency in hertz. | ||
200 | # TYPE node_cpu_frequency_min_hertz gauge | ||
201 | node_cpu_frequency_min_hertz{cpu="0"} 8e+08 | ||
202 | node_cpu_frequency_min_hertz{cpu="1"} 8e+08 | ||
203 | node_cpu_frequency_min_hertz{cpu="2"} 1e+06 | ||
204 | node_cpu_frequency_min_hertz{cpu="3"} 1e+06 | ||
205 | # HELP node_cpu_guest_seconds_total Seconds the cpus spent in guests (VMs) for each mode. | 187 | # HELP node_cpu_guest_seconds_total Seconds the cpus spent in guests (VMs) for each mode. |
206 | # TYPE node_cpu_guest_seconds_total counter | 188 | # TYPE node_cpu_guest_seconds_total counter |
207 | node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0.01 | 189 | node_cpu_guest_seconds_total{cpu="0",mode="nice"} 0.01 |
@@ -224,6 +206,24 @@ node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09 | |||
224 | # TYPE node_cpu_package_throttles_total counter | 206 | # TYPE node_cpu_package_throttles_total counter |
225 | node_cpu_package_throttles_total{package="0"} 30 | 207 | node_cpu_package_throttles_total{package="0"} 30 |
226 | node_cpu_package_throttles_total{package="1"} 6 | 208 | node_cpu_package_throttles_total{package="1"} 6 |
209 | # HELP node_cpu_scaling_frequency_hertz Current scaled cpu thread frequency in hertz. | ||
210 | # TYPE node_cpu_scaling_frequency_hertz gauge | ||
211 | node_cpu_scaling_frequency_hertz{cpu="0"} 1.699981e+09 | ||
212 | node_cpu_scaling_frequency_hertz{cpu="1"} 1.699981e+09 | ||
213 | node_cpu_scaling_frequency_hertz{cpu="2"} 8e+06 | ||
214 | node_cpu_scaling_frequency_hertz{cpu="3"} 8e+06 | ||
215 | # HELP node_cpu_scaling_frequency_max_hrts Maximum scaled cpu thread frequency in hertz. | ||
216 | # TYPE node_cpu_scaling_frequency_max_hrts gauge | ||
217 | node_cpu_scaling_frequency_max_hrts{cpu="0"} 3.7e+09 | ||
218 | node_cpu_scaling_frequency_max_hrts{cpu="1"} 3.7e+09 | ||
219 | node_cpu_scaling_frequency_max_hrts{cpu="2"} 4.2e+09 | ||
220 | node_cpu_scaling_frequency_max_hrts{cpu="3"} 4.2e+09 | ||
221 | # HELP node_cpu_scaling_frequency_min_hrts Minimum scaled cpu thread frequency in hertz. | ||
222 | # TYPE node_cpu_scaling_frequency_min_hrts gauge | ||
223 | node_cpu_scaling_frequency_min_hrts{cpu="0"} 8e+08 | ||
224 | node_cpu_scaling_frequency_min_hrts{cpu="1"} 8e+08 | ||
225 | node_cpu_scaling_frequency_min_hrts{cpu="2"} 1e+06 | ||
226 | node_cpu_scaling_frequency_min_hrts{cpu="3"} 1e+06 | ||
227 | # HELP node_cpu_seconds_total Seconds the cpus spent in each mode. | 227 | # HELP node_cpu_seconds_total Seconds the cpus spent in each mode. |
228 | # TYPE node_cpu_seconds_total counter | 228 | # TYPE node_cpu_seconds_total counter |
229 | node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69 | 229 | node_cpu_seconds_total{cpu="0",mode="idle"} 10870.69 |