Skip to content

Commit f6678e5

Browse files
committed
Revert "18264 netapp_ontap_status: respect alert's suppression and acknowledgement"
This reverts commit 05ce889. Reason for revert: plugin tests failing Change-Id: I8ac633e9806370072d9efd21c0bf2bcd183b633d
1 parent 5995c4c commit f6678e5

4 files changed

Lines changed: 9 additions & 102 deletions

File tree

.werks/18264.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmk/plugins/netapp/agent_based/netapp_ontap_status.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@
2929
# }
3030

3131

32-
def format_alert(alert):
33-
s = alert.name
34-
if alert.acknowledge:
35-
s += f", acknowledged by {alert.acknowledger}"
36-
if alert.suppress:
37-
s += f", suppressed by {alert.suppressor}"
38-
return s
39-
40-
4132
def parse_netapp_api_status(string_table: StringTable) -> Section:
4233
return [
4334
alert for line in string_table for alert in [models.AlertModel.model_validate_json(line[0])]
@@ -55,25 +46,14 @@ def discovery_netapp_ontap_status(section: Section) -> DiscoveryResult:
5546

5647

5748
def check_netapp_ontap_status(section: Section) -> CheckResult:
49+
"""
50+
Status is considered OK if there are no alerts
51+
"""
52+
5853
if not section:
59-
yield Result(state=State.OK, summary="No alerts present")
60-
return
61-
62-
handled_alerts = [alert for alert in section if alert.acknowledge or alert.suppress]
63-
unhandled_alerts = [alert for alert in section if alert not in handled_alerts]
64-
# show the unhandled alerts first
65-
details = "\n".join(format_alert(alert) for alert in unhandled_alerts + handled_alerts)
66-
67-
if unhandled_alerts:
68-
yield Result(
69-
state=State.CRIT, summary="Unhandled alerts present, see details", details=details
70-
)
54+
yield Result(state=State.OK, summary="Status: OK")
7155
else:
72-
yield Result(
73-
state=State.OK,
74-
summary="Alerts present, but all acknowledged or suppressed, see details",
75-
details=details,
76-
)
56+
yield Result(state=State.CRIT, summary="Status: Alerts present")
7757

7858

7959
check_plugin_netapp_ontap_status = CheckPlugin(

cmk/plugins/netapp/models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,6 @@ class AlertModel(BaseModel):
577577
"""
578578

579579
name: str
580-
acknowledge: bool
581-
acknowledger: str = ""
582-
suppress: bool
583-
suppressor: str = ""
584580

585581

586582
class SvmTrafficCountersModel(BaseModel):

tests/unit/cmk/plugins/netapp/test_netapp_ontap_status.py

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,15 @@ class AlertModelFactory(ModelFactory):
2121
"alerts_models, expected_result",
2222
[
2323
pytest.param(
24-
[
25-
AlertModelFactory.build(name="alert1", acknowledge=False, suppress=False),
26-
AlertModelFactory.build(name="alert2", acknowledge=False, suppress=False),
27-
],
28-
[
29-
Result(
30-
state=State.CRIT,
31-
summary="Unhandled alerts present, see details",
32-
details="alert1\nalert2",
33-
)
34-
],
24+
[AlertModelFactory.build(name="alert1"), AlertModelFactory.build(name="alert2")],
25+
[Result(state=State.CRIT, summary="Status: Alerts present")],
3526
id="alerts present",
3627
),
3728
pytest.param(
3829
[],
39-
[Result(state=State.OK, summary="No alerts present")],
30+
[Result(state=State.OK, summary="Status: OK")],
4031
id="no alerts present",
4132
),
42-
pytest.param(
43-
[
44-
AlertModelFactory.build(
45-
name="alert1", acknowledge=True, acknowledger="hhirsch", suppress=False
46-
),
47-
AlertModelFactory.build(
48-
name="alert2", acknowledge=False, suppress=True, suppressor="hhirsch"
49-
),
50-
],
51-
[
52-
Result(
53-
state=State.OK,
54-
summary="Alerts present, but all acknowledged or suppressed, see details",
55-
details="alert1, acknowledged by hhirsch\nalert2, suppressed by hhirsch",
56-
)
57-
],
58-
id="alerts suppressed",
59-
),
60-
pytest.param(
61-
[
62-
AlertModelFactory.build(
63-
name="alert2", acknowledge=False, suppress=True, suppressor="hhirsch"
64-
),
65-
AlertModelFactory.build(
66-
name="alert1", acknowledge=False, acknowledger="hhirsch", suppress=False
67-
),
68-
],
69-
[
70-
Result(
71-
state=State.CRIT,
72-
summary="Unhandled alerts present, see details",
73-
details="alert1\nalert2, suppressed by hhirsch",
74-
)
75-
],
76-
id="one alert not suppressed (show it first)",
77-
),
7833
],
7934
)
8035
def test_check_netapp_ontap_status(

0 commit comments

Comments
 (0)