65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
|
|
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
|
|
# conditions defined in the file COPYING, which is part of this source code package.
|
|
from typing import Mapping, Any
|
|
from .agent_based_api.v1 import check_levels, equals, register, Service, SNMPTree, get_value_store, all_of, exists
|
|
from .agent_based_api.v1.type_defs import CheckResult, DiscoveryResult, StringTable
|
|
from .utils.humidity import check_humidity
|
|
|
|
CheckParams = Mapping[str, Any]
|
|
|
|
def parse_clever_pdu_humidity_120(string_table: StringTable):
|
|
data=string_table[0]
|
|
parsed = {}
|
|
parsed = {
|
|
"Master Humidity" : int(data[0]),
|
|
}
|
|
return parsed
|
|
|
|
|
|
|
|
register.snmp_section(
|
|
name="clever_pdu_humidity_120",
|
|
parsed_section_name="clever_pdu_humidity_120",
|
|
parse_function=parse_clever_pdu_humidity_120,
|
|
detect=all_of(
|
|
equals(
|
|
".1.3.6.1.2.1.1.2.0",
|
|
".1.3.6.1.4.1.30966",
|
|
),
|
|
exists(".1.3.6.1.4.1.30966.10.3.2.70.0"),
|
|
),
|
|
fetch=SNMPTree(
|
|
".1.3.6.1.4.1.30966.10.3.2",
|
|
[
|
|
"14", # mHumidity
|
|
],
|
|
),
|
|
)
|
|
|
|
|
|
def discover_clever_pdu_humidity_120(section) -> DiscoveryResult:
|
|
if section.get("Master Humidity") == 0:
|
|
return
|
|
else:
|
|
yield from (Service(item=item) for item in section)
|
|
|
|
|
|
def check_clever_pdu_humidity_120(item, params: CheckParams, section) -> CheckResult:
|
|
yield from check_humidity(
|
|
section.get("Master Humidity"),
|
|
params,
|
|
)
|
|
|
|
register.check_plugin(
|
|
name="clever_pdu_humidity_120",
|
|
service_name="%s",
|
|
discovery_function=discover_clever_pdu_humidity_120,
|
|
check_function=check_clever_pdu_humidity_120,
|
|
check_ruleset_name="humidity",
|
|
check_default_parameters={},
|
|
|
|
)
|