1818from cmk .plugins .netapp .agent_based .netapp_ontap_temp import (
1919 _check_netapp_ontap_temp ,
2020 discovery_netapp_ontap_temp ,
21+ parse_netapp_ontap_temp ,
2122)
2223from cmk .plugins .netapp .models import ShelfTemperatureModel
2324
@@ -32,79 +33,68 @@ class ShelfTemperatureModelFactory(ModelFactory):
3233 list_id = "2" ,
3334 state = "ok" ,
3435 id = 111 ,
35- temperature = 20.0 ,
36+ temperature = 20 ,
3637 ambient = True ,
37- low_warning = None ,
38- low_critical = None ,
39- high_warning = None ,
40- high_critical = None ,
38+ low_warning = 5 ,
39+ low_critical = 0 ,
40+ high_warning = 55 ,
41+ high_critical = 60 ,
4142 ),
4243 ],
4344 "Internal Shelf 2" : [
4445 ShelfTemperatureModelFactory .build (
4546 list_id = "2" ,
4647 state = "ok" ,
47- temperature = 50.0 ,
48+ temperature = 50 ,
4849 ambient = False ,
49- low_warning = None ,
50- low_critical = None ,
51- high_warning = None ,
52- high_critical = None ,
50+ low_warning = 5 ,
51+ low_critical = 0 ,
52+ high_warning = 95 ,
53+ high_critical = 105 ,
5354 ),
5455 ],
5556 "Ambient Shelf 1" : [
5657 ShelfTemperatureModelFactory .build (
5758 list_id = "1" ,
5859 state = "ok" ,
59- temperature = 50.0 ,
60+ temperature = 50 ,
6061 ambient = True ,
61- low_warning = None ,
62- low_critical = None ,
63- high_warning = None ,
64- high_critical = None ,
62+ low_warning = 5 ,
63+ low_critical = 0 ,
64+ high_warning = 95 ,
65+ high_critical = 105 ,
6566 ),
6667 ShelfTemperatureModelFactory .build (
6768 list_id = "1" ,
6869 state = "ok" ,
69- temperature = 10.0 ,
70+ temperature = 10 ,
7071 ambient = True ,
71- low_warning = None ,
72- low_critical = None ,
73- high_warning = None ,
74- high_critical = None ,
72+ low_warning = 5 ,
73+ low_critical = 0 ,
74+ high_warning = 95 ,
75+ high_critical = 105 ,
7576 ),
7677 ShelfTemperatureModelFactory .build (
7778 list_id = "1" ,
7879 state = "ok" ,
79- temperature = 20.0 ,
80+ temperature = 20 ,
8081 ambient = True ,
81- low_warning = None ,
82- low_critical = None ,
83- high_warning = None ,
84- high_critical = None ,
85- ),
86- ShelfTemperatureModelFactory .build (
87- list_id = "1" ,
88- id = 20 ,
89- state = "error" ,
90- temperature = None ,
91- ambient = True ,
92- low_warning = None ,
93- low_critical = None ,
94- high_warning = None ,
95- high_critical = None ,
82+ low_warning = 5 ,
83+ low_critical = 0 ,
84+ high_warning = 95 ,
85+ high_critical = 105 ,
9686 ),
9787 ],
9888 "Internal Shelf 1" : [
9989 ShelfTemperatureModelFactory .build (
10090 list_id = "1" ,
10191 state = "ok" ,
102- temperature = 30.0 ,
92+ temperature = 30 ,
10393 ambient = False ,
104- low_warning = None ,
105- low_critical = None ,
106- high_warning = None ,
107- high_critical = None ,
94+ low_warning = 5 ,
95+ low_critical = 0 ,
96+ high_warning = 95 ,
97+ high_critical = 105 ,
10898 ),
10999 ],
110100}
@@ -142,7 +132,6 @@ def test_check_netapp_ontap_temp_() -> None:
142132 Metric ("temp" , 50.0 ),
143133 Result (state = State .OK , summary = "Average: 26.7 °C" ),
144134 Result (state = State .OK , summary = "Lowest: 10 °C" ),
145- Result (state = State .CRIT , summary = "Additional failed sensors: 1 (1/20)" ),
146135 ]
147136
148137
@@ -218,3 +207,35 @@ def test_check_netapp_ontap_temp_trend(
218207 )
219208
220209 assert result [- 1 ] == expected_trend_result
210+
211+
212+ @pytest .mark .parametrize (
213+ "json_line, expected_count" ,
214+ [
215+ pytest .param (
216+ # Valid sensor: temperature and thresholds present
217+ '{"list_id":"1","id":8,"state":"ok","installed":true,"temperature":57,"ambient":false,'
218+ '"low_warning":5,"low_critical":0,"high_warning":95,"high_critical":105}' ,
219+ 1 ,
220+ id = "valid sensor is kept" ,
221+ ),
222+ pytest .param (
223+ # DAC-only sensor: installed=true but no SFP — all values null (NetApp firmware bug)
224+ '{"list_id":"1","id":10,"state":"error","installed":true,"temperature":null,"ambient":false,'
225+ '"low_warning":null,"low_critical":null,"high_warning":null,"high_critical":null}' ,
226+ 0 ,
227+ id = "DAC sensor with null temperature and null thresholds is filtered" ,
228+ ),
229+ pytest .param (
230+ # Sensor with temperature but no thresholds is filtered
231+ '{"list_id":"1","id":12,"state":"ok","installed":true,"temperature":45,"ambient":false,'
232+ '"low_warning":null,"low_critical":null,"high_warning":null,"high_critical":null}' ,
233+ 0 ,
234+ id = "sensor with temperature but no thresholds is filtered" ,
235+ ),
236+ ],
237+ )
238+ def test_parse_netapp_ontap_temp_filters_dac_sensors (json_line : str , expected_count : int ) -> None :
239+ section = parse_netapp_ontap_temp ([[json_line ]])
240+ total = sum (len (sensors ) for sensors in section .values ())
241+ assert total == expected_count
0 commit comments