Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmk/gui/plugins/wato/check_parameters/cisco_dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ def _valuespec_discovery_cisco_dom_rules() -> Dictionary:
default_value=["1", "2", "3"],
),
),
(
"operational_states",
ListChoice(
title=_("Operational states to discover"),
choices={
1: _("up"),
2: _("down"),
3: _("testing"),
4: _("unknown"),
5: _("dormant"),
6: _("not present"),
7: _("lower layer down"),
8: _("degraded"),
},
toggle_all=True,
default_value=["1", "2", "3", "4", "5", "6", "7", "8"],
),
),
],
)

Expand Down
54 changes: 44 additions & 10 deletions cmk/plugins/cisco/agent_based/cisco_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@
"3": "testing",
}

_CISCO_TEMPERATURE_OPER_STATE_MAP = {
"1": "up",
"2": "down",
"3": "testing",
"4": "unknown",
"5": "dormant",
"6": "not present",
"7": "lower layer down",
"8": "degraded",
}


class EntSensorThresholdRelation(enum.IntEnum):
LESS_THAN = 1
Expand Down Expand Up @@ -427,16 +438,21 @@ def _get_contained_sensor_ids(


def _map_admin_states_container(
if_oid_admin_states: Mapping[str, str],
if_oid_admin_states: Mapping[str, Sequence[str]],
sensor_if_map: Sequence[Sequence[str]],
container: Mapping[str, set[str]],
) -> Mapping[str, str | None]:
admin_states_dict = {}

sensor_oid_admin_status_map = {
sensor_oid.removesuffix(".0"): _CISCO_TEMPERATURE_ADMIN_STATE_MAP.get(
if_oid_admin_states.get(if_ref_oid.split(".")[-1], "")
)
sensor_oid.removesuffix(".0"): [
_CISCO_TEMPERATURE_ADMIN_STATE_MAP.get(
if_oid_admin_states.get(if_ref_oid.split(".")[-1], ["", ""])[0]
),
_CISCO_TEMPERATURE_OPER_STATE_MAP.get(
if_oid_admin_states.get(if_ref_oid.split(".")[-1], ["", ""])[1]
),
]
for [sensor_oid, if_ref_oid] in sensor_if_map
# this was written with the expectation that the entAliasMappingIdentifier always
# points to ifTable. If not, the referenced oid needs to be added to the SNMPTree
Expand Down Expand Up @@ -465,7 +481,10 @@ def _map_admin_states(
# Map admin state of Ethernet ports to sensor_ids of corresponding ethernet port sensors.
# Since the naming schema in the description can differ between interfaces and physical entities
# use the entAliasMappingIdentifier to map between the ifEntry and the entPhysicalEntry
if_oid_admin_states = {if_oid: admin_state for if_oid, if_name, admin_state in admin_states}
if_oid_admin_states = {
if_oid: [admin_state, oper_state]
for if_oid, if_name, admin_state, oper_state in admin_states
}
admin_states_dict = _map_admin_states_container(if_oid_admin_states, sensor_if_map, container)

if len(admin_states_dict) == 0: # fallback if entAliasMapping did not work
Expand Down Expand Up @@ -533,6 +552,7 @@ def _map_admin_states(
OIDEnd(),
OIDCached("2"), # Description of the sensor
OIDCached("7"), # ifAdminStatus
OIDCached("8"), # ifOperStatus
],
),
SNMPTree(
Expand Down Expand Up @@ -638,11 +658,22 @@ def discover_cisco_temperature_dom(params: Mapping[str, Any], section: Section)
_CISCO_TEMPERATURE_ADMIN_STATE_MAP[admin_state]
for admin_state in params.get("admin_states", ["1"])
} | {None}
oper_states_to_discover = {
_CISCO_TEMPERATURE_OPER_STATE_MAP[oper_state]
for oper_state in params.get("operational_states")
} | {None}
for item, attrs in parsed_dom.items():
dev_state = attrs.get("raw_dev_state")
adm_state = attrs.get("admin_state")
if dev_state == "1" and adm_state in admin_states_to_discover:
yield Service(item=item)
try:
dev_state = attrs.get("raw_dev_state")
adm_state, oper_state = attrs.get("admin_state")
if (
dev_state == "1"
and adm_state in admin_states_to_discover
and oper_state in oper_states_to_discover
):
yield Service(item=item)
except TypeError:
continue


def _determine_levels(
Expand Down Expand Up @@ -707,7 +738,10 @@ def check_cisco_temperature_dom(
service_name="DOM %s",
sections=["cisco_temperature"],
discovery_function=discover_cisco_temperature_dom,
discovery_default_parameters={"admin_states": ["1"]},
discovery_default_parameters={
"admin_states": ["1"],
"operational_states": ["1", "2", "3", "4", "5", "6", "7", "8"],
},
discovery_ruleset_name="discovery_cisco_dom_rules",
check_function=check_cisco_temperature_dom,
check_ruleset_name="cisco_dom",
Expand Down
Loading