@cryptotaxi247 / netdata-1 / commits / 5567a24b5

fix(nvme)!: query controller instead of namespace for SMART metrics (#20704)

Ilya Mashchenko committed Jul 19, 2025 at 21:56 UTC 5567a24b5d6c5385282522b54c71e6547a0e34e1
2 files changed +256 -226
src/go/plugin/go.d/collector/nvme/collect.go
+31 -1
@@ -9,7 +9,9 @@ import (
9 "fmt"
10 "path/filepath"
11 "strconv"
12 + "strings"
13 "time"
14 + "unicode"
15
16 "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/metrix"
17 )
@@ -90,13 +92,18 @@ func (c *Collector) listNVMeDevices() error {
92 seen := make(map[string]bool)
93
94 for _, dev := range devList.Devices {
93 - path := dev.DevicePath
95 + path := extractControllerPathFromDevicePath(dev.DevicePath)
96 + if path == "" {
97 + continue
98 + }
99 +
100 seen[path] = true
101 if !c.devicePaths[path] {
102 c.devicePaths[path] = true
103 c.addDeviceCharts(path, dev.ModelNumber)
104 }
105 }
106 +
107 for path := range c.devicePaths {
108 if !seen[path] {
109 delete(c.devicePaths, path)
@@ -107,6 +114,29 @@ func (c *Collector) listNVMeDevices() error {
114 return nil
115 }
116
117 +func extractControllerPathFromDevicePath(devicePath string) string {
118 + if !strings.Contains(devicePath, "nvme") {
119 + return ""
120 + }
121 +
122 + // "/dev/nvme0n1" -> "/dev/nvme0"
123 + // "/dev/nvme10n1" -> "/dev/nvme10"
124 +
125 + // Find where "nX" (namespace part) starts
126 + idx := strings.LastIndex(devicePath, "n")
127 + if idx <= 0 || idx+1 >= len(devicePath) {
128 + return devicePath
129 + }
130 +
131 + // Check if character before and after 'n' is a digit (indicating namespace)
132 + before, after := devicePath[idx-1], devicePath[idx+1]
133 + if !unicode.IsDigit(rune(before)) || !unicode.IsDigit(rune(after)) {
134 + return devicePath
135 + }
136 +
137 + return devicePath[:idx]
138 +}
139 +
140 func extractDeviceFromPath(devicePath string) string {
141 _, name := filepath.Split(devicePath)
142 return name
src/go/plugin/go.d/collector/nvme/collector_test.go
+225 -225
@@ -137,81 +137,81 @@ func TestCollector_Collect(t *testing.T) {
137 mx := collr.Collect(context.Background())
138
139 expected := map[string]int64{
140 - "device_nvme0n1_available_spare": 100,
141 - "device_nvme0n1_controller_busy_time": 4172940,
142 - "device_nvme0n1_critical_comp_time": 0,
143 - "device_nvme0n1_critical_warning_available_spare": 0,
144 - "device_nvme0n1_critical_warning_nvm_subsystem_reliability": 0,
145 - "device_nvme0n1_critical_warning_persistent_memory_read_only": 0,
146 - "device_nvme0n1_critical_warning_read_only": 0,
147 - "device_nvme0n1_critical_warning_temp_threshold": 0,
148 - "device_nvme0n1_critical_warning_volatile_mem_backup_failed": 0,
149 - "device_nvme0n1_data_units_read": 91155062272000,
150 - "device_nvme0n1_data_units_written": 987485941760000,
151 - "device_nvme0n1_host_read_commands": 5808178366,
152 - "device_nvme0n1_host_write_commands": 24273507789,
153 - "device_nvme0n1_media_errors": 0,
154 - "device_nvme0n1_num_err_log_entries": 212,
155 - "device_nvme0n1_percentage_used": 30,
156 - "device_nvme0n1_power_cycles": 99,
157 - "device_nvme0n1_power_on_time": 87926400,
158 - "device_nvme0n1_temperature": 50,
159 - "device_nvme0n1_thm_temp1_total_time": 1474,
160 - "device_nvme0n1_thm_temp1_trans_count": 3,
161 - "device_nvme0n1_thm_temp2_total_time": 0,
162 - "device_nvme0n1_thm_temp2_trans_count": 0,
163 - "device_nvme0n1_unsafe_shutdowns": 49,
164 - "device_nvme0n1_warning_temp_time": 0,
165 - "device_nvme1n1_available_spare": 100,
166 - "device_nvme1n1_controller_busy_time": 4172940,
167 - "device_nvme1n1_critical_comp_time": 0,
168 - "device_nvme1n1_critical_warning_available_spare": 0,
169 - "device_nvme1n1_critical_warning_nvm_subsystem_reliability": 0,
170 - "device_nvme1n1_critical_warning_persistent_memory_read_only": 0,
171 - "device_nvme1n1_critical_warning_read_only": 0,
172 - "device_nvme1n1_critical_warning_temp_threshold": 0,
173 - "device_nvme1n1_critical_warning_volatile_mem_backup_failed": 0,
174 - "device_nvme1n1_data_units_read": 91155062272000,
175 - "device_nvme1n1_data_units_written": 987485941760000,
176 - "device_nvme1n1_host_read_commands": 5808178366,
177 - "device_nvme1n1_host_write_commands": 24273507789,
178 - "device_nvme1n1_media_errors": 0,
179 - "device_nvme1n1_num_err_log_entries": 212,
180 - "device_nvme1n1_percentage_used": 30,
181 - "device_nvme1n1_power_cycles": 99,
182 - "device_nvme1n1_power_on_time": 87926400,
183 - "device_nvme1n1_temperature": 50,
184 - "device_nvme1n1_thm_temp1_total_time": 1474,
185 - "device_nvme1n1_thm_temp1_trans_count": 3,
186 - "device_nvme1n1_thm_temp2_total_time": 0,
187 - "device_nvme1n1_thm_temp2_trans_count": 0,
188 - "device_nvme1n1_unsafe_shutdowns": 49,
189 - "device_nvme1n1_warning_temp_time": 0,
190 - "device_nvme2n1_available_spare": 100,
191 - "device_nvme2n1_controller_busy_time": 4172940,
192 - "device_nvme2n1_critical_comp_time": 0,
193 - "device_nvme2n1_critical_warning_available_spare": 0,
194 - "device_nvme2n1_critical_warning_nvm_subsystem_reliability": 0,
195 - "device_nvme2n1_critical_warning_persistent_memory_read_only": 0,
196 - "device_nvme2n1_critical_warning_read_only": 0,
197 - "device_nvme2n1_critical_warning_temp_threshold": 0,
198 - "device_nvme2n1_critical_warning_volatile_mem_backup_failed": 0,
199 - "device_nvme2n1_data_units_read": 91155062272000,
200 - "device_nvme2n1_data_units_written": 987485941760000,
201 - "device_nvme2n1_host_read_commands": 5808178366,
202 - "device_nvme2n1_host_write_commands": 24273507789,
203 - "device_nvme2n1_media_errors": 0,
204 - "device_nvme2n1_num_err_log_entries": 212,
205 - "device_nvme2n1_percentage_used": 30,
206 - "device_nvme2n1_power_cycles": 99,
207 - "device_nvme2n1_power_on_time": 87926400,
208 - "device_nvme2n1_temperature": 50,
209 - "device_nvme2n1_thm_temp1_total_time": 1474,
210 - "device_nvme2n1_thm_temp1_trans_count": 3,
211 - "device_nvme2n1_thm_temp2_total_time": 0,
212 - "device_nvme2n1_thm_temp2_trans_count": 0,
213 - "device_nvme2n1_unsafe_shutdowns": 49,
214 - "device_nvme2n1_warning_temp_time": 0,
140 + "device_nvme0_available_spare": 100,
141 + "device_nvme0_controller_busy_time": 4172940,
142 + "device_nvme0_critical_comp_time": 0,
143 + "device_nvme0_critical_warning_available_spare": 0,
144 + "device_nvme0_critical_warning_nvm_subsystem_reliability": 0,
145 + "device_nvme0_critical_warning_persistent_memory_read_only": 0,
146 + "device_nvme0_critical_warning_read_only": 0,
147 + "device_nvme0_critical_warning_temp_threshold": 0,
148 + "device_nvme0_critical_warning_volatile_mem_backup_failed": 0,
149 + "device_nvme0_data_units_read": 91155062272000,
150 + "device_nvme0_data_units_written": 987485941760000,
151 + "device_nvme0_host_read_commands": 5808178366,
152 + "device_nvme0_host_write_commands": 24273507789,
153 + "device_nvme0_media_errors": 0,
154 + "device_nvme0_num_err_log_entries": 212,
155 + "device_nvme0_percentage_used": 30,
156 + "device_nvme0_power_cycles": 99,
157 + "device_nvme0_power_on_time": 87926400,
158 + "device_nvme0_temperature": 50,
159 + "device_nvme0_thm_temp1_total_time": 1474,
160 + "device_nvme0_thm_temp1_trans_count": 3,
161 + "device_nvme0_thm_temp2_total_time": 0,
162 + "device_nvme0_thm_temp2_trans_count": 0,
163 + "device_nvme0_unsafe_shutdowns": 49,
164 + "device_nvme0_warning_temp_time": 0,
165 + "device_nvme1_available_spare": 100,
166 + "device_nvme1_controller_busy_time": 4172940,
167 + "device_nvme1_critical_comp_time": 0,
168 + "device_nvme1_critical_warning_available_spare": 0,
169 + "device_nvme1_critical_warning_nvm_subsystem_reliability": 0,
170 + "device_nvme1_critical_warning_persistent_memory_read_only": 0,
171 + "device_nvme1_critical_warning_read_only": 0,
172 + "device_nvme1_critical_warning_temp_threshold": 0,
173 + "device_nvme1_critical_warning_volatile_mem_backup_failed": 0,
174 + "device_nvme1_data_units_read": 91155062272000,
175 + "device_nvme1_data_units_written": 987485941760000,
176 + "device_nvme1_host_read_commands": 5808178366,
177 + "device_nvme1_host_write_commands": 24273507789,
178 + "device_nvme1_media_errors": 0,
179 + "device_nvme1_num_err_log_entries": 212,
180 + "device_nvme1_percentage_used": 30,
181 + "device_nvme1_power_cycles": 99,
182 + "device_nvme1_power_on_time": 87926400,
183 + "device_nvme1_temperature": 50,
184 + "device_nvme1_thm_temp1_total_time": 1474,
185 + "device_nvme1_thm_temp1_trans_count": 3,
186 + "device_nvme1_thm_temp2_total_time": 0,
187 + "device_nvme1_thm_temp2_trans_count": 0,
188 + "device_nvme1_unsafe_shutdowns": 49,
189 + "device_nvme1_warning_temp_time": 0,
190 + "device_nvme2_available_spare": 100,
191 + "device_nvme2_controller_busy_time": 4172940,
192 + "device_nvme2_critical_comp_time": 0,
193 + "device_nvme2_critical_warning_available_spare": 0,
194 + "device_nvme2_critical_warning_nvm_subsystem_reliability": 0,
195 + "device_nvme2_critical_warning_persistent_memory_read_only": 0,
196 + "device_nvme2_critical_warning_read_only": 0,
197 + "device_nvme2_critical_warning_temp_threshold": 0,
198 + "device_nvme2_critical_warning_volatile_mem_backup_failed": 0,
199 + "device_nvme2_data_units_read": 91155062272000,
200 + "device_nvme2_data_units_written": 987485941760000,
201 + "device_nvme2_host_read_commands": 5808178366,
202 + "device_nvme2_host_write_commands": 24273507789,
203 + "device_nvme2_media_errors": 0,
204 + "device_nvme2_num_err_log_entries": 212,
205 + "device_nvme2_percentage_used": 30,
206 + "device_nvme2_power_cycles": 99,
207 + "device_nvme2_power_on_time": 87926400,
208 + "device_nvme2_temperature": 50,
209 + "device_nvme2_thm_temp1_total_time": 1474,
210 + "device_nvme2_thm_temp1_trans_count": 3,
211 + "device_nvme2_thm_temp2_total_time": 0,
212 + "device_nvme2_thm_temp2_trans_count": 0,
213 + "device_nvme2_unsafe_shutdowns": 49,
214 + "device_nvme2_warning_temp_time": 0,
215 }
216
217 assert.Equal(t, expected, mx)
@@ -225,56 +225,56 @@ func TestCollector_Collect(t *testing.T) {
225 mx := collr.Collect(context.Background())
226
227 expected := map[string]int64{
228 - "device_nvme0n1_available_spare": 100,
229 - "device_nvme0n1_controller_busy_time": 497040,
230 - "device_nvme0n1_critical_comp_time": 0,
231 - "device_nvme0n1_critical_warning_available_spare": 0,
232 - "device_nvme0n1_critical_warning_nvm_subsystem_reliability": 0,
233 - "device_nvme0n1_critical_warning_persistent_memory_read_only": 0,
234 - "device_nvme0n1_critical_warning_read_only": 0,
235 - "device_nvme0n1_critical_warning_temp_threshold": 0,
236 - "device_nvme0n1_critical_warning_volatile_mem_backup_failed": 0,
237 - "device_nvme0n1_data_units_read": 5068041216000,
238 - "device_nvme0n1_data_units_written": 69712734208000,
239 - "device_nvme0n1_host_read_commands": 313528805,
240 - "device_nvme0n1_host_write_commands": 1928062610,
241 - "device_nvme0n1_media_errors": 0,
242 - "device_nvme0n1_num_err_log_entries": 110,
243 - "device_nvme0n1_percentage_used": 2,
244 - "device_nvme0n1_power_cycles": 64,
245 - "device_nvme0n1_power_on_time": 17906400,
246 - "device_nvme0n1_temperature": 36,
247 - "device_nvme0n1_thm_temp1_total_time": 0,
248 - "device_nvme0n1_thm_temp1_trans_count": 0,
249 - "device_nvme0n1_thm_temp2_total_time": 0,
250 - "device_nvme0n1_thm_temp2_trans_count": 0,
251 - "device_nvme0n1_unsafe_shutdowns": 39,
252 - "device_nvme0n1_warning_temp_time": 0,
253 - "device_nvme1n1_available_spare": 100,
254 - "device_nvme1n1_controller_busy_time": 497040,
255 - "device_nvme1n1_critical_comp_time": 0,
256 - "device_nvme1n1_critical_warning_available_spare": 0,
257 - "device_nvme1n1_critical_warning_nvm_subsystem_reliability": 0,
258 - "device_nvme1n1_critical_warning_persistent_memory_read_only": 0,
259 - "device_nvme1n1_critical_warning_read_only": 0,
260 - "device_nvme1n1_critical_warning_temp_threshold": 0,
261 - "device_nvme1n1_critical_warning_volatile_mem_backup_failed": 0,
262 - "device_nvme1n1_data_units_read": 5068041216000,
263 - "device_nvme1n1_data_units_written": 69712734208000,
264 - "device_nvme1n1_host_read_commands": 313528805,
265 - "device_nvme1n1_host_write_commands": 1928062610,
266 - "device_nvme1n1_media_errors": 0,
267 - "device_nvme1n1_num_err_log_entries": 110,
268 - "device_nvme1n1_percentage_used": 2,
269 - "device_nvme1n1_power_cycles": 64,
270 - "device_nvme1n1_power_on_time": 17906400,
271 - "device_nvme1n1_temperature": 36,
272 - "device_nvme1n1_thm_temp1_total_time": 0,
273 - "device_nvme1n1_thm_temp1_trans_count": 0,
274 - "device_nvme1n1_thm_temp2_total_time": 0,
275 - "device_nvme1n1_thm_temp2_trans_count": 0,
276 - "device_nvme1n1_unsafe_shutdowns": 39,
277 - "device_nvme1n1_warning_temp_time": 0,
228 + "device_nvme0_available_spare": 100,
229 + "device_nvme0_controller_busy_time": 497040,
230 + "device_nvme0_critical_comp_time": 0,
231 + "device_nvme0_critical_warning_available_spare": 0,
232 + "device_nvme0_critical_warning_nvm_subsystem_reliability": 0,
233 + "device_nvme0_critical_warning_persistent_memory_read_only": 0,
234 + "device_nvme0_critical_warning_read_only": 0,
235 + "device_nvme0_critical_warning_temp_threshold": 0,
236 + "device_nvme0_critical_warning_volatile_mem_backup_failed": 0,
237 + "device_nvme0_data_units_read": 5068041216000,
238 + "device_nvme0_data_units_written": 69712734208000,
239 + "device_nvme0_host_read_commands": 313528805,
240 + "device_nvme0_host_write_commands": 1928062610,
241 + "device_nvme0_media_errors": 0,
242 + "device_nvme0_num_err_log_entries": 110,
243 + "device_nvme0_percentage_used": 2,
244 + "device_nvme0_power_cycles": 64,
245 + "device_nvme0_power_on_time": 17906400,
246 + "device_nvme0_temperature": 36,
247 + "device_nvme0_thm_temp1_total_time": 0,
248 + "device_nvme0_thm_temp1_trans_count": 0,
249 + "device_nvme0_thm_temp2_total_time": 0,
250 + "device_nvme0_thm_temp2_trans_count": 0,
251 + "device_nvme0_unsafe_shutdowns": 39,
252 + "device_nvme0_warning_temp_time": 0,
253 + "device_nvme1_available_spare": 100,
254 + "device_nvme1_controller_busy_time": 497040,
255 + "device_nvme1_critical_comp_time": 0,
256 + "device_nvme1_critical_warning_available_spare": 0,
257 + "device_nvme1_critical_warning_nvm_subsystem_reliability": 0,
258 + "device_nvme1_critical_warning_persistent_memory_read_only": 0,
259 + "device_nvme1_critical_warning_read_only": 0,
260 + "device_nvme1_critical_warning_temp_threshold": 0,
261 + "device_nvme1_critical_warning_volatile_mem_backup_failed": 0,
262 + "device_nvme1_data_units_read": 5068041216000,
263 + "device_nvme1_data_units_written": 69712734208000,
264 + "device_nvme1_host_read_commands": 313528805,
265 + "device_nvme1_host_write_commands": 1928062610,
266 + "device_nvme1_media_errors": 0,
267 + "device_nvme1_num_err_log_entries": 110,
268 + "device_nvme1_percentage_used": 2,
269 + "device_nvme1_power_cycles": 64,
270 + "device_nvme1_power_on_time": 17906400,
271 + "device_nvme1_temperature": 36,
272 + "device_nvme1_thm_temp1_total_time": 0,
273 + "device_nvme1_thm_temp1_trans_count": 0,
274 + "device_nvme1_thm_temp2_total_time": 0,
275 + "device_nvme1_thm_temp2_trans_count": 0,
276 + "device_nvme1_unsafe_shutdowns": 39,
277 + "device_nvme1_warning_temp_time": 0,
278 }
279
280 assert.Equal(t, expected, mx)
@@ -288,56 +288,56 @@ func TestCollector_Collect(t *testing.T) {
288 mx := collr.Collect(context.Background())
289
290 expected := map[string]int64{
291 - "device_nvme0n1_available_spare": 100,
292 - "device_nvme0n1_controller_busy_time": 497040,
293 - "device_nvme0n1_critical_comp_time": 0,
294 - "device_nvme0n1_critical_warning_available_spare": 0,
295 - "device_nvme0n1_critical_warning_nvm_subsystem_reliability": 0,
296 - "device_nvme0n1_critical_warning_persistent_memory_read_only": 0,
297 - "device_nvme0n1_critical_warning_read_only": 0,
298 - "device_nvme0n1_critical_warning_temp_threshold": 0,
299 - "device_nvme0n1_critical_warning_volatile_mem_backup_failed": 0,
300 - "device_nvme0n1_data_units_read": 5068041216000,
301 - "device_nvme0n1_data_units_written": 69712734208000,
302 - "device_nvme0n1_host_read_commands": 313528805,
303 - "device_nvme0n1_host_write_commands": 1928062610,
304 - "device_nvme0n1_media_errors": 0,
305 - "device_nvme0n1_num_err_log_entries": 110,
306 - "device_nvme0n1_percentage_used": 2,
307 - "device_nvme0n1_power_cycles": 64,
308 - "device_nvme0n1_power_on_time": 17906400,
309 - "device_nvme0n1_temperature": 36,
310 - "device_nvme0n1_thm_temp1_total_time": 0,
311 - "device_nvme0n1_thm_temp1_trans_count": 0,
312 - "device_nvme0n1_thm_temp2_total_time": 0,
313 - "device_nvme0n1_thm_temp2_trans_count": 0,
314 - "device_nvme0n1_unsafe_shutdowns": 39,
315 - "device_nvme0n1_warning_temp_time": 0,
316 - "device_nvme1n1_available_spare": 100,
317 - "device_nvme1n1_controller_busy_time": 497040,
318 - "device_nvme1n1_critical_comp_time": 0,
319 - "device_nvme1n1_critical_warning_available_spare": 0,
320 - "device_nvme1n1_critical_warning_nvm_subsystem_reliability": 0,
321 - "device_nvme1n1_critical_warning_persistent_memory_read_only": 0,
322 - "device_nvme1n1_critical_warning_read_only": 0,
323 - "device_nvme1n1_critical_warning_temp_threshold": 0,
324 - "device_nvme1n1_critical_warning_volatile_mem_backup_failed": 0,
325 - "device_nvme1n1_data_units_read": 5068041216000,
326 - "device_nvme1n1_data_units_written": 69712734208000,
327 - "device_nvme1n1_host_read_commands": 313528805,
328 - "device_nvme1n1_host_write_commands": 1928062610,
329 - "device_nvme1n1_media_errors": 0,
330 - "device_nvme1n1_num_err_log_entries": 110,
331 - "device_nvme1n1_percentage_used": 2,
332 - "device_nvme1n1_power_cycles": 64,
333 - "device_nvme1n1_power_on_time": 17906400,
334 - "device_nvme1n1_temperature": 36,
335 - "device_nvme1n1_thm_temp1_total_time": 0,
336 - "device_nvme1n1_thm_temp1_trans_count": 0,
337 - "device_nvme1n1_thm_temp2_total_time": 0,
338 - "device_nvme1n1_thm_temp2_trans_count": 0,
339 - "device_nvme1n1_unsafe_shutdowns": 39,
340 - "device_nvme1n1_warning_temp_time": 0,
291 + "device_nvme0_available_spare": 100,
292 + "device_nvme0_controller_busy_time": 497040,
293 + "device_nvme0_critical_comp_time": 0,
294 + "device_nvme0_critical_warning_available_spare": 0,
295 + "device_nvme0_critical_warning_nvm_subsystem_reliability": 0,
296 + "device_nvme0_critical_warning_persistent_memory_read_only": 0,
297 + "device_nvme0_critical_warning_read_only": 0,
298 + "device_nvme0_critical_warning_temp_threshold": 0,
299 + "device_nvme0_critical_warning_volatile_mem_backup_failed": 0,
300 + "device_nvme0_data_units_read": 5068041216000,
301 + "device_nvme0_data_units_written": 69712734208000,
302 + "device_nvme0_host_read_commands": 313528805,
303 + "device_nvme0_host_write_commands": 1928062610,
304 + "device_nvme0_media_errors": 0,
305 + "device_nvme0_num_err_log_entries": 110,
306 + "device_nvme0_percentage_used": 2,
307 + "device_nvme0_power_cycles": 64,
308 + "device_nvme0_power_on_time": 17906400,
309 + "device_nvme0_temperature": 36,
310 + "device_nvme0_thm_temp1_total_time": 0,
311 + "device_nvme0_thm_temp1_trans_count": 0,
312 + "device_nvme0_thm_temp2_total_time": 0,
313 + "device_nvme0_thm_temp2_trans_count": 0,
314 + "device_nvme0_unsafe_shutdowns": 39,
315 + "device_nvme0_warning_temp_time": 0,
316 + "device_nvme1_available_spare": 100,
317 + "device_nvme1_controller_busy_time": 497040,
318 + "device_nvme1_critical_comp_time": 0,
319 + "device_nvme1_critical_warning_available_spare": 0,
320 + "device_nvme1_critical_warning_nvm_subsystem_reliability": 0,
321 + "device_nvme1_critical_warning_persistent_memory_read_only": 0,
322 + "device_nvme1_critical_warning_read_only": 0,
323 + "device_nvme1_critical_warning_temp_threshold": 0,
324 + "device_nvme1_critical_warning_volatile_mem_backup_failed": 0,
325 + "device_nvme1_data_units_read": 5068041216000,
326 + "device_nvme1_data_units_written": 69712734208000,
327 + "device_nvme1_host_read_commands": 313528805,
328 + "device_nvme1_host_write_commands": 1928062610,
329 + "device_nvme1_media_errors": 0,
330 + "device_nvme1_num_err_log_entries": 110,
331 + "device_nvme1_percentage_used": 2,
332 + "device_nvme1_power_cycles": 64,
333 + "device_nvme1_power_on_time": 17906400,
334 + "device_nvme1_temperature": 36,
335 + "device_nvme1_thm_temp1_total_time": 0,
336 + "device_nvme1_thm_temp1_trans_count": 0,
337 + "device_nvme1_thm_temp2_total_time": 0,
338 + "device_nvme1_thm_temp2_trans_count": 0,
339 + "device_nvme1_unsafe_shutdowns": 39,
340 + "device_nvme1_warning_temp_time": 0,
341 }
342
343 assert.Equal(t, expected, mx)
@@ -351,56 +351,56 @@ func TestCollector_Collect(t *testing.T) {
351 mx := collr.Collect(context.Background())
352
353 expected := map[string]int64{
354 - "device_nvme0n1_available_spare": 100,
355 - "device_nvme0n1_controller_busy_time": 497040,
356 - "device_nvme0n1_critical_comp_time": 0,
357 - "device_nvme0n1_critical_warning_available_spare": 0,
358 - "device_nvme0n1_critical_warning_nvm_subsystem_reliability": 0,
359 - "device_nvme0n1_critical_warning_persistent_memory_read_only": 0,
360 - "device_nvme0n1_critical_warning_read_only": 0,
361 - "device_nvme0n1_critical_warning_temp_threshold": 0,
362 - "device_nvme0n1_critical_warning_volatile_mem_backup_failed": 0,
363 - "device_nvme0n1_data_units_read": 5068041216000,
364 - "device_nvme0n1_data_units_written": 69712734208000,
365 - "device_nvme0n1_host_read_commands": 313528805,
366 - "device_nvme0n1_host_write_commands": 1928062610,
367 - "device_nvme0n1_media_errors": 0,
368 - "device_nvme0n1_num_err_log_entries": 110,
369 - "device_nvme0n1_percentage_used": 2,
370 - "device_nvme0n1_power_cycles": 64,
371 - "device_nvme0n1_power_on_time": 17906400,
372 - "device_nvme0n1_temperature": 36,
373 - "device_nvme0n1_thm_temp1_total_time": 0,
374 - "device_nvme0n1_thm_temp1_trans_count": 0,
375 - "device_nvme0n1_thm_temp2_total_time": 0,
376 - "device_nvme0n1_thm_temp2_trans_count": 0,
377 - "device_nvme0n1_unsafe_shutdowns": 39,
378 - "device_nvme0n1_warning_temp_time": 0,
379 - "device_nvme1n1_available_spare": 100,
380 - "device_nvme1n1_controller_busy_time": 497040,
381 - "device_nvme1n1_critical_comp_time": 0,
382 - "device_nvme1n1_critical_warning_available_spare": 0,
383 - "device_nvme1n1_critical_warning_nvm_subsystem_reliability": 0,
384 - "device_nvme1n1_critical_warning_persistent_memory_read_only": 0,
385 - "device_nvme1n1_critical_warning_read_only": 0,
386 - "device_nvme1n1_critical_warning_temp_threshold": 0,
387 - "device_nvme1n1_critical_warning_volatile_mem_backup_failed": 0,
388 - "device_nvme1n1_data_units_read": 5068041216000,
389 - "device_nvme1n1_data_units_written": 69712734208000,
390 - "device_nvme1n1_host_read_commands": 313528805,
391 - "device_nvme1n1_host_write_commands": 1928062610,
392 - "device_nvme1n1_media_errors": 0,
393 - "device_nvme1n1_num_err_log_entries": 110,
394 - "device_nvme1n1_percentage_used": 2,
395 - "device_nvme1n1_power_cycles": 64,
396 - "device_nvme1n1_power_on_time": 17906400,
397 - "device_nvme1n1_temperature": 36,
398 - "device_nvme1n1_thm_temp1_total_time": 0,
399 - "device_nvme1n1_thm_temp1_trans_count": 0,
400 - "device_nvme1n1_thm_temp2_total_time": 0,
401 - "device_nvme1n1_thm_temp2_trans_count": 0,
402 - "device_nvme1n1_unsafe_shutdowns": 39,
403 - "device_nvme1n1_warning_temp_time": 0,
354 + "device_nvme0_available_spare": 100,
355 + "device_nvme0_controller_busy_time": 497040,
356 + "device_nvme0_critical_comp_time": 0,
357 + "device_nvme0_critical_warning_available_spare": 0,
358 + "device_nvme0_critical_warning_nvm_subsystem_reliability": 0,
359 + "device_nvme0_critical_warning_persistent_memory_read_only": 0,
360 + "device_nvme0_critical_warning_read_only": 0,
361 + "device_nvme0_critical_warning_temp_threshold": 0,
362 + "device_nvme0_critical_warning_volatile_mem_backup_failed": 0,
363 + "device_nvme0_data_units_read": 5068041216000,
364 + "device_nvme0_data_units_written": 69712734208000,
365 + "device_nvme0_host_read_commands": 313528805,
366 + "device_nvme0_host_write_commands": 1928062610,
367 + "device_nvme0_media_errors": 0,
368 + "device_nvme0_num_err_log_entries": 110,
369 + "device_nvme0_percentage_used": 2,
370 + "device_nvme0_power_cycles": 64,
371 + "device_nvme0_power_on_time": 17906400,
372 + "device_nvme0_temperature": 36,
373 + "device_nvme0_thm_temp1_total_time": 0,
374 + "device_nvme0_thm_temp1_trans_count": 0,
375 + "device_nvme0_thm_temp2_total_time": 0,
376 + "device_nvme0_thm_temp2_trans_count": 0,
377 + "device_nvme0_unsafe_shutdowns": 39,
378 + "device_nvme0_warning_temp_time": 0,
379 + "device_nvme1_available_spare": 100,
380 + "device_nvme1_controller_busy_time": 497040,
381 + "device_nvme1_critical_comp_time": 0,
382 + "device_nvme1_critical_warning_available_spare": 0,
383 + "device_nvme1_critical_warning_nvm_subsystem_reliability": 0,
384 + "device_nvme1_critical_warning_persistent_memory_read_only": 0,
385 + "device_nvme1_critical_warning_read_only": 0,
386 + "device_nvme1_critical_warning_temp_threshold": 0,
387 + "device_nvme1_critical_warning_volatile_mem_backup_failed": 0,
388 + "device_nvme1_data_units_read": 5068041216000,
389 + "device_nvme1_data_units_written": 69712734208000,
390 + "device_nvme1_host_read_commands": 313528805,
391 + "device_nvme1_host_write_commands": 1928062610,
392 + "device_nvme1_media_errors": 0,
393 + "device_nvme1_num_err_log_entries": 110,
394 + "device_nvme1_percentage_used": 2,
395 + "device_nvme1_power_cycles": 64,
396 + "device_nvme1_power_on_time": 17906400,
397 + "device_nvme1_temperature": 36,
398 + "device_nvme1_thm_temp1_total_time": 0,
399 + "device_nvme1_thm_temp1_trans_count": 0,
400 + "device_nvme1_thm_temp2_total_time": 0,
401 + "device_nvme1_thm_temp2_trans_count": 0,
402 + "device_nvme1_unsafe_shutdowns": 39,
403 + "device_nvme1_warning_temp_time": 0,
404 }
405
406 assert.Equal(t, expected, mx)