Skip to content

Commit

Permalink
17412 FIX cisco_temperature: ignore incomplete sensor thresholds
Browse files Browse the repository at this point in the history
Prior to this werk, the Cisco temperature check raised an exception
whenever a sensor threshold lacked complete information—specifically,
if any of the severity, relation, or threshold values were missing.
This caused both the discovery and check processes to fail. The updated
behavior addresses this issue by first verifying whether a threshold value
is defined and ignoring sensors that do not have one. However, if a
threshold value is defined but either the severity, relation, or both are
missing, an exception will now be raised instead of skipping over the incomplete
threshold.

SUP-21069

Change-Id: I6614ade4bcefd79f2af4d42f3c4e19d4a68051d2
  • Loading branch information
anthonyh209 committed Dec 17, 2024
1 parent a58ff82 commit d3f74c1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .werks/17412.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[//]: # (werk v2)
# cisco_temperature: ignore incomplete sensor thresholds

key | value
---------- | ---
date | 2024-12-16T13:02:38+00:00
version | 2.3.0p24
class | fix
edition | cre
component | checks
level | 1
compatible | yes

Prior to this werk, the Cisco temperature check raised an exception
whenever a sensor threshold lacked complete information—specifically,
if any of the severity, relation, or threshold values were missing.
This caused both the discovery and check processes to fail. The updated
behavior addresses this issue by first verifying whether a threshold value
is defined and ignoring sensors that do not have one. However, if a
threshold value is defined but either the severity, relation, or both are
missing, an exception will now be raised instead of skipping over the incomplete
threshold.
6 changes: 6 additions & 0 deletions cmk/base/plugins/agent_based/cisco_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def parse_cisco_temperature( # pylint: disable=too-many-branches
thresholds.setdefault(sensor_id, [])

for endoid, severity, relation, thresh_value in levels_info:
if thresh_value and not all((severity, relation)):
raise ValueError("Threshold value with no relation or severity")

if not thresh_value:
continue

# endoid is e.g. 21549.9 or 21459.10
sensor_id, _subid = endoid.split(".")
thresholds.setdefault(sensor_id, []).append(
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/cmk/base/plugins/agent_based/test_cisco_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,32 @@ def test_parse_admin_state_mapping(
},
id="fallback_no_coercion_for_severity_other",
),
pytest.param(
[
[["1010", "", "Switch 1 - Inlet Temp Sensor"]],
[["1010", "8", "9", "0", "49", "1"]],
[
# no threshold values
["1010.1", "1", "1", ""],
["1010.2", "1", "1", ""],
],
[["1010", "Switch 1 - Inlet Temp Sensor", "49", "56", "2"]],
[["oid_end", "description", "1"]],
[],
],
{
"8": {
"Switch 1 - Inlet Temp Sensor": {
"dev_levels_lower": None,
"dev_levels_upper": (56.0, 56.0),
"dev_state": (1, "warning"),
"raw_env_mon_state": "2",
"reading": 49,
},
}
},
id="no_threshold_values",
),
],
)
def test_parse_cisco_temperature_thresholds(
Expand Down

0 comments on commit d3f74c1

Please sign in to comment.