@cryptotaxi247 / netdata / commits / 2f6251b98

fix(go.d/adaptecraid): ignore non-Hard-drive entries in PD parse (#22355)

Ilya Mashchenko committed May 1, 2026 at 10:36 UTC 2f6251b98b6b1fe0e503df455a4ab1c70c76a7b1
3 files changed +517 -8
src/go/plugin/go.d/collector/adaptecraid/collect_pd.go
+6
@@ -104,6 +104,12 @@ func parsePhysDevInfo(bs []byte) (map[string]*physicalDevice, error) {
104 }
105
106 switch {
107 + case strings.HasPrefix(line, "Device is"):
108 + // Skip non-disk entries such as "Device is an Enclosure Services Device".
109 + if line != "Device is a Hard drive" {
110 + delete(devices, pd.number)
111 + pd = nil
112 + }
113 case strings.HasPrefix(line, "State"):
114 pd.state = getColonSepValue(line)
115 case strings.HasPrefix(line, "Reported Location"):
src/go/plugin/go.d/collector/adaptecraid/collector_test.go
+65 -8
@@ -18,10 +18,11 @@ var (
18 dataConfigJSON, _ = os.ReadFile("testdata/config.json")
19 dataConfigYAML, _ = os.ReadFile("testdata/config.yaml")
20
21 - dataLogicalDevicesOld, _ = os.ReadFile("testdata/getconfig-ld-old.txt")
22 - dataPhysicalDevicesOld, _ = os.ReadFile("testdata/getconfig-pd-old.txt")
23 - dataLogicalDevicesCurrent, _ = os.ReadFile("testdata/getconfig-ld-current.txt")
24 - dataPhysicalDevicesCurrent, _ = os.ReadFile("testdata/getconfig-pd-current.txt")
21 + dataLogicalDevicesOld, _ = os.ReadFile("testdata/getconfig-ld-old.txt")
22 + dataPhysicalDevicesOld, _ = os.ReadFile("testdata/getconfig-pd-old.txt")
23 + dataLogicalDevicesCurrent, _ = os.ReadFile("testdata/getconfig-ld-current.txt")
24 + dataPhysicalDevicesCurrent, _ = os.ReadFile("testdata/getconfig-pd-current.txt")
25 + dataPhysicalDevicesWithEnclosure, _ = os.ReadFile("testdata/getconfig-pd-with-enclosure.txt")
26 )
27
28 func Test_testDataIsValid(t *testing.T) {
@@ -29,10 +30,11 @@ func Test_testDataIsValid(t *testing.T) {
30 "dataConfigJSON": dataConfigJSON,
31 "dataConfigYAML": dataConfigYAML,
32
32 - "dataLogicalDevicesOld": dataLogicalDevicesOld,
33 - "dataPhysicalDevicesOld": dataPhysicalDevicesOld,
34 - "dataLogicalDevicesCurrent": dataLogicalDevicesCurrent,
35 - "dataPhysicalDevicesCurrent": dataPhysicalDevicesCurrent,
33 + "dataLogicalDevicesOld": dataLogicalDevicesOld,
34 + "dataPhysicalDevicesOld": dataPhysicalDevicesOld,
35 + "dataLogicalDevicesCurrent": dataLogicalDevicesCurrent,
36 + "dataPhysicalDevicesCurrent": dataPhysicalDevicesCurrent,
37 + "dataPhysicalDevicesWithEnclosure": dataPhysicalDevicesWithEnclosure,
38 } {
39 require.NotNil(t, data, name)
40 }
@@ -119,6 +121,10 @@ func TestCollector_Check(t *testing.T) {
121 wantFail: false,
122 prepareMock: prepareMockOkCurrent,
123 },
124 + "success case with enclosure data": {
125 + wantFail: false,
126 + prepareMock: prepareMockOkWithEnclosure,
127 + },
128 "err on exec": {
129 wantFail: true,
130 prepareMock: prepareMockErr,
@@ -200,6 +206,50 @@ func TestCollector_Collect(t *testing.T) {
206 "pd_5_smart_warnings": 0,
207 },
208 },
209 + "success case with enclosure data": {
210 + prepareMock: prepareMockOkWithEnclosure,
211 + wantCharts: len(ldChartsTmpl)*1 + (len(pdChartsTmpl)-1)*12,
212 + wantMetrics: map[string]int64{
213 + "ld_0_health_state_critical": 0,
214 + "ld_0_health_state_ok": 1,
215 + "pd_0_health_state_critical": 0,
216 + "pd_0_health_state_ok": 1,
217 + "pd_0_smart_warnings": 0,
218 + "pd_1_health_state_critical": 0,
219 + "pd_1_health_state_ok": 1,
220 + "pd_1_smart_warnings": 0,
221 + "pd_10_health_state_critical": 0,
222 + "pd_10_health_state_ok": 1,
223 + "pd_10_smart_warnings": 0,
224 + "pd_11_health_state_critical": 0,
225 + "pd_11_health_state_ok": 1,
226 + "pd_11_smart_warnings": 0,
227 + "pd_2_health_state_critical": 0,
228 + "pd_2_health_state_ok": 1,
229 + "pd_2_smart_warnings": 0,
230 + "pd_3_health_state_critical": 0,
231 + "pd_3_health_state_ok": 1,
232 + "pd_3_smart_warnings": 0,
233 + "pd_4_health_state_critical": 0,
234 + "pd_4_health_state_ok": 1,
235 + "pd_4_smart_warnings": 0,
236 + "pd_5_health_state_critical": 0,
237 + "pd_5_health_state_ok": 1,
238 + "pd_5_smart_warnings": 0,
239 + "pd_6_health_state_critical": 0,
240 + "pd_6_health_state_ok": 1,
241 + "pd_6_smart_warnings": 0,
242 + "pd_7_health_state_critical": 0,
243 + "pd_7_health_state_ok": 1,
244 + "pd_7_smart_warnings": 0,
245 + "pd_8_health_state_critical": 0,
246 + "pd_8_health_state_ok": 1,
247 + "pd_8_smart_warnings": 0,
248 + "pd_9_health_state_critical": 0,
249 + "pd_9_health_state_ok": 1,
250 + "pd_9_smart_warnings": 0,
251 + },
252 + },
253 "err on exec": {
254 prepareMock: prepareMockErr,
255 },
@@ -239,6 +289,13 @@ func prepareMockOkCurrent() *mockArcconfExec {
289 }
290 }
291
292 +func prepareMockOkWithEnclosure() *mockArcconfExec {
293 + return &mockArcconfExec{
294 + ldData: dataLogicalDevicesCurrent,
295 + pdData: dataPhysicalDevicesWithEnclosure,
296 + }
297 +}
298 +
299 func prepareMockErr() *mockArcconfExec {
300 return &mockArcconfExec{
301 errOnInfo: true,
src/go/plugin/go.d/collector/adaptecraid/testdata/getconfig-pd-with-enclosure.txt new
+446
@@ -0,0 +1,446 @@
1 +Controllers found: 1
2 +----------------------------------------------------------------------
3 +Physical Device information
4 +----------------------------------------------------------------------
5 + Device #0
6 + Device is a Hard drive
7 + State : Online
8 + Block Size : 512 Bytes
9 + Supported : Yes
10 + Transfer Speed : SATA 6.0 Gb/s
11 + Reported Channel,Device(T:L) : 0,16(16:0)
12 + Reported Location : Enclosure 0, Slot 0( Connector Unknown )
13 + Reported ESD(T:L) : 2,0(0:0)
14 + Vendor : ATA
15 + Model : INTEL SSDSC2KB019T
16 + Firmware : SCV10111
17 + Serial number : XXXXXXXXXXXXXXXXXX
18 + Reserved Size : 3666200 KB
19 + Used Size : 1827840 MB
20 + Unused Size : 64 KB
21 + Total Size : 1831420 MB
22 + Write Cache : Enabled (write-back)
23 + FRU : None
24 + S.M.A.R.T. : No
25 + S.M.A.R.T. warnings : 0
26 + Power State : Full rpm
27 + Supported Power States : Full power,Powered off
28 + SSD : Yes
29 + Temperature : Not Supported
30 + NCQ status : Enabled
31 + ----------------------------------------------------------------
32 + Device Phy Information
33 + ----------------------------------------------------------------
34 + Phy #0
35 + PHY Identifier : 0
36 + SAS Address : 5000
37 + Attached PHY Identifier : 12
38 + Attached SAS Address : 5000
39 +
40 + Device #1
41 + Device is a Hard drive
42 + State : Online
43 + Block Size : 512 Bytes
44 + Supported : Yes
45 + Transfer Speed : SATA 6.0 Gb/s
46 + Reported Channel,Device(T:L) : 0,17(17:0)
47 + Reported Location : Enclosure 0, Slot 1( Connector Unknown )
48 + Reported ESD(T:L) : 2,0(0:0)
49 + Vendor : ATA
50 + Model : INTEL SSDSC2KB019T
51 + Firmware : SCV10111
52 + Serial number : XXXXXXXXXXXXXXXXXX
53 + Reserved Size : 3666200 KB
54 + Used Size : 1827840 MB
55 + Unused Size : 64 KB
56 + Total Size : 1831420 MB
57 + Write Cache : Enabled (write-back)
58 + FRU : None
59 + S.M.A.R.T. : No
60 + S.M.A.R.T. warnings : 0
61 + Power State : Full rpm
62 + Supported Power States : Full power,Powered off
63 + SSD : Yes
64 + Temperature : Not Supported
65 + NCQ status : Enabled
66 + ----------------------------------------------------------------
67 + Device Phy Information
68 + ----------------------------------------------------------------
69 + Phy #0
70 + PHY Identifier : 0
71 + SAS Address : 5000
72 + Attached PHY Identifier : 13
73 + Attached SAS Address : 5000
74 +
75 + Device #2
76 + Device is a Hard drive
77 + State : Online
78 + Block Size : 512 Bytes
79 + Supported : Yes
80 + Transfer Speed : SATA 6.0 Gb/s
81 + Reported Channel,Device(T:L) : 0,18(18:0)
82 + Reported Location : Enclosure 0, Slot 2( Connector Unknown )
83 + Reported ESD(T:L) : 2,0(0:0)
84 + Vendor : ATA
85 + Model : INTEL SSDSC2KB019T
86 + Firmware : SCV10111
87 + Serial number : XXXXXXXXXXXXXXXXXX
88 + Reserved Size : 3666200 KB
89 + Used Size : 1827840 MB
90 + Unused Size : 64 KB
91 + Total Size : 1831420 MB
92 + Write Cache : Enabled (write-back)
93 + FRU : None
94 + S.M.A.R.T. : No
95 + S.M.A.R.T. warnings : 0
96 + Power State : Full rpm
97 + Supported Power States : Full power,Powered off
98 + SSD : Yes
99 + Temperature : Not Supported
100 + NCQ status : Enabled
101 + ----------------------------------------------------------------
102 + Device Phy Information
103 + ----------------------------------------------------------------
104 + Phy #0
105 + PHY Identifier : 0
106 + SAS Address : 5000
107 + Attached PHY Identifier : 14
108 + Attached SAS Address : 5000
109 +
110 + Device #3
111 + Device is a Hard drive
112 + State : Online
113 + Block Size : 512 Bytes
114 + Supported : Yes
115 + Transfer Speed : SATA 6.0 Gb/s
116 + Reported Channel,Device(T:L) : 0,19(19:0)
117 + Reported Location : Enclosure 0, Slot 3( Connector Unknown )
118 + Reported ESD(T:L) : 2,0(0:0)
119 + Vendor : ATA
120 + Model : INTEL SSDSC2KB019T
121 + Firmware : SCV10111
122 + Serial number : XXXXXXXXXXXXXXXXXX
123 + Reserved Size : 3666200 KB
124 + Used Size : 1827840 MB
125 + Unused Size : 64 KB
126 + Total Size : 1831420 MB
127 + Write Cache : Enabled (write-back)
128 + FRU : None
129 + S.M.A.R.T. : No
130 + S.M.A.R.T. warnings : 0
131 + Power State : Full rpm
132 + Supported Power States : Full power,Powered off
133 + SSD : Yes
134 + Temperature : Not Supported
135 + NCQ status : Enabled
136 + ----------------------------------------------------------------
137 + Device Phy Information
138 + ----------------------------------------------------------------
139 + Phy #0
140 + PHY Identifier : 0
141 + SAS Address : 5000
142 + Attached PHY Identifier : 15
143 + Attached SAS Address : 5000
144 +
145 + Device #4
146 + Device is a Hard drive
147 + State : Online
148 + Block Size : 512 Bytes
149 + Supported : Yes
150 + Transfer Speed : SATA 6.0 Gb/s
151 + Reported Channel,Device(T:L) : 0,20(20:0)
152 + Reported Location : Enclosure 0, Slot 4( Connector Unknown )
153 + Reported ESD(T:L) : 2,0(0:0)
154 + Vendor : ATA
155 + Model : INTEL SSDSC2KB019T
156 + Firmware : SCV10111
157 + Serial number : XXXXXXXXXXXXXXXXXX
158 + Reserved Size : 3666200 KB
159 + Used Size : 1827840 MB
160 + Unused Size : 64 KB
161 + Total Size : 1831420 MB
162 + Write Cache : Enabled (write-back)
163 + FRU : None
164 + S.M.A.R.T. : No
165 + S.M.A.R.T. warnings : 0
166 + Power State : Full rpm
167 + Supported Power States : Full power,Powered off
168 + SSD : Yes
169 + Temperature : Not Supported
170 + NCQ status : Enabled
171 + ----------------------------------------------------------------
172 + Device Phy Information
173 + ----------------------------------------------------------------
174 + Phy #0
175 + PHY Identifier : 0
176 + SAS Address : 5000
177 + Attached PHY Identifier : 16
178 + Attached SAS Address : 5000
179 +
180 + Device #5
181 + Device is a Hard drive
182 + State : Online
183 + Block Size : 512 Bytes
184 + Supported : Yes
185 + Transfer Speed : SATA 6.0 Gb/s
186 + Reported Channel,Device(T:L) : 0,21(21:0)
187 + Reported Location : Enclosure 0, Slot 5( Connector Unknown )
188 + Reported ESD(T:L) : 2,0(0:0)
189 + Vendor : ATA
190 + Model : INTEL SSDSC2KB019T
191 + Firmware : SCV10111
192 + Serial number : XXXXXXXXXXXXXXXXXX
193 + Reserved Size : 3666200 KB
194 + Used Size : 1827840 MB
195 + Unused Size : 64 KB
196 + Total Size : 1831420 MB
197 + Write Cache : Enabled (write-back)
198 + FRU : None
199 + S.M.A.R.T. : No
200 + S.M.A.R.T. warnings : 0
201 + Power State : Full rpm
202 + Supported Power States : Full power,Powered off
203 + SSD : Yes
204 + Temperature : Not Supported
205 + NCQ status : Enabled
206 + ----------------------------------------------------------------
207 + Device Phy Information
208 + ----------------------------------------------------------------
209 + Phy #0
210 + PHY Identifier : 0
211 + SAS Address : 5000
212 + Attached PHY Identifier : 17
213 + Attached SAS Address : 5000
214 +
215 + Device #6
216 + Device is a Hard drive
217 + State : Online
218 + Block Size : 512 Bytes
219 + Supported : Yes
220 + Transfer Speed : SATA 6.0 Gb/s
221 + Reported Channel,Device(T:L) : 0,22(22:0)
222 + Reported Location : Enclosure 0, Slot 6( Connector Unknown )
223 + Reported ESD(T:L) : 2,0(0:0)
224 + Vendor : ATA
225 + Model : INTEL SSDSC2KB019T
226 + Firmware : SCV10111
227 + Serial number : XXXXXXXXXXXXXXXXXX
228 + Reserved Size : 3666200 KB
229 + Used Size : 1827840 MB
230 + Unused Size : 64 KB
231 + Total Size : 1831420 MB
232 + Write Cache : Enabled (write-back)
233 + FRU : None
234 + S.M.A.R.T. : No
235 + S.M.A.R.T. warnings : 0
236 + Power State : Full rpm
237 + Supported Power States : Full power,Powered off
238 + SSD : Yes
239 + Temperature : Not Supported
240 + NCQ status : Enabled
241 + ----------------------------------------------------------------
242 + Device Phy Information
243 + ----------------------------------------------------------------
244 + Phy #0
245 + PHY Identifier : 0
246 + SAS Address : 5000
247 + Attached PHY Identifier : 18
248 + Attached SAS Address : 5000
249 +
250 + Device #7
251 + Device is a Hard drive
252 + State : Online
253 + Block Size : 512 Bytes
254 + Supported : Yes
255 + Transfer Speed : SATA 6.0 Gb/s
256 + Reported Channel,Device(T:L) : 0,23(23:0)
257 + Reported Location : Enclosure 0, Slot 7( Connector Unknown )
258 + Reported ESD(T:L) : 2,0(0:0)
259 + Vendor : ATA
260 + Model : INTEL SSDSC2KB019T
261 + Firmware : SCV10111
262 + Serial number : XXXXXXXXXXXXXXXXXX
263 + Reserved Size : 3666200 KB
264 + Used Size : 1827840 MB
265 + Unused Size : 64 KB
266 + Total Size : 1831420 MB
267 + Write Cache : Enabled (write-back)
268 + FRU : None
269 + S.M.A.R.T. : No
270 + S.M.A.R.T. warnings : 0
271 + Power State : Full rpm
272 + Supported Power States : Full power,Powered off
273 + SSD : Yes
274 + Temperature : Not Supported
275 + NCQ status : Enabled
276 + ----------------------------------------------------------------
277 + Device Phy Information
278 + ----------------------------------------------------------------
279 + Phy #0
280 + PHY Identifier : 0
281 + SAS Address : 5000
282 + Attached PHY Identifier : 19
283 + Attached SAS Address : 5000
284 +
285 + Device #8
286 + Device is a Hard drive
287 + State : Online
288 + Block Size : 512 Bytes
289 + Supported : Yes
290 + Transfer Speed : SATA 6.0 Gb/s
291 + Reported Channel,Device(T:L) : 0,24(24:0)
292 + Reported Location : Enclosure 0, Slot 8( Connector Unknown )
293 + Reported ESD(T:L) : 2,0(0:0)
294 + Vendor : ATA
295 + Model : INTEL SSDSC2KB019T
296 + Firmware : SCV10111
297 + Serial number : XXXXXXXXXXXXXXXXXX
298 + Reserved Size : 3666200 KB
299 + Used Size : 1827840 MB
300 + Unused Size : 64 KB
301 + Total Size : 1831420 MB
302 + Write Cache : Enabled (write-back)
303 + FRU : None
304 + S.M.A.R.T. : No
305 + S.M.A.R.T. warnings : 0
306 + Power State : Full rpm
307 + Supported Power States : Full power,Powered off
308 + SSD : Yes
309 + Temperature : Not Supported
310 + NCQ status : Enabled
311 + ----------------------------------------------------------------
312 + Device Phy Information
313 + ----------------------------------------------------------------
314 + Phy #0
315 + PHY Identifier : 0
316 + SAS Address : 5000
317 + Attached PHY Identifier : 20
318 + Attached SAS Address : 5000
319 +
320 + Device #9
321 + Device is a Hard drive
322 + State : Online
323 + Block Size : 512 Bytes
324 + Supported : Yes
325 + Transfer Speed : SATA 6.0 Gb/s
326 + Reported Channel,Device(T:L) : 0,25(25:0)
327 + Reported Location : Enclosure 0, Slot 9( Connector Unknown )
328 + Reported ESD(T:L) : 2,0(0:0)
329 + Vendor : ATA
330 + Model : INTEL SSDSC2KB019T
331 + Firmware : SCV10111
332 + Serial number : XXXXXXXXXXXXXXXXXX
333 + Reserved Size : 3666200 KB
334 + Used Size : 1827840 MB
335 + Unused Size : 64 KB
336 + Total Size : 1831420 MB
337 + Write Cache : Enabled (write-back)
338 + FRU : None
339 + S.M.A.R.T. : No
340 + S.M.A.R.T. warnings : 0
341 + Power State : Full rpm
342 + Supported Power States : Full power,Powered off
343 + SSD : Yes
344 + Temperature : Not Supported
345 + NCQ status : Enabled
346 + ----------------------------------------------------------------
347 + Device Phy Information
348 + ----------------------------------------------------------------
349 + Phy #0
350 + PHY Identifier : 0
351 + SAS Address : 5000
352 + Attached PHY Identifier : 21
353 + Attached SAS Address : 5000
354 +
355 + Device #10
356 + Device is a Hard drive
357 + State : Global Hot-Spare
358 + Block Size : 512 Bytes
359 + Supported : Yes
360 + Transfer Speed : SATA 6.0 Gb/s
361 + Reported Channel,Device(T:L) : 0,26(26:0)
362 + Reported Location : Enclosure 0, Slot 10( Connector Unknown )
363 + Reported ESD(T:L) : 2,0(0:0)
364 + Vendor : ATA
365 + Model : INTEL SSDSC2KB019T
366 + Firmware : SCV10111
367 + Serial number : XXXXXXXXXXXXXXXXXX
368 + Reserved Size : 3666200 KB
369 + Used Size : 1827840 MB
370 + Unused Size : 64 KB
371 + Total Size : 1831420 MB
372 + Write Cache : Enabled (write-back)
373 + FRU : None
374 + S.M.A.R.T. : No
375 + S.M.A.R.T. warnings : 0
376 + Power State : Full rpm
377 + Supported Power States : Full power,Powered off
378 + SSD : Yes
379 + Temperature : Not Supported
380 + NCQ status : Enabled
381 + ----------------------------------------------------------------
382 + Device Phy Information
383 + ----------------------------------------------------------------
384 + Phy #0
385 + PHY Identifier : 0
386 + SAS Address : 5000
387 + Attached PHY Identifier : 22
388 + Attached SAS Address : 5000
389 +
390 + Device #11
391 + Device is a Hard drive
392 + State : Global Hot-Spare
393 + Block Size : 512 Bytes
394 + Supported : Yes
395 + Transfer Speed : SATA 6.0 Gb/s
396 + Reported Channel,Device(T:L) : 0,27(27:0)
397 + Reported Location : Enclosure 0, Slot 11( Connector Unknown )
398 + Reported ESD(T:L) : 2,0(0:0)
399 + Vendor : ATA
400 + Model : INTEL SSDSC2KB019T
401 + Firmware : SCV10111
402 + Serial number : XXXXXXXXXXXXXXXXXX
403 + Reserved Size : 3666200 KB
404 + Used Size : 1827840 MB
405 + Unused Size : 64 KB
406 + Total Size : 1831420 MB
407 + Write Cache : Enabled (write-back)
408 + FRU : None
409 + S.M.A.R.T. : No
410 + S.M.A.R.T. warnings : 0
411 + Power State : Full rpm
412 + Supported Power States : Full power,Powered off
413 + SSD : Yes
414 + Temperature : Not Supported
415 + NCQ status : Enabled
416 + ----------------------------------------------------------------
417 + Device Phy Information
418 + ----------------------------------------------------------------
419 + Phy #0
420 + PHY Identifier : 0
421 + SAS Address : 5000
422 + Attached PHY Identifier : 23
423 + Attached SAS Address : 5000
424 +
425 + Device #12
426 + Device is an Enclosure Services Device
427 + Reported Channel,Device(T:L) : 2,0(0:0)
428 + Enclosure ID : 0
429 + Enclosure Logical Identifier : 5000
430 + Expander ID : 0
431 + Expander SAS Address : 5000
432 + Type : SES2
433 + Vendor : LSI CORP
434 + Model : SAS2X28
435 + Firmware : 0717
436 + Status of Enclosure Services Device
437 + Fan 1 status : 0 rpm (Not Installed)
438 + Fan 2 status : 0 rpm (Not Installed)
439 + Fan 3 status : 0 rpm (Not Installed)
440 + Power supply 1 status : Not Installed
441 + Power supply 2 status : Not Installed
442 + Temperature Sensor Status 1 : 24 C/ 75 F (Normal)
443 + Speaker status : On
444 +
445 +
446 +Command completed successfully.