|
@@ -5,6 +5,9 @@
|
|
# License: GNU General Public License v2
|
|
# License: GNU General Public License v2
|
|
|
|
|
|
from typing import Dict
|
|
from typing import Dict
|
|
|
|
+from datetime import datetime
|
|
|
|
+import pytz
|
|
|
|
+import re
|
|
from cmk.agent_based.v2 import (
|
|
from cmk.agent_based.v2 import (
|
|
AgentSection,
|
|
AgentSection,
|
|
CheckPlugin,
|
|
CheckPlugin,
|
|
@@ -13,8 +16,31 @@ from cmk.agent_based.v2 import (
|
|
Result,
|
|
Result,
|
|
Service,
|
|
Service,
|
|
State,
|
|
State,
|
|
|
|
+ Metric,
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+non_graphable = [
|
|
|
|
+ "eDirectorySystemCurrTime",
|
|
|
|
+ "eDirectoryUpTime",
|
|
|
|
+ "eDirectoryAgentVersion",
|
|
|
|
+ "CheckPointThreadStartTime",
|
|
|
|
+ "CheckPointThreadForceStartTime",
|
|
|
|
+ "CheckPointThreadIsForced",
|
|
|
|
+]
|
|
|
|
+
|
|
|
|
+def format_partition_agent(value):
|
|
|
|
+ formatted = re.sub('CN=|OU=|O=|T=', '', value).replace("=", " ")
|
|
|
|
+ return formatted
|
|
|
|
+
|
|
|
|
+def convert_timestamp(value):
|
|
|
|
+ """convert Zulu time to current time in local timezone"""
|
|
|
|
+ utc_dt = datetime.strptime(value, "%Y%m%d%H%M%SZ")
|
|
|
|
+ utc = pytz.utc
|
|
|
|
+ utc_dt = utc.localize(utc_dt)
|
|
|
|
+ local_tz = pytz.timezone(pytz.timezone('local'))
|
|
|
|
+ local_dt = utc_dt.astimezone(local_tz)
|
|
|
|
+ return local_dt
|
|
|
|
+
|
|
def parse_ldap_data(string_table):
|
|
def parse_ldap_data(string_table):
|
|
"""parse one lines of data to dictionary"""
|
|
"""parse one lines of data to dictionary"""
|
|
parsed = {}
|
|
parsed = {}
|
|
@@ -23,8 +49,11 @@ def parse_ldap_data(string_table):
|
|
parsed.setdefault(item, {})
|
|
parsed.setdefault(item, {})
|
|
for _count, data in enumerate(line[1:]):
|
|
for _count, data in enumerate(line[1:]):
|
|
if item == "Agent Partition":
|
|
if item == "Agent Partition":
|
|
|
|
+ #print(format_partition_agent(data))
|
|
continue
|
|
continue
|
|
- key, value=data.split("=")
|
|
|
|
|
|
+ #key, value=format_partition_agent(data).split("#")
|
|
|
|
+ else:
|
|
|
|
+ key, value=data.split("=")
|
|
parsed[item].setdefault(key, value)
|
|
parsed[item].setdefault(key, value)
|
|
return parsed
|
|
return parsed
|
|
|
|
|
|
@@ -41,7 +70,8 @@ def check_edirectory_items(item: str, section) -> CheckResult:
|
|
return
|
|
return
|
|
for key, value in data.items():
|
|
for key, value in data.items():
|
|
yield Result(state=State(0), summary=f"{key}: {value}", details=f"{key}: {value}")
|
|
yield Result(state=State(0), summary=f"{key}: {value}", details=f"{key}: {value}")
|
|
-
|
|
|
|
|
|
+ if key not in non_graphable:
|
|
|
|
+ yield Metric(key, float(value))
|
|
|
|
|
|
agent_section_edirectory_monitor = AgentSection(
|
|
agent_section_edirectory_monitor = AgentSection(
|
|
name="edirectory_monitor",
|
|
name="edirectory_monitor",
|