|
@@ -16,6 +16,7 @@ from cmk.agent_based.v2 import (
|
|
State,
|
|
State,
|
|
Metric,
|
|
Metric,
|
|
get_value_store,
|
|
get_value_store,
|
|
|
|
+ check_levels,
|
|
)
|
|
)
|
|
|
|
|
|
from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
@@ -28,17 +29,17 @@ from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
time_attributes_ignored,
|
|
time_attributes_ignored,
|
|
non_graphable_attributes,
|
|
non_graphable_attributes,
|
|
total_counter_attributes,
|
|
total_counter_attributes,
|
|
- idm_nongraphable_attributes,
|
|
|
|
)
|
|
)
|
|
|
|
|
|
def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> CheckResult:
|
|
def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> CheckResult:
|
|
value_store = get_value_store()
|
|
value_store = get_value_store()
|
|
|
|
+ print(params)
|
|
'''Split the item key and store the last part for making the returned result and/or metric more unique'''
|
|
'''Split the item key and store the last part for making the returned result and/or metric more unique'''
|
|
item_detail = item.split()[-1]
|
|
item_detail = item.split()[-1]
|
|
data = section.get(item)
|
|
data = section.get(item)
|
|
- warn, crit = params.get("levels", ("fixed", (None, None)))[1]
|
|
|
|
|
|
+ #warn, crit = params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None)))[1]
|
|
# The warn and crit you can use than later inside a check_levels function
|
|
# The warn and crit you can use than later inside a check_levels function
|
|
- # print(f"Levels - {warn} - {crit}")
|
|
|
|
|
|
+ # print(f"Levels - {warn} - {crit}")
|
|
if not data:
|
|
if not data:
|
|
return
|
|
return
|
|
for key, value in data.items():
|
|
for key, value in data.items():
|
|
@@ -58,15 +59,23 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
yield Result(state=State(0), summary=f"{key}: {datevalue}", details=f"{key}: {datevalue}")
|
|
yield Result(state=State(0), summary=f"{key}: {datevalue}", details=f"{key}: {datevalue}")
|
|
else:
|
|
else:
|
|
'''create a default result if above criteria do not apply'''
|
|
'''create a default result if above criteria do not apply'''
|
|
- yield Result(state=State(0), summary=f"{key}: {value}", details=f"{key}: {value}")
|
|
|
|
|
|
+ warn, crit = params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None)))[1]
|
|
|
|
+ if warn is not None or crit is not None:
|
|
|
|
+ #print(f"Levels {key} - {warn} - {crit}")
|
|
|
|
+ yield from check_levels(
|
|
|
|
+ int(value),
|
|
|
|
+ levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None))),
|
|
|
|
+ label=key,
|
|
|
|
+ metric_name=key,
|
|
|
|
+ )
|
|
|
|
+ else:
|
|
|
|
+ yield Result(state=State(0), summary=f"{key}: {value}", details=f"{key}: {value}")
|
|
if (item_detail + "_" + key) in total_counter_attributes:
|
|
if (item_detail + "_" + key) in total_counter_attributes:
|
|
'''create a metric which is the difference between previous check value and current check value'''
|
|
'''create a metric which is the difference between previous check value and current check value'''
|
|
previous_value = value_store.get(key, 0)
|
|
previous_value = value_store.get(key, 0)
|
|
value_store[key] = value
|
|
value_store[key] = value
|
|
value_difference = int(value) - int(previous_value)
|
|
value_difference = int(value) - int(previous_value)
|
|
yield Metric((item_detail + "_" + key), abs(value_difference), boundaries=(0, None))
|
|
yield Metric((item_detail + "_" + key), abs(value_difference), boundaries=(0, None))
|
|
- elif item.startswith("IDM") and key in idm_nongraphable_attributes:
|
|
|
|
- continue
|
|
|
|
elif (item_detail + "_" + key) not in non_graphable_attributes:
|
|
elif (item_detail + "_" + key) not in non_graphable_attributes:
|
|
'''Only create a metric for graphable values'''
|
|
'''Only create a metric for graphable values'''
|
|
yield Metric((item_detail + "_" + key), abs(int(value)))
|
|
yield Metric((item_detail + "_" + key), abs(int(value)))
|
|
@@ -81,6 +90,6 @@ check_plugin_edirectory_monitor_ldap = CheckPlugin(
|
|
service_name="%s",
|
|
service_name="%s",
|
|
discovery_function=discover_edirectory_items,
|
|
discovery_function=discover_edirectory_items,
|
|
check_function=check_edirectory_items,
|
|
check_function=check_edirectory_items,
|
|
- check_default_parameters={},
|
|
|
|
|
|
+ check_default_parameters={"levels_upper": None},
|
|
check_ruleset_name="edirectory_monitor_ldap",
|
|
check_ruleset_name="edirectory_monitor_ldap",
|
|
)
|
|
)
|