|
@@ -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,
|
|
@@ -31,9 +32,33 @@ from cmk_addons.plugins.edirectory_monitor.lib import (
|
|
total_counter_attributes,
|
|
total_counter_attributes,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+total_counters = [
|
|
|
|
+ "Bindings_simpleAuthBinds",
|
|
|
|
+ "Bindings_unAuthBinds",
|
|
|
|
+ "Bindings_bindSecurityErrors",
|
|
|
|
+ "Bindings_strongAuthBinds",
|
|
|
|
+ "Errors_errors",
|
|
|
|
+ "Errors_securityErrors",
|
|
|
|
+ "IncomingOperations_abandonOps",
|
|
|
|
+ "IncomingOperations_addEntryOps",
|
|
|
|
+ "IncomingOperations_compareOps",
|
|
|
|
+ "IncomingOperations_extendedOps",
|
|
|
|
+ "IncomingOperations_inOps",
|
|
|
|
+ "IncomingOperations_listOps",
|
|
|
|
+ "IncomingOperations_wholeSubtreeSearchOps",
|
|
|
|
+ "IncomingOperations_oneLevelSearchOps",
|
|
|
|
+ "IncomingOperations_searchOps",
|
|
|
|
+ "IncomingOperations_modifyRDNOps",
|
|
|
|
+ "IncomingOperations_modifyEntryOps",
|
|
|
|
+ "IncomingOperations_removeEntryOps",
|
|
|
|
+ "IncomingOperations_readOps",
|
|
|
|
+ "OutgoingOperations_chainings",
|
|
|
|
+ "TrafficVolume_inBytes",
|
|
|
|
+ "TrafficVolume_outBytes",
|
|
|
|
+]
|
|
|
|
+
|
|
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)
|
|
@@ -58,27 +83,40 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
|
|
datevalue = convert_timestamp(value)
|
|
datevalue = convert_timestamp(value)
|
|
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 result if above criteria do not apply'''
|
|
warn, crit = params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None)))[1]
|
|
warn, crit = params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None)))[1]
|
|
if warn is not None or crit is not None:
|
|
if warn is not None or crit is not None:
|
|
#print(f"Levels {key} - {warn} - {crit}")
|
|
#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,
|
|
|
|
- )
|
|
|
|
|
|
+ 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(key, ("fixed", (None, None))),
|
|
|
|
+ label=key,
|
|
|
|
+ metric_name=key,
|
|
|
|
+ notice_only=True,
|
|
|
|
+ )
|
|
|
|
+ else:
|
|
|
|
+ yield from check_levels(
|
|
|
|
+ int(math.ceil(value)),
|
|
|
|
+ levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None))),
|
|
|
|
+ label=key,
|
|
|
|
+ metric_name=key,
|
|
|
|
+ notice_only=True,
|
|
|
|
+ )
|
|
else:
|
|
else:
|
|
- yield Result(state=State(0), summary=f"{key}: {value}", details=f"{key}: {value}")
|
|
|
|
- if (item_detail + "_" + key) in total_counter_attributes:
|
|
|
|
|
|
+ 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), math.ceil(value_difference), boundaries=(0, None))
|
|
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), math.ceil(int(value)))
|
|
|
|
|
|
agent_section_edirectory_monitor_ldap = AgentSection(
|
|
agent_section_edirectory_monitor_ldap = AgentSection(
|
|
name="edirectory_monitor_ldap",
|
|
name="edirectory_monitor_ldap",
|