Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUP-20101: Correct Raritan check and add residual current check #755

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion cmk/base/check_legacy_includes/raritan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
# 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 .temperature import check_temperature
from cmk.base.check_legacy_includes.temperature import check_temperature
from cmk.agent_based.v1 import check_levels
from cmk.agent_based.v2 import (
Result,
State,
render,
)


# For raritan devices which support the PDU2-, EMD-, or LHX-MIB

Expand Down Expand Up @@ -46,6 +53,7 @@
"19": ("binary", ""),
"20": ("binary", "Contact"),
"21": ("fanspeed", ""),
"26": ("residual_current", "Residual Current"),
"30": ("", "Other"),
"31": ("", "None"),
}
Expand Down Expand Up @@ -237,3 +245,25 @@ def check_raritan_sensors_temp(item, params, parsed):
dev_status_name=state_readable,
)
return None


def check_raritan_sensors_hum(item, params, parsed):
if item in parsed:
state, state_readable = parsed[item]["state"]
unit = parsed[item]["sensor_unit"]
reading, crit_lower, warn_lower, crit, warn = parsed[item]["sensor_data"]
if params.get('levels'):
warn, crit = params.get('levels')
if params.get('levels_lower'):
warn_lower, crit_lower = params.get('levels_lower')

yield from check_levels(
reading,
metric_name=parsed[item]["sensor_type"],
levels_upper=(warn, crit),
levels_lower=(warn_lower, crit_lower),
render_func=render.percent,
boundaries=(0, 100),
)
yield Result(state=State.OK, summary=f"device status: {state_readable}")
return None
10 changes: 5 additions & 5 deletions cmk/base/legacy_checks/raritan_pdu_plugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

def parse_raritan_pdu_plugs(string_table):
parsed = {}

for outlet_label, outlet_name, outlet_state in string_table:
parsed[outlet_label] = {
"state": raritan_map_state.get(outlet_state, (3, "unknown")),
"outlet_name": outlet_name,
}
if raritan_map_state.get(outlet_state):
parsed[outlet_label] = {
"state": raritan_map_state.get(outlet_state),
"outlet_name": outlet_name,
}
return parsed


Expand Down
4 changes: 3 additions & 1 deletion cmk/base/legacy_checks/raritan_px2_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from cmk.base.check_legacy_includes.raritan import (
check_raritan_sensors,
check_raritan_sensors_temp,
check_raritan_sensors_hum,
inventory_raritan_sensors,
inventory_raritan_sensors_temp,
parse_raritan_sensors,
Expand Down Expand Up @@ -100,7 +101,8 @@ def discover_raritan_px2_sensors_humidity(parsed):
service_name="Humidity %s",
sections=["raritan_px2_sensors"],
discovery_function=discover_raritan_px2_sensors_humidity,
check_function=check_raritan_sensors,
check_function=check_raritan_sensors_hum,
check_ruleset_name="humidity",
)


Expand Down
12 changes: 12 additions & 0 deletions cmk/plugins/raritan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# _____ __ __ _____
# / ____| \ \ / / | __ \
# | (___ \ \ /\ / / | |__) |
# \___ \ \ \/ \/ / | _ /
# ____) | \ /\ / | | \ \
# |_____/ \/ \/ |_| \_\
#
# (c) 2024 SWR
# @author Frank Baier <[email protected]>
#
Loading