diff --git a/agent_based/cisco_asyncos_cpu.py b/agent_based/cisco_asyncos_cpu.py index 1ad56b159c62ddb4da7ef62b483c84f207c95c5f..5822be0e8edda0866b4a089b7f15abb11758074d 100644 --- a/agent_based/cisco_asyncos_cpu.py +++ b/agent_based/cisco_asyncos_cpu.py @@ -18,15 +18,9 @@ from .agent_based_api.v1.type_defs import ( from .agent_based_api.v1 import ( register, Service, - equals, - Result, check_levels, - State, SNMPTree, contains, - startswith, - all_of, - any_of, ) diff --git a/agent_based/cisco_asyncos_fan.py b/agent_based/cisco_asyncos_fan.py new file mode 100644 index 0000000000000000000000000000000000000000..13363dc0e311fc5cae4d21964e8a80acfa3f7d74 --- /dev/null +++ b/agent_based/cisco_asyncos_fan.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2020-02-10 + +# +# monitors status Cisco IronPort Appliances (ESA/SMA/WSA) fan sensors +# Tested with: C380, M380, C370, M670, S370 +# +# 2021-03-21: rewrite for CMK 2.0 +# +# sample snmpwalk +# .1.3.6.1.4.1.15497.1.1.1.10.1.1.1 = INTEGER: 1 +# .1.3.6.1.4.1.15497.1.1.1.10.1.1.2 = INTEGER: 2 +# .1.3.6.1.4.1.15497.1.1.1.10.1.1.3 = INTEGER: 3 +# .1.3.6.1.4.1.15497.1.1.1.10.1.1.4 = INTEGER: 4 +# .1.3.6.1.4.1.15497.1.1.1.10.1.2.1 = Gauge32: 3600 +# .1.3.6.1.4.1.15497.1.1.1.10.1.2.2 = Gauge32: 3600 +# .1.3.6.1.4.1.15497.1.1.1.10.1.2.3 = Gauge32: 3600 +# .1.3.6.1.4.1.15497.1.1.1.10.1.2.4 = Gauge32: 3480 +# .1.3.6.1.4.1.15497.1.1.1.10.1.3.1 = STRING: FAN 1 +# .1.3.6.1.4.1.15497.1.1.1.10.1.3.2 = STRING: FAN 2 +# .1.3.6.1.4.1.15497.1.1.1.10.1.3.3 = STRING: FAN 3 +# .1.3.6.1.4.1.15497.1.1.1.10.1.3.4 = STRING: FAN 4 +# +# ASYNCOS-MAIL-MIB::fanIndex.1 = INTEGER: 1 +# ASYNCOS-MAIL-MIB::fanIndex.2 = INTEGER: 2 +# ASYNCOS-MAIL-MIB::fanIndex.3 = INTEGER: 3 +# ASYNCOS-MAIL-MIB::fanIndex.4 = INTEGER: 4 +# ASYNCOS-MAIL-MIB::fanRPMs.1 = Gauge32: 3600 +# ASYNCOS-MAIL-MIB::fanRPMs.2 = Gauge32: 3600 +# ASYNCOS-MAIL-MIB::fanRPMs.3 = Gauge32: 3600 +# ASYNCOS-MAIL-MIB::fanRPMs.4 = Gauge32: 3480 +# ASYNCOS-MAIL-MIB::fanName.1 = STRING: FAN 1 +# ASYNCOS-MAIL-MIB::fanName.2 = STRING: FAN 2 +# ASYNCOS-MAIL-MIB::fanName.3 = STRING: FAN 3 +# ASYNCOS-MAIL-MIB::fanName.4 = STRING: FAN 4 +# + +from typing import Dict, List + +from .agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +from .agent_based_api.v1 import ( + register, + Service, + check_levels, + State, + SNMPTree, + contains, +) + +# +# [[['6400', 'FAN 1'], ['6300', 'FAN 2'], ['6400', 'FAN 3'], ['6400', 'FAN 4'], ['6400', 'FAN 5'], ['6800', 'FAN 6']]] +# + +def parse_cisco_asyncos_fan(string_table: List[StringTable]) -> dict: + sensors = {} + for sensor in string_table[0]: + try: + value, item = sensor + if item.startswith('FAN '): + item = item.replace('FAN ', '') + sensors.update({item: int(value)}) + except (ValueError, IndexError): + pass + return sensors + + +def discovery_cisco_asyncos_fan(section: Dict) -> DiscoveryResult: + for key in section.keys(): + yield Service(item=key) + + +def check_cisco_asyncos_fan(item, params, section) -> CheckResult: + try: + value = section[item] + + yield from check_levels( + value, + label='Speed', + levels_lower=params.get('lower', None), + levels_upper=params.get('upper', None), + metric_name='fan' if params.get('output_metrics') else None, + render_func=lambda v: '%s RPM' % str(v), + ) + + except KeyError: + pass + + +register.snmp_section( + name='cisco_asyncos_fan', + parse_function=parse_cisco_asyncos_fan, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.15497.1.1.1.10.1', # ASYNCOS-MAIL-MIB::fanEntry + oids=[ + '2', # fanRPMs + '3', # fanName + ] + ), + ], + detect=contains('.1.3.6.1.2.1.1.1.0', 'AsyncOS'), +) + +register.check_plugin( + name='cisco_asyncos_fan', + service_name='Fan %s', + discovery_function=discovery_cisco_asyncos_fan, + check_function=check_cisco_asyncos_fan, + check_default_parameters={}, + check_ruleset_name='hw_fans' +) diff --git a/agent_based/cisco_asyncos_mem.py b/agent_based/cisco_asyncos_mem.py index b4ddf2373032697114e5f1a9fa21c0d094e5fea8..55f19f0e98a1a5d63850baa90e53ea64bb756af3 100644 --- a/agent_based/cisco_asyncos_mem.py +++ b/agent_based/cisco_asyncos_mem.py @@ -28,15 +28,9 @@ from .agent_based_api.v1.type_defs import ( from .agent_based_api.v1 import ( register, Service, - equals, - Result, check_levels, - State, SNMPTree, contains, - startswith, - all_of, - any_of, ) diff --git a/agent_based/cisco_asyncos_power.py b/agent_based/cisco_asyncos_power.py new file mode 100644 index 0000000000000000000000000000000000000000..d63ef493ccd8b12234a58fff0361e55f80b345b8 --- /dev/null +++ b/agent_based/cisco_asyncos_power.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# License: GNU General Public License v2 +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2020-02-10 +# +# monitors status power supplies of Cisco IronPort Appliances (ESA/SMA/WSA) +# Tested with: C380, M380, C370, M670, S370 +# +# 2021-03-21: rewrite for CMK 2.0 +# +# sample snmpwalk +# .1.3.6.1.4.1.15497.1.1.1.8.1.1.1 = INTEGER: 1 +# .1.3.6.1.4.1.15497.1.1.1.8.1.1.2 = INTEGER: 2 +# .1.3.6.1.4.1.15497.1.1.1.8.1.2.1 = INTEGER: 2 +# .1.3.6.1.4.1.15497.1.1.1.8.1.2.2 = INTEGER: 2 +# .1.3.6.1.4.1.15497.1.1.1.8.1.3.1 = INTEGER: 1 +# .1.3.6.1.4.1.15497.1.1.1.8.1.3.2 = INTEGER: 1 +# .1.3.6.1.4.1.15497.1.1.1.8.1.4.1 = STRING: PS 1 +# .1.3.6.1.4.1.15497.1.1.1.8.1.4.2 = STRING: PS 2 +# +# ASYNCOS-MAIL-MIB::powerSupplyIndex.1 = INTEGER: 1 +# ASYNCOS-MAIL-MIB::powerSupplyIndex.2 = INTEGER: 2 +# ASYNCOS-MAIL-MIB::powerSupplyStatus.1 = INTEGER: powerSupplyHealthy(2) +# ASYNCOS-MAIL-MIB::powerSupplyStatus.2 = INTEGER: powerSupplyHealthy(2) +# ASYNCOS-MAIL-MIB::powerSupplyRedundancy.1 = INTEGER: powerSupplyRedundancyOK(1) +# ASYNCOS-MAIL-MIB::powerSupplyRedundancy.2 = INTEGER: powerSupplyRedundancyOK(1) +# ASYNCOS-MAIL-MIB::powerSupplyName.1 = STRING: PS 1 +# ASYNCOS-MAIL-MIB::powerSupplyName.2 = STRING: PS 2 +# + +from typing import Dict, List, NamedTuple + +from .agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +from .agent_based_api.v1 import ( + register, + Service, + Result, + State, + SNMPTree, + contains, +) + + +class CiscoAsyncosPowersupply(NamedTuple): + redundancy: State + state: State + redundancy_readable: str + state_readable: str + + +# +# [[['2', '1', 'PS 1'], ['2', '1', 'PS 2']]] +# +def parse_cisco_asyncos_power(string_table: List[StringTable]) -> dict: + def get_ps_state(st: str): + state = { + '1': (State.WARN, 'not installed'), + '2': (State.OK, 'healthy'), + '3': (State.CRIT, 'no AC'), + '4': (State.CRIT, 'faulty'), + } + return state.get(st) + + def get_ps_redundancy(st: str): + redundancy = { + '1': (State.OK, 'OK'), + '2': (State.CRIT, 'redundancy lost'), + } + return redundancy.get(st) + + sensors = {} + + for sensor in string_table[0]: + try: + state, redundancy, item = sensor + if item.startswith('PS '): + item = item.replace('PS ', '') + + state, state_readable = get_ps_state(state) + redundancy, redundancy_readable = get_ps_redundancy(redundancy) + + sensors.update({item: CiscoAsyncosPowersupply( + state=state, + state_readable=state_readable, + redundancy=redundancy, + redundancy_readable=redundancy_readable, + )}) + except (ValueError, IndexError): + pass + return sensors + + +# +# { +# '1': CiscoAsyncosPowersupply(redundancy=<State.OK: 0>, state=<State.OK: 0>, redundancy_readable='OK', state_readable='healthy'), +# '2': CiscoAsyncosPowersupply(redundancy=<State.OK: 0>, state=<State.OK: 0>, redundancy_readable='OK', state_readable='healthy') +# } +# + +def discovery_cisco_asyncos_power(section: Dict) -> DiscoveryResult: + for key in section.keys(): + yield Service(item=key) + + +def check_cisco_asyncos_power(item, section) -> CheckResult: + try: + sensor = section[item] + + yield Result(state=sensor.state, summary='Status: %s' % sensor.state_readable) + yield Result(state=sensor.redundancy, summary='Redundancy: %s' % sensor.redundancy_readable) + + except KeyError: + pass + + +register.snmp_section( + name='cisco_asyncos_power', + parse_function=parse_cisco_asyncos_power, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.15497.1.1.1.8.1', # ASYNCOS-MAIL-MIB::powerSupplyEntry + oids=[ + '2', # powerSupplyStatus + '3', # powerSupplyRedundancy + '4', # powerSupplyName + ] + ), + ], + detect=contains('.1.3.6.1.2.1.1.1.0', 'AsyncOS'), +) + +register.check_plugin( + name='cisco_asyncos_power', + service_name='Power Supply %s', + discovery_function=discovery_cisco_asyncos_power, + check_function=check_cisco_asyncos_power, + # check_default_parameters={}, +) diff --git a/agent_based/cisco_asyncos_temp.py b/agent_based/cisco_asyncos_temp.py index 2b26886dbfde085d1d5c3b6b615681a58410be9e..a8b476951c5e479a2922425985ea42a049f88fbf 100644 --- a/agent_based/cisco_asyncos_temp.py +++ b/agent_based/cisco_asyncos_temp.py @@ -33,21 +33,14 @@ from .agent_based_api.v1.type_defs import ( from .agent_based_api.v1 import ( register, Service, - equals, - Result, check_levels, - State, SNMPTree, contains, - startswith, - all_of, - any_of, ) from .utils.temperature import ( check_temperature, TempParamType, - to_celsius, ) diff --git a/checks/cisco_asyncos.include b/checks/cisco_asyncos.include deleted file mode 100644 index dedc66859dddb20d81c645c58932520ea1349533..0000000000000000000000000000000000000000 --- a/checks/cisco_asyncos.include +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Author: Th.L. -# Date: 10-02-2020 -# -# include for Cisco IronPort appliances -# -# 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- -# ails. 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. -# -# - -# -# find Cisco IronPort appliance by sysdescription -# -# OMD[cmk16x]:~/local/share/check_mk/checks$ snmpwalk -v2c -c public localhost sysDesc -# SNMPv2-MIB::sysDescr.0 = STRING: Cisco IronPort Model C380, AsyncOS Version: 12.5.1-037, Build Date: 2019-12-06, Serial #: E4AA5DAD515E-FCH1938V2J7 - -# OMD[cmk16x]:~/local/share/check_mk/checks$ snmpwalk -v2c -c public localhost sysDesc -# SNMPv2-MIB::sysDescr.0 = STRING: Cisco Model S370, AsyncOS Version: 9.0.1-162, Build Date: 2016-02-18, Serial #: 848F69E9A847-7QP2TW1 - -def scan_cisco_asyncos(oid): - if oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1: - return True -# -# diff --git a/checks/cisco_asyncos_bandwidth b/checks/cisco_asyncos_bandwidth index a1ac94e6ad7e28314f110230294649bc9a40d91d..5829e7b7652274aad153b6ec36abd1afa2261b24 100644 --- a/checks/cisco_asyncos_bandwidth +++ b/checks/cisco_asyncos_bandwidth @@ -58,6 +58,7 @@ check_info['cisco_asyncos_bandwidth'] = { '3', # cacheBwidthTotal1hrMean '5', # cacheBwidthTotal1dayMean ]), - 'snmp_scan_function': scan_cisco_asyncos, - 'includes': ['cisco_asyncos.include'], + 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, + # 'snmp_scan_function': scan_cisco_asyncos, + # 'includes': ['cisco_asyncos.include'], } diff --git a/checks/cisco_asyncos_cache b/checks/cisco_asyncos_cache index c376fe437889c6c51b16b323377364fa245aed5d..a52a3b95fbf24737d3b0844b5c7c862a0cb6378e 100644 --- a/checks/cisco_asyncos_cache +++ b/checks/cisco_asyncos_cache @@ -63,6 +63,7 @@ check_info['cisco_asyncos_cache'] = { '8.1', # cacheMissRespTimeNow '9.1', # cacheTotalRespTimeNow ]), - 'snmp_scan_function': scan_cisco_asyncos, - 'includes': ['cisco_asyncos.include'], + 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, + # 'snmp_scan_function': scan_cisco_asyncos, + # 'includes': ['cisco_asyncos.include'], } diff --git a/checks/cisco_asyncos_conn b/checks/cisco_asyncos_conn index 540498045f95371321a2046f322ba2c4f839f530..a66954bb91abdad7f7df05a9bfee41241d34fa67 100644 --- a/checks/cisco_asyncos_conn +++ b/checks/cisco_asyncos_conn @@ -58,6 +58,7 @@ check_info['cisco_asyncos_conn'] = { '8', # cacheClientTotalConns '9', # cacheClientMaxConns ]), - 'snmp_scan_function': scan_cisco_asyncos, - 'includes': ['cisco_asyncos.include'], + 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, + # 'snmp_scan_function': scan_cisco_asyncos, + # 'includes': ['cisco_asyncos.include'], } diff --git a/checks/cisco_asyncos_dns b/checks/cisco_asyncos_dns index a98e20d84a223527bec9a70f414911dad5abd6e9..579959db70fb87849d0e21880f04e1ae9d3538a5 100644 --- a/checks/cisco_asyncos_dns +++ b/checks/cisco_asyncos_dns @@ -66,8 +66,8 @@ check_info['cisco_asyncos_dns'] = { '15', # outstandingDNSRequests '16', # pendingDNSRequests ]), + 'default_levels_variable': 'cisco_asyncos_dns_default_levels', 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, # 'snmp_scan_function': scan_cisco_asyncos, # 'includes': ['cisco_asyncos.include'], - 'default_levels_variable': 'cisco_asyncos_dns_default_levels', } diff --git a/checks/cisco_asyncos_fan b/checks/cisco_asyncos_fan deleted file mode 100644 index 6c3291981a839043200cebf2970d6c43d440be2a..0000000000000000000000000000000000000000 --- a/checks/cisco_asyncos_fan +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Author: Th.L. -# Date: 10-02-2020 -# -# monitors status Cisco IronPort Appliances (ESA/SMA/WSA) fan sensors -# Tested with: C380, M380, C370, M670, S370 -# -# based on original Check_MK fan checks -# -# 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. -# -# OMD[cmk16x]:~$ snmpwalk -v2c -c C370-MAIL localhost -m ASYNCOS-MAIL-MIB -ObentU fanTable -# .1.3.6.1.4.1.15497.1.1.1.10.1.1.1 = INTEGER: 1 -# .1.3.6.1.4.1.15497.1.1.1.10.1.1.2 = INTEGER: 2 -# .1.3.6.1.4.1.15497.1.1.1.10.1.1.3 = INTEGER: 3 -# .1.3.6.1.4.1.15497.1.1.1.10.1.1.4 = INTEGER: 4 -# .1.3.6.1.4.1.15497.1.1.1.10.1.2.1 = Gauge32: 3600 -# .1.3.6.1.4.1.15497.1.1.1.10.1.2.2 = Gauge32: 3600 -# .1.3.6.1.4.1.15497.1.1.1.10.1.2.3 = Gauge32: 3600 -# .1.3.6.1.4.1.15497.1.1.1.10.1.2.4 = Gauge32: 3480 -# .1.3.6.1.4.1.15497.1.1.1.10.1.3.1 = STRING: FAN 1 -# .1.3.6.1.4.1.15497.1.1.1.10.1.3.2 = STRING: FAN 2 -# .1.3.6.1.4.1.15497.1.1.1.10.1.3.3 = STRING: FAN 3 -# .1.3.6.1.4.1.15497.1.1.1.10.1.3.4 = STRING: FAN 4 -# -# OMD[cmk16x]:~$ snmpwalk -v2c -c C370-MAIL localhost -m ASYNCOS-MAIL-MIB fanTable -# ASYNCOS-MAIL-MIB::fanIndex.1 = INTEGER: 1 -# ASYNCOS-MAIL-MIB::fanIndex.2 = INTEGER: 2 -# ASYNCOS-MAIL-MIB::fanIndex.3 = INTEGER: 3 -# ASYNCOS-MAIL-MIB::fanIndex.4 = INTEGER: 4 -# ASYNCOS-MAIL-MIB::fanRPMs.1 = Gauge32: 3600 -# ASYNCOS-MAIL-MIB::fanRPMs.2 = Gauge32: 3600 -# ASYNCOS-MAIL-MIB::fanRPMs.3 = Gauge32: 3600 -# ASYNCOS-MAIL-MIB::fanRPMs.4 = Gauge32: 3480 -# ASYNCOS-MAIL-MIB::fanName.1 = STRING: FAN 1 -# ASYNCOS-MAIL-MIB::fanName.2 = STRING: FAN 2 -# ASYNCOS-MAIL-MIB::fanName.3 = STRING: FAN 3 -# ASYNCOS-MAIL-MIB::fanName.4 = STRING: FAN 4 -# - - -factory_settings['cisco_asyncos_fan_default_levels'] = { - 'lower': (2000, 1000), - 'upper': (8000, 8400), - 'output_metrics': True, -} - - -def inventory_cisco_asyncos_fan(info): - if info: - for line in info: - fanRPM, fanName = line - if fanName.lower().startswith('fan '): - fanName = fanName[4:] - item = fanName - yield item, {} - - -def check_cisco_asyncos_fan(item, params, info): - if info: - for line in info: - fanRPM, fanName = line - if fanName.lower().startswith('fan '): - fanName = fanName[4:] - if fanName == item: - rpm = int(fanRPM) - yield check_fan(rpm, params) - - -check_info['cisco_asyncos_fan'] = { - 'inventory_function': inventory_cisco_asyncos_fan, - 'check_function': check_cisco_asyncos_fan, - 'group': 'hw_fans', - 'service_description': 'FAN %s', - 'has_perfdata': True, - 'snmp_info': ( - '.1.3.6.1.4.1.15497.1.1.1.10.1', # ASYNCOS-MAIL-MIB::fanEntry - [ - '2', # fanRPMs - '3', # fanName - ]), - 'default_levels_variable': 'cisco_asyncos_fan_default_levels', - 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, - # 'snmp_scan_function': scan_cisco_asyncos, - # 'includes': ['cisco_asyncos.include', 'fan.include'], - # 'includes': ['fan.include'], -} diff --git a/checks/cisco_asyncos_license b/checks/cisco_asyncos_license index f950eb918f47f3487e2a0222de2f43690c1a24cf..d46dacdc0009f4e1526ca67d5b33db631bbb35ec 100644 --- a/checks/cisco_asyncos_license +++ b/checks/cisco_asyncos_license @@ -190,9 +190,9 @@ check_info['cisco_asyncos_license'] = { '3', # keyIsPerpetual '4', # keySecondsUntilExpire ]), + 'default_levels_variable': 'cisco_asyncos_license_default_levels', 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, # 'snmp_scan_function': scan_cisco_asyncos, - # 'default_levels_variable': 'cisco_asyncos_license_default_levels', - 'includes': ['cisco_asyncos.include'], + # 'includes': ['cisco_asyncos.include'], } diff --git a/checks/cisco_asyncos_power b/checks/cisco_asyncos_power deleted file mode 100644 index fe9aa178a8cc126f2fce2be92f7df1c41edfc1d2..0000000000000000000000000000000000000000 --- a/checks/cisco_asyncos_power +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# -# Author: Th.L. -# Date: 10-02-2020 -# -# monitors status power supplies of Cisco IronPort Appliances (ESA/SMA/WSA) -# Tested with: C380, M380, C370, M670, S370 -# -# -# based on original Check_MK power supply checks (fireeye/dell) -# -# 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- -# ails. 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. -# -# OMD[cmk16x]:~$ snmpwalk -ObentU -v2c -c public localhost -m ASYNCOS-MAIL-MIB powerSupplyTable -# .1.3.6.1.4.1.15497.1.1.1.8.1.1.1 = INTEGER: 1 -# .1.3.6.1.4.1.15497.1.1.1.8.1.1.2 = INTEGER: 2 -# .1.3.6.1.4.1.15497.1.1.1.8.1.2.1 = INTEGER: 2 -# .1.3.6.1.4.1.15497.1.1.1.8.1.2.2 = INTEGER: 2 -# .1.3.6.1.4.1.15497.1.1.1.8.1.3.1 = INTEGER: 1 -# .1.3.6.1.4.1.15497.1.1.1.8.1.3.2 = INTEGER: 1 -# .1.3.6.1.4.1.15497.1.1.1.8.1.4.1 = STRING: PS 1 -# .1.3.6.1.4.1.15497.1.1.1.8.1.4.2 = STRING: PS 2 -# -# OMD[cmk16x]:~$ snmpwalk -v2c -c public localhost -m ASYNCOS-MAIL-MIB powerSupplyTable -# ASYNCOS-MAIL-MIB::powerSupplyIndex.1 = INTEGER: 1 -# ASYNCOS-MAIL-MIB::powerSupplyIndex.2 = INTEGER: 2 -# ASYNCOS-MAIL-MIB::powerSupplyStatus.1 = INTEGER: powerSupplyHealthy(2) -# ASYNCOS-MAIL-MIB::powerSupplyStatus.2 = INTEGER: powerSupplyHealthy(2) -# ASYNCOS-MAIL-MIB::powerSupplyRedundancy.1 = INTEGER: powerSupplyRedundancyOK(1) -# ASYNCOS-MAIL-MIB::powerSupplyRedundancy.2 = INTEGER: powerSupplyRedundancyOK(1) -# ASYNCOS-MAIL-MIB::powerSupplyName.1 = STRING: PS 1 -# ASYNCOS-MAIL-MIB::powerSupplyName.2 = STRING: PS 2 -# - - -def inventory_cisco_asyncos_power(info, has_item, has_params=False): - if info: - params = None - if has_params: - params = {} - for line in info: - if has_item: - status, redundancy, name = line - item = name - yield item, params - - -def check_cisco_asyncos_power_states(states): - # Now we only known the OK states and health states - # but we can expand if we know more - map_states = { - 'status': { - '1': (1, 'not installed'), - '2': (0, 'healthy'), - '3': (2, 'no AC'), - '4': (2, 'faulty'), - }, - 'redundancy': { - '1': (0, 'OK'), - '2': (2, 'redundancy lost'), - } - } - states_evaluated = {} - for what, text in states: - states_evaluated.setdefault(text, map_states[text.lower()].get(what.lower(), (2, 'not %s' % what.lower()))) - - return states_evaluated - - -def check_cisco_asyncos_power(item, _no_params, info): - for line in info: - status, redundancy, name = line - if item == name: - for text, (state, state_readable) in \ - check_cisco_asyncos_power_states([(status, 'Status'), (redundancy, 'redundancy')]).items(): - yield state, '%s: %s' % (text, state_readable) - - -check_info['cisco_asyncos_power'] = { - 'inventory_function': lambda info: inventory_cisco_asyncos_power(info, True), - 'check_function': check_cisco_asyncos_power, - 'service_description': 'Power Supply %s', - 'snmp_info': ( - '.1.3.6.1.4.1.15497.1.1.1.8.1', # ASYNCOS-MAIL-MIB::powerSupplyEntry - [ - '2', # powerSupplyStatus - '3', # powerSupplyRedundancy - '4', # powerSupplyName - ]), - 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, - # 'snmp_scan_function': scan_cisco_asyncos, - # 'includes': ['cisco_asyncos.include'], -} \ No newline at end of file diff --git a/checks/cisco_asyncos_queue b/checks/cisco_asyncos_queue index 4330b2ee4a20151e49cca9366128a901356e15f0..e4105d0ba04f2101f8fe8e2ef5ef45f2a3748b05 100644 --- a/checks/cisco_asyncos_queue +++ b/checks/cisco_asyncos_queue @@ -78,8 +78,8 @@ check_info['cisco_asyncos_queue'] = { '11' # workQueueMessages ] ), - 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, 'default_levels_variable': 'cisco_asyncos_queue_default_levels', + 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1, # 'snmp_scan_function': scan_cisco_asyncos, # 'includes': ['cisco_asyncos.include'], } diff --git a/checks/cisco_asyncos_raid b/checks/cisco_asyncos_raid index ef9e921487b6375046d7bf07be866f5ec024cbb2..1aed36da7298814fccf1104d1ea2a55acf5b9a56 100644 --- a/checks/cisco_asyncos_raid +++ b/checks/cisco_asyncos_raid @@ -8,18 +8,6 @@ # Tested with: C380, M380, C370, M670, S370 # # -# based on original Check_MK power supply checks (fireeye/dell) -# -# 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- -# ails. 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. # # OMD[cmk16x]:~$ snmpwalk -v2c -c C370-MAIL localhost -m ASYNCOS-MAIL-MIB -ObentU raidTable # .1.3.6.1.4.1.15497.1.1.1.18.1.1.1 = INTEGER: 1 diff --git a/cisco_asyncos.mkp b/cisco_asyncos.mkp index 0587cbb03450684d01757b1a334ebf94537a97dd..7ffc3e968140298a7b31323b262f25092a18aae7 100644 Binary files a/cisco_asyncos.mkp and b/cisco_asyncos.mkp differ diff --git a/packages/cisco_asyncos b/packages/cisco_asyncos index ceae4b30b3db0b2f78b2a5bd67649e77f61e2e74..7d32ddabd949a141eec423a2b14fcdb344ba8dbf 100644 --- a/packages/cisco_asyncos +++ b/packages/cisco_asyncos @@ -23,17 +23,16 @@ 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_asyncos_cpu.py', 'cisco_asyncos_mem.py', - 'cisco_asyncos_temp.py'], + 'cisco_asyncos_temp.py', + 'cisco_asyncos_fan.py', + 'cisco_asyncos_power.py'], 'checks': ['cisco_asyncos_bandwidth', 'cisco_asyncos_cache', 'cisco_asyncos_conn', - 'cisco_asyncos_fan', 'cisco_asyncos_license', - 'cisco_asyncos_power', 'cisco_asyncos_queue', 'cisco_asyncos_raid', 'cisco_asyncos_update', - 'cisco_asyncos.include', 'cisco_asyncos_dns', 'cisco_asyncos_messageage', 'cisco_asyncos_resources'], @@ -42,7 +41,7 @@ 'plugins/wato/cisco_asyncos_update.py', 'plugins/metrics/cisco_asyncos.py']}, 'name': 'cisco_asyncos', - 'num_files': 20, + 'num_files': 19, 'title': 'Cisco AsyncOS (IronPort) checks', 'version': '20200514_v0.1.4', 'version.min_required': '2.0.0',