Add port of storeonce plugin to CheckMK 2.4.
This commit is contained in:
parent
fbc07dbbfd
commit
0e59597d5d
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
# This is a modification of CheckMK v2.4.0 storeonce_stores.py to support teams
|
||||
|
||||
from collections.abc import Mapping
|
||||
|
||||
from cmk.agent_based.v1 import check_levels as check_levels_v1
|
||||
from cmk.agent_based.v2 import (
|
||||
AgentSection,
|
||||
CheckPlugin,
|
||||
CheckResult,
|
||||
DiscoveryResult,
|
||||
render,
|
||||
Result,
|
||||
Service,
|
||||
State,
|
||||
StringTable,
|
||||
)
|
||||
from cmk.plugins.lib import storeonce
|
||||
|
||||
Section = Mapping[str, Mapping[str, str]]
|
||||
|
||||
def parse_storeonce_stores_team(string_table: StringTable) -> Section:
|
||||
return {
|
||||
"Store {} Store {}".format(data["Store ID"], data["Name"]): data
|
||||
for data in storeonce.parse_storeonce_servicesets(string_table).values()
|
||||
}
|
||||
|
||||
|
||||
agent_section_storeonce_stores_team = AgentSection(
|
||||
name="storeonce_stores_team",
|
||||
parse_function=parse_storeonce_stores_team,
|
||||
)
|
||||
|
||||
|
||||
def discover_storeonce_stores_team(section: Section) -> DiscoveryResult:
|
||||
yield from (Service(item=item) for item in section)
|
||||
|
||||
|
||||
def check_storeonce_stores_team(item: str, section: Section) -> CheckResult:
|
||||
if (values := section.get(item)) is None:
|
||||
return
|
||||
|
||||
yield Result(
|
||||
state=storeonce.STATE_MAP[values["Health Level"]],
|
||||
summary="Status: %s" % values["Status"],
|
||||
)
|
||||
|
||||
yield from check_levels_v1(
|
||||
float(values["Size On Disk"]), metric_name="data_size", label="Size", render_func=render.bytes
|
||||
)
|
||||
|
||||
if "Dedupe Ratio" in values:
|
||||
yield from check_levels_v1(
|
||||
float(values["Dedupe Ratio"]), metric_name="dedup_rate", label="Dedup ratio"
|
||||
)
|
||||
|
||||
description = values.get("Description")
|
||||
if description:
|
||||
yield Result(state=State.OK, summary="Description: %s" % description)
|
||||
|
||||
|
||||
check_plugin_storeonce_stores_team = CheckPlugin(
|
||||
name="storeonce_stores_team",
|
||||
service_name="%s",
|
||||
discovery_function=discover_storeonce_stores_team,
|
||||
check_function=check_storeonce_stores_team,
|
||||
)
|
||||
9442
storeonce/2.4/local/lib/python3/cmk/special_agents/agent_storeonce.py
Executable file
9442
storeonce/2.4/local/lib/python3/cmk/special_agents/agent_storeonce.py
Executable file
File diff suppressed because it is too large
Load Diff
BIN
storeonce/2.4/storeonce-2.0.0.mkp
Executable file
BIN
storeonce/2.4/storeonce-2.0.0.mkp
Executable file
Binary file not shown.
@ -1 +1,4 @@
|
||||
the standard check was modified to monitor federated devices also.
|
||||
The standard check was modified to monitor federated devices also.
|
||||
|
||||
2.0/ appears to be a modification of tree at commit 98fa924ec6a078e8a58ca68ed6052edde81ada56 in the CheckMK repository.
|
||||
2.4/ is a modification of tree at commit 4abde4a41de677e103561e4fb75b81f6ee8b80dd in the CheckMK repository.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user