-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AudioCodes Temperature: Add new check plugin
CMK-20914 Change-Id: Idfeeab5be400919a73bebe9138d3b028efff1ea8
- Loading branch information
Showing
7 changed files
with
322 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk 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 collections.abc import Mapping | ||
|
||
from cmk.agent_based.v2 import ( | ||
OIDEnd, | ||
SimpleSNMPSection, | ||
SNMPTree, | ||
StringTable, | ||
) | ||
|
||
from .lib import DETECT_AUDIOCODES | ||
|
||
|
||
def parse_module_names(string_table: StringTable) -> Mapping[str, str] | None: | ||
if not string_table: | ||
return None | ||
|
||
return {module[0]: module[1] for module in string_table} | ||
|
||
|
||
snmp_section_audiocodes_module_names = SimpleSNMPSection( | ||
name="audiocodes_module_names", | ||
detect=DETECT_AUDIOCODES, | ||
fetch=SNMPTree( | ||
base=".1.3.6.1.2.1.47.1.1.1.1", | ||
oids=[ | ||
OIDEnd(), | ||
"2", | ||
], | ||
), | ||
parse_function=parse_module_names, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk 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 collections.abc import Mapping | ||
|
||
from cmk.agent_based.v2 import ( | ||
CheckPlugin, | ||
CheckResult, | ||
DiscoveryResult, | ||
OIDEnd, | ||
Result, | ||
Service, | ||
SimpleSNMPSection, | ||
SNMPTree, | ||
State, | ||
StringTable, | ||
) | ||
from cmk.plugins.lib.temperature import check_temperature, TempParamDict | ||
|
||
from .lib import data_by_item, DETECT_AUDIOCODES | ||
|
||
|
||
def parse_audiocodes_temperature(string_table: StringTable) -> Mapping[str, float] | None: | ||
if not string_table: | ||
return None | ||
|
||
return {module[0]: float(module[1]) for module in string_table} | ||
|
||
|
||
snmp_section_audiocodes_temperature = SimpleSNMPSection( | ||
name="audiocodes_temperature", | ||
detect=DETECT_AUDIOCODES, | ||
fetch=SNMPTree( | ||
base=".1.3.6.1.4.1.5003.9.10.10.4.21.1", | ||
oids=[ | ||
OIDEnd(), | ||
"11", # acSysModuleTemperature | ||
], | ||
), | ||
parse_function=parse_audiocodes_temperature, | ||
) | ||
|
||
|
||
def discover_audiocodes_temperature( | ||
section_audiocodes_module_names: Mapping[str, str] | None, | ||
section_audiocodes_temperature: Mapping[str, float] | None, | ||
) -> DiscoveryResult: | ||
if not section_audiocodes_module_names or not section_audiocodes_temperature: | ||
return | ||
|
||
yield from ( | ||
Service(item=item) | ||
for item in data_by_item( | ||
section_audiocodes_module_names, | ||
section_audiocodes_temperature, | ||
) | ||
) | ||
|
||
|
||
def check_audiocodes_temperature( | ||
item: str, | ||
params: TempParamDict, | ||
section_audiocodes_module_names: Mapping[str, str] | None, | ||
section_audiocodes_temperature: Mapping[str, float] | None, | ||
) -> CheckResult: | ||
if not section_audiocodes_temperature or not section_audiocodes_module_names: | ||
return | ||
|
||
if ( | ||
module_temp := data_by_item( | ||
section_audiocodes_module_names, | ||
section_audiocodes_temperature, | ||
).get(item) | ||
) is None: | ||
return | ||
|
||
if module_temp == -1: | ||
yield Result( | ||
state=State.OK, | ||
summary="Temperature is not available", | ||
) | ||
return | ||
|
||
yield from check_temperature( | ||
reading=module_temp, | ||
params=params, | ||
) | ||
|
||
|
||
check_plugin_audiocodes_temperature = CheckPlugin( | ||
name="audiocodes_temperature", | ||
service_name="AudioCodes Temperature %s", | ||
sections=["audiocodes_module_names", "audiocodes_temperature"], | ||
discovery_function=discover_audiocodes_temperature, | ||
check_function=check_audiocodes_temperature, | ||
check_default_parameters={}, | ||
check_ruleset_name="temperature", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
title: AudioCodes: Temperature | ||
agents: snmp | ||
catalog: agentless | ||
license: GPLv2 | ||
distribution: check_mk | ||
description: | ||
This check monitors the temperature of every module in an AudioCodes device. | ||
|
||
discovery: | ||
One service is created for every module. |
Oops, something went wrong.