Browse Source

Update 'plugins/edirectory_monitor/agent_based/edirectory_monitor_ldap.py'

Michael Honkoop 5 days ago
parent
commit
d367af9358
1 changed files with 8 additions and 8 deletions
  1. 8 8
      plugins/edirectory_monitor/agent_based/edirectory_monitor_ldap.py

+ 8 - 8
plugins/edirectory_monitor/agent_based/edirectory_monitor_ldap.py

@@ -29,7 +29,6 @@ from cmk_addons.plugins.edirectory_monitor.lib import (
     time_attributes,
     time_attributes_ignored,
     non_graphable_attributes,
-    total_counter_attributes,
 )
 
 total_counters = [
@@ -86,13 +85,12 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
             '''create a result if above criteria do not apply'''
             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}")
                 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)),
+                        int(value_difference),
                         levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(key, ("fixed", (None, None))),
                         label=key,
                         metric_name=key,
@@ -100,23 +98,25 @@ def check_edirectory_items(item: str, params: Mapping[str, Any], section) -> Che
                         )
                 else:
                     yield from check_levels(
-                        int(math.ceil(value)),
+                        int(value),
                         levels_upper=params.get((item.lower()).replace(" ", "_"), {}).get(key, ("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}")
+               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'''
             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 Metric((item_detail + "_" + key), math.ceil(value_difference), boundaries=(0, None))
+            yield Metric(key, math.ceil(int(value_difference)), boundaries=(0, None))
         elif (item_detail + "_" + key) not in non_graphable_attributes:
             '''Only create a metric for graphable values'''
-            yield Metric((item_detail + "_" + key), math.ceil(int(value)))
+            yield Metric(key, math.ceil(int(value)))
 
 agent_section_edirectory_monitor_ldap = AgentSection(
     name="edirectory_monitor_ldap",
@@ -128,6 +128,6 @@ check_plugin_edirectory_monitor_ldap = CheckPlugin(
     service_name="%s",
     discovery_function=discover_edirectory_items,
     check_function=check_edirectory_items,
-    check_default_parameters={"levels_upper": None},
+    check_default_parameters={},
     check_ruleset_name="edirectory_monitor_ldap",
 )