Module: check_mk
Branch: master
Commit: bf851cab402f3dc455728d87afc35c45ff12ac7f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf851cab402f3d…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Fri Mar 1 16:02:09 2019 +0100
7045 alcatel_power_aos7: Support for new switches
This werk adds power supply monitoring (equivalent to alcatel_power) support
for the new switch devices running at least AOS7.
CMK-1775
Change-Id: Ic546c1e5447c2019495c401bba7c77672f78270a
---
.werks/7045 | 13 ++++
checkman/alcatel_power_aos7 | 27 +++++++
checks/alcatel_power_aos7 | 89 ++++++++++++++++++++++
.../generictests/datasets/alcatel_power_aos7.py | 34 +++++++++
4 files changed, 163 insertions(+)
diff --git a/.werks/7045 b/.werks/7045
new file mode 100644
index 0000000..649cbd1
--- /dev/null
+++ b/.werks/7045
@@ -0,0 +1,13 @@
+Title: alcatel_power_aos7: Support for new switches
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1551451576
+Class: feature
+
+This werk adds power supply monitoring (equivalent to alcatel_power) support
+for the new switch devices running at least AOS7.
+
+CMK-1775
diff --git a/checkman/alcatel_power_aos7 b/checkman/alcatel_power_aos7
new file mode 100644
index 0000000..4d67a47
--- /dev/null
+++ b/checkman/alcatel_power_aos7
@@ -0,0 +1,27 @@
+title: Alcatel switches: Power Supplies
+agents: snmp
+catalog: hw/network/alcatel
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the status of power supplies in Alcatel switches running
+ operating system AOS7 or higher. Please consider that this check does not
+ behave like {alcatel_power} for Alcatel switches running operating system
+ AOS6 or lower.
+
+ Check status:
+ - {OK} in case the monitored value is one of:
+ up, master
+ - {WARN} in case the monitored value is one of:
+ testing, secondary, idle, pwrsave
+ - {CRIT} in case the monitored value is one of:
+ down, unpowered
+ - {UNKNOWN} in case the monitored value is one of:
+ unknown
+
+item:
+ The ID of the power supply as output from the SNMP agent.
+
+inventory:
+ One check is created for each present power supply.
+
diff --git a/checks/alcatel_power_aos7 b/checks/alcatel_power_aos7
new file mode 100644
index 0000000..5dba3ba
--- /dev/null
+++ b/checks/alcatel_power_aos7
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2019 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+alcatel_power_aos7_operability_to_status_mapping = {
+ '1': "up",
+ '2': "down",
+ '3': "testing",
+ '4': "unknown",
+ '5': "secondary",
+ '6': "not present", # no check status required
+ '7': "unpowered",
+ '8': "master",
+ '9': "idle",
+ '10': "power save",
+}
+
+alcatel_power_aos7_no_power_supply = "no power supply"
+
+alcatel_power_aos7_power_type_mapping = {
+ '0': alcatel_power_aos7_no_power_supply,
+ '1': "AC",
+ '2': "DC",
+}
+
+PowerSupplyEntry = collections.namedtuple('PowerSupplyEntry',
'status_readable power_supply_type')
+
+
+def parse_alcatel_power_aos7(info):
+ return {
+ item: PowerSupplyEntry(
+ alcatel_power_aos7_operability_to_status_mapping[operability_status],
+ alcatel_power_aos7_power_type_mapping[power_supply_type],
+ ) for (item, operability_status, power_supply_type) in info
+ }
+
+
+@discover
+def inventory_alcatel_power_aos7(_oidend, device):
+ return (device.power_supply_type != alcatel_power_aos7_no_power_supply and
+ device.status_readable != "not present")
+
+
+@get_parsed_item_data
+def check_alcatel_power_aos7(item, _no_params, device):
+ if device.status_readable == 'up':
+ status = 0
+ else:
+ status = 2
+ yield status, "[%s] Status: %s" % (device.power_supply_type,
device.status_readable)
+
+
+check_info["alcatel_power_aos7"] = {
+ "parse_function": parse_alcatel_power_aos7,
+ "check_function": check_alcatel_power_aos7,
+ "inventory_function": inventory_alcatel_power_aos7,
+ "service_description": "Power Supply %s",
+ "snmp_scan_function": alcatel_new_networking_products_scan_function,
+ "snmp_info": (
+ ".1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1", # MIB object
"chasEntPhysicalEntry"
+ [
+ OID_END,
+ 2, # MIB object "chasEntPhysOperStatus"
+ 35, # MIB object "chasEntPhysPowerType"
+ ]),
+ "includes": ["alcatel.include"],
+}
diff --git a/tests/unit/checks/generictests/datasets/alcatel_power_aos7.py
b/tests/unit/checks/generictests/datasets/alcatel_power_aos7.py
new file mode 100644
index 0000000..b2c5bb8
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/alcatel_power_aos7.py
@@ -0,0 +1,34 @@
+#yapf: disable
+
+
+checkname = 'alcatel_power_aos7'
+
+
+info = [[u'1', u'1', u'1'],
+ [u'2', u'2', u'1'],
+ [u'3', u'3', u'1'],
+ [u'4', u'4', u'1'],
+ [u'5', u'5', u'0'],
+ [u'6', u'6', u'0'],
+ [u'7', u'7', u'0'],
+ [u'8', u'8', u'2'],
+ [u'9', u'9', u'2'],
+ [u'10', u'10', u'2']]
+
+
+discovery = {'': [(u'1', {}),
+ (u'10', {}),
+ (u'2', {}),
+ (u'3', {}),
+ (u'4', {}),
+ (u'8', {}),
+ (u'9', {})]}
+
+
+checks = {'': [(u'1', {}, [(0, '[AC] Status: up', [])]),
+ (u'10', {}, [(2, '[DC] Status: power save', [])]),
+ (u'2', {}, [(2, '[AC] Status: down', [])]),
+ (u'3', {}, [(2, '[AC] Status: testing', [])]),
+ (u'4', {}, [(2, '[AC] Status: unknown', [])]),
+ (u'8', {}, [(2, '[DC] Status: master', [])]),
+ (u'9', {}, [(2, '[DC] Status: idle', [])])]}