|
@@ -7,6 +7,7 @@
|
|
# License: GNU General Public License v2
|
|
# License: GNU General Public License v2
|
|
|
|
|
|
import datetime
|
|
import datetime
|
|
|
|
+import math
|
|
from typing import Mapping, Any
|
|
from typing import Mapping, Any
|
|
from cmk.agent_based.v2 import (
|
|
from cmk.agent_based.v2 import (
|
|
AgentSection,
|
|
AgentSection,
|
|
@@ -16,6 +17,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 (
|
|
@@ -26,10 +28,70 @@ from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
uptime_attributes,
|
|
uptime_attributes,
|
|
time_attributes,
|
|
time_attributes,
|
|
time_attributes_ignored,
|
|
time_attributes_ignored,
|
|
- non_graphable_attributes,
|
|
|
|
- total_counter_attributes,
|
|
|
|
- idm_nongraphable_attributes,
|
|
|
|
|
|
+
|
|
)
|
|
)
|
|
|
|
+'''Definition of keys which hold a non-graphable value'''
|
|
|
|
+non_graphable = [
|
|
|
|
+ "arch",
|
|
|
|
+ "average_load",
|
|
|
|
+ "comitted",
|
|
|
|
+ "configuration",
|
|
|
|
+ "containment",
|
|
|
|
+ "connectedToRemoteLoader",
|
|
|
|
+ "downTime",
|
|
|
|
+ "DriverDN",
|
|
|
|
+ "driverSetDN",
|
|
|
|
+ "driver-state",
|
|
|
|
+ "EngineVersion",
|
|
|
|
+ "id",
|
|
|
|
+ "initial",
|
|
|
|
+ "JobDN",
|
|
|
|
+ "lock",
|
|
|
|
+ "name",
|
|
|
|
+ "nextScheduledRun",
|
|
|
|
+ "numberOfDrivers",
|
|
|
|
+ "processors",
|
|
|
|
+ "running",
|
|
|
|
+ "shutDownPending",
|
|
|
|
+ "starting",
|
|
|
|
+ "startOption",
|
|
|
|
+ "startUpOption_auto-start_count",
|
|
|
|
+ "startUpOption_manual_count",
|
|
|
|
+ "startUpOption_disabled_count",
|
|
|
|
+ "state",
|
|
|
|
+ "status",
|
|
|
|
+ "stopped",
|
|
|
|
+ "total",
|
|
|
|
+ "type",
|
|
|
|
+ "uptime",
|
|
|
|
+ "used",
|
|
|
|
+ "version",
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+'''Definition of keys which hold a total counter'''
|
|
|
|
+total_counters = [
|
|
|
|
+ "nrf_identity",
|
|
|
|
+ "nrf_request",
|
|
|
|
+ "jdbc_statement"
|
|
|
|
+ "publisher_add",
|
|
|
|
+ "publisher_add-association",
|
|
|
|
+ "publisher_check-password",
|
|
|
|
+ "publisher_delete",
|
|
|
|
+ "publisher_init-params",
|
|
|
|
+ "publisher_modify",
|
|
|
|
+ "publisher_move",
|
|
|
|
+ "publisher_query",
|
|
|
|
+ "publisher_rename",
|
|
|
|
+ "publisher_remove-association",
|
|
|
|
+ "publisher_service-supported",
|
|
|
|
+ "publisher_status",
|
|
|
|
+ "subscriber_add",
|
|
|
|
+ "subscriber_modify",
|
|
|
|
+ "subscriber_query",
|
|
|
|
+ "subscriber_delete",
|
|
|
|
+ "subscriber_rename",
|
|
|
|
+ "subscriber_modify-password",
|
|
|
|
+]
|
|
|
|
|
|
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()
|
|
@@ -37,8 +99,6 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
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("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:
|
|
if not data:
|
|
return
|
|
return
|
|
for key, value in data.items():
|
|
for key, value in data.items():
|
|
@@ -58,16 +118,39 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
yield Result(state=State(0), notice=f"{key}: {datevalue}", details=f"{key}: {datevalue}")
|
|
yield Result(state=State(0), notice=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), notice=f"{key}: {value}", details=f"{key}: {value}")
|
|
|
|
- if (item_detail + "_" + key) in total_counter_attributes:
|
|
|
|
|
|
+ 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:
|
|
|
|
+ if (item_detail + "_" + key) in total_counters:
|
|
|
|
+ previous_value = value_store.get(key, 0)
|
|
|
|
+ value_store[key] = value
|
|
|
|
+ value_difference = int(value) - int(previous_value)
|
|
|
|
+ yield from check_levels(
|
|
|
|
+ int(math.ceil(value_difference)),
|
|
|
|
+ levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(partialkey, ("fixed", (None, None))),
|
|
|
|
+ label=key,
|
|
|
|
+ metric_name=key,
|
|
|
|
+ notice_only=True,
|
|
|
|
+ )
|
|
|
|
+ else:
|
|
|
|
+ yield from check_levels(
|
|
|
|
+ int(value),
|
|
|
|
+ levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(partialkey, ("fixed", (None, None))),
|
|
|
|
+ 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_counters:
|
|
'''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:
|
|
|
|
|
|
+ elif key in non_graphable:
|
|
continue
|
|
continue
|
|
- elif (item_detail + "_" + key) not in non_graphable_attributes:
|
|
|
|
|
|
+ else:
|
|
'''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)))
|
|
|
|
|