|
|
@@ -14,10 +14,7 @@ from cmk.agent_based.v2 import (
|
|
|
render,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# JSON parsing
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
def parse_p1(string_table):
|
|
|
flat = list(itertools.chain.from_iterable(string_table))
|
|
|
@@ -39,10 +36,7 @@ agent_section_p1 = AgentSection(
|
|
|
parse_function=parse_p1,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# P1 tariff
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
def discover_p1_tariff(section):
|
|
|
if section is not None and "active_tariff" in section:
|
|
|
@@ -73,10 +67,7 @@ check_plugin_p1_tariff = CheckPlugin(
|
|
|
check_function=check_p1_tariff,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Power
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
POWER_ITEMS = {
|
|
|
"Total": "active_power_w",
|
|
|
@@ -85,13 +76,11 @@ POWER_ITEMS = {
|
|
|
"L3": "active_power_l3_w",
|
|
|
}
|
|
|
|
|
|
-
|
|
|
def discover_p1_power(section):
|
|
|
for item, key in POWER_ITEMS.items():
|
|
|
if key in section:
|
|
|
yield Service(item=item)
|
|
|
|
|
|
-
|
|
|
def check_p1_power(item, section):
|
|
|
key = POWER_ITEMS.get(item)
|
|
|
|
|
|
@@ -115,7 +104,6 @@ def check_p1_power(item, section):
|
|
|
boundaries=(0, None),
|
|
|
)
|
|
|
|
|
|
-
|
|
|
check_plugin_p1_power = CheckPlugin(
|
|
|
name="p1_power",
|
|
|
sections=["p1"],
|
|
|
@@ -124,10 +112,7 @@ check_plugin_p1_power = CheckPlugin(
|
|
|
check_function=check_p1_power,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Voltage
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
VOLTAGE_ITEMS = {
|
|
|
"L1": "active_voltage_l1_v",
|
|
|
@@ -135,13 +120,11 @@ VOLTAGE_ITEMS = {
|
|
|
"L3": "active_voltage_l3_v",
|
|
|
}
|
|
|
|
|
|
-
|
|
|
def discover_p1_voltage(section):
|
|
|
for item, key in VOLTAGE_ITEMS.items():
|
|
|
if key in section:
|
|
|
yield Service(item=item)
|
|
|
|
|
|
-
|
|
|
def check_p1_voltage(item, params, section):
|
|
|
key = VOLTAGE_ITEMS.get(item)
|
|
|
|
|
|
@@ -163,7 +146,6 @@ def check_p1_voltage(item, params, section):
|
|
|
boundaries=(0, 300),
|
|
|
)
|
|
|
|
|
|
-
|
|
|
check_plugin_p1_voltage = CheckPlugin(
|
|
|
name="p1_voltage",
|
|
|
sections=["p1"],
|
|
|
@@ -176,10 +158,7 @@ check_plugin_p1_voltage = CheckPlugin(
|
|
|
check_ruleset_name="p1_voltage",
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Current
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
CURRENT_ITEMS = {
|
|
|
"Total": "active_current_a",
|
|
|
@@ -188,13 +167,11 @@ CURRENT_ITEMS = {
|
|
|
"L3": "active_current_l3_a",
|
|
|
}
|
|
|
|
|
|
-
|
|
|
def discover_p1_current(section):
|
|
|
for item, key in CURRENT_ITEMS.items():
|
|
|
if key in section:
|
|
|
yield Service(item=item)
|
|
|
|
|
|
-
|
|
|
def check_p1_current(item, section):
|
|
|
key = CURRENT_ITEMS.get(item)
|
|
|
|
|
|
@@ -218,7 +195,6 @@ def check_p1_current(item, section):
|
|
|
boundaries=(0, None),
|
|
|
)
|
|
|
|
|
|
-
|
|
|
check_plugin_p1_current = CheckPlugin(
|
|
|
name="p1_current",
|
|
|
sections=["p1"],
|
|
|
@@ -227,10 +203,7 @@ check_plugin_p1_current = CheckPlugin(
|
|
|
check_function=check_p1_current,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Energy import / export
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
ENERGY_ITEMS = {
|
|
|
"Import": {
|
|
|
@@ -245,13 +218,11 @@ ENERGY_ITEMS = {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
-
|
|
|
def discover_p1_energy(section):
|
|
|
for item, keys in ENERGY_ITEMS.items():
|
|
|
if any(key in section for key in keys.values()):
|
|
|
yield Service(item=item)
|
|
|
|
|
|
-
|
|
|
def check_p1_energy(item, section):
|
|
|
keys = ENERGY_ITEMS.get(item)
|
|
|
|
|
|
@@ -301,16 +272,12 @@ check_plugin_p1_energy = CheckPlugin(
|
|
|
check_function=check_p1_energy,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Gas
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
def discover_p1_gas(section):
|
|
|
if "total_gas_m3" in section:
|
|
|
yield Service()
|
|
|
|
|
|
-
|
|
|
def check_p1_gas(section):
|
|
|
value = float(section["total_gas_m3"])
|
|
|
|
|
|
@@ -334,10 +301,7 @@ check_plugin_p1_gas = CheckPlugin(
|
|
|
check_function=check_p1_gas,
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
# Power quality
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
|
POWER_QUALITY_KEYS = {
|
|
|
"Voltage sag L1": "voltage_sag_l1_count",
|
|
|
@@ -350,12 +314,10 @@ POWER_QUALITY_KEYS = {
|
|
|
"Long power failure": "long_power_fail_count",
|
|
|
}
|
|
|
|
|
|
-
|
|
|
def discover_p1_power_quality(section):
|
|
|
if any(key in section for key in POWER_QUALITY_KEYS.values()):
|
|
|
yield Service()
|
|
|
|
|
|
-
|
|
|
def check_p1_power_quality(section):
|
|
|
found = 0
|
|
|
|
|
|
@@ -387,7 +349,6 @@ def check_p1_power_quality(section):
|
|
|
summary="No power-quality counters available",
|
|
|
)
|
|
|
|
|
|
-
|
|
|
check_plugin_p1_power_quality = CheckPlugin(
|
|
|
name="p1_power_quality",
|
|
|
sections=["p1"],
|