|
@@ -25,22 +25,29 @@ from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
|
discover_edirectory_items,
|
|
|
parse_ldap_data,
|
|
|
ignored_items,
|
|
|
- uptime_attributes,
|
|
|
+# uptime_attributes,
|
|
|
time_attributes,
|
|
|
time_attributes_ignored,
|
|
|
non_graphable_attributes,
|
|
|
total_counter_attributes,
|
|
|
- idm_nongraphable_attributes,
|
|
|
)
|
|
|
+'''Definition of keys which hold an uptime value'''
|
|
|
+uptime_attributes = [
|
|
|
+ "Status_eDirectoryUpTime",
|
|
|
+]
|
|
|
+
|
|
|
+'''Definition of keys which hold a non-graphable value'''
|
|
|
+non_graphable = [
|
|
|
+ "Status_eDirectorySystemCurrTime",
|
|
|
+ "Status_eDirectoryUpTime",
|
|
|
+ "Status_eDirectoryAgentVersion",
|
|
|
+]
|
|
|
|
|
|
def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> CheckResult:
|
|
|
value_store = get_value_store()
|
|
|
'''Split the item key and store the last part for making the returned result and/or metric more unique'''
|
|
|
item_detail = item.split()[-1]
|
|
|
data = section.get(item)
|
|
|
- warn, crit = params.get("levels", ("fixed", (None, None)))[1]
|
|
|
- # The warn and crit you can use than later inside a check_levels function
|
|
|
- # print(f"Levels - {warn} - {crit}")
|
|
|
if not data:
|
|
|
return
|
|
|
for key, value in data.items():
|
|
@@ -63,10 +70,11 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
|
partialkey = key.split(".")[0]
|
|
|
warn, crit = params.get((item.lower()).replace(" ", "_"), {}).get(partialkey, ("fixed", (None, None)))[1]
|
|
|
if warn is not None or crit is not None:
|
|
|
- #print(f"Levels {key} - {warn} - {crit}")
|
|
|
if (item_detail + "_" + key) in total_counter_attributes:
|
|
|
previous_value = value_store.get(key, 0)
|
|
|
value_store[key] = value
|
|
|
+ if (previous_value > value):
|
|
|
+ previous_value = 0
|
|
|
value_difference = int(value) - int(previous_value)
|
|
|
yield from check_levels(
|
|
|
int(math.ceil(value_difference)),
|
|
@@ -74,7 +82,7 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
|
label=key,
|
|
|
metric_name=key,
|
|
|
notice_only=True,
|
|
|
- )
|
|
|
+ )
|
|
|
else:
|
|
|
yield from check_levels(
|
|
|
int(value),
|
|
@@ -82,7 +90,7 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
|
label=key,
|
|
|
metric_name=key,
|
|
|
notice_only=True,
|
|
|
- )
|
|
|
+ )
|
|
|
else:
|
|
|
yield Result(state=State(0), notice=f"{key}: {value}", details=f"{key}: {value}")
|
|
|
if (item_detail + "_" + key) in total_counter_attributes:
|
|
@@ -98,7 +106,7 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
|
agent_section_edirectory_monitor_agent = AgentSection(
|
|
|
name="edirectory_monitor_agent",
|
|
|
parse_function=parse_ldap_data,
|
|
|
- )
|
|
|
+)
|
|
|
|
|
|
check_plugin_edirectory_monitor_agent = CheckPlugin(
|
|
|
name="edirectory_monitor_agent",
|