diff --git a/agent_based/cisco_asyncos_bandwidth.py b/agent_based/cisco_asyncos_bandwidth.py new file mode 100644 index 0000000000000000000000000000000000000000..99483a0de98f70f586c3cfc73e47a81b08b8f908 --- /dev/null +++ b/agent_based/cisco_asyncos_bandwidth.py @@ -0,0 +1,87 @@ +#!/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 : 2021-03-24 +# +# only use full for Cisco WSA appliances +# + +from typing import Mapping, List, NamedTuple + +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + check_levels, + Result, + SNMPTree, + contains, + State, +) + + +class CiscoAsyncosBandwidth(NamedTuple): + bandwidth_now: int + bandwidth_hour: int + bandwidth_day: int + + +# [[['0', '0', '247']]] +def parse_cisco_asyncos_bandwidth(string_table: List[StringTable]) -> CiscoAsyncosBandwidth: + return CiscoAsyncosBandwidth( + bandwidth_now=int(string_table[0][0][0]), + bandwidth_hour=int(string_table[0][0][1]), + bandwidth_day = int(string_table[0][0][2]), + ) + + +def discovery_cisco_asyncos_bandwidth(section: CiscoAsyncosBandwidth) -> DiscoveryResult: + yield Service() + + +def check_cisco_asyncos_bandwidth(params, section: CiscoAsyncosBandwidth) -> CheckResult: + yield from check_levels( + section.bandwidth_now, + label='Current bandwidth', + levels_upper=params.get('upper', None), + levels_lower=params.get('lower', None), + metric_name='bandwith_now', + # render_func= + ) + + yield Result(state=State.OK, + summary='last hour: %s, last day: %s' % (section.bandwidth_hour, section.bandwidth_day)) + + +register.snmp_section( + name='cisco_asyncos_bandwidth', + parse_function=parse_cisco_asyncos_bandwidth, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.15497.1.2.3.7.4', # ASYNCOSWEBSECURITYAPPLIANCE-MIB::proxyRecentBandWTotPerf + oids=[ + '1', # cacheBwidthTotalNow + '3', # cacheBwidthTotal1hrMean + '5', # cacheBwidthTotal1dayMean + ] + ), + ], + detect=contains('.1.3.6.1.2.1.1.1.0', 'AsyncOS'), +) + +register.check_plugin( + name='cisco_asyncos_bandwidth', + service_name='Bandwidth', + discovery_function=discovery_cisco_asyncos_bandwidth, + check_function=check_cisco_asyncos_bandwidth, + check_default_parameters={}, +) diff --git a/agent_based/cisco_asyncos_cache.py b/agent_based/cisco_asyncos_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..dda48c618bf15b2ccd3d0c762141d4233e3d0dfd --- /dev/null +++ b/agent_based/cisco_asyncos_cache.py @@ -0,0 +1,92 @@ +#!/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 : 2021-03-24 +# +# only use full for Cisco WSA appliances +# + +from typing import Mapping, List, NamedTuple + +from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( + DiscoveryResult, + CheckResult, + StringTable, +) + +from cmk.base.plugins.agent_based.agent_based_api.v1 import ( + register, + Service, + check_levels, + Result, + Metric, + SNMPTree, + contains, + State, +) + + +class CiscoAsyncosCache(NamedTuple): + cache_hits_now: int + cache_misses_now: int + cache_hit_resptime_now: int + cache_miss_resptime_now: int + cache_total_resptime: int + + +# [[['0', '0', '0', '0', '0']]] +def parse_cisco_asyncos_cache(string_table: List[StringTable]) -> CiscoAsyncosCache: + return CiscoAsyncosCache( + cache_hits_now=int(string_table[0][0][0]), + cache_misses_now=int(string_table[0][0][1]), + cache_hit_resptime_now=int(string_table[0][0][2]), + cache_miss_resptime_now=int(string_table[0][0][3]), + cache_total_resptime=int(string_table[0][0][4]), + ) + + +def discovery_cisco_asyncos_cache(section: CiscoAsyncosCache) -> DiscoveryResult: + yield Service() + + +def check_cisco_asyncos_cache(params, section: CiscoAsyncosCache) -> CheckResult: + yield Result(state=State.OK, + summary='Cache Stats current %s Hits (%sms response time), %s Misses (%sms response time) and %sms total response time' % ( + section.cache_hits_now, section.cache_hit_resptime_now, section.cache_misses_now, + section.cache_miss_resptime_now, section.cache_total_resptime)) + + yield Metric(name='cache_hits_now', value=section.cache_hits_now) + yield Metric(name='cache_misses_now', value=section.cache_misses_now) + yield Metric(name='cache_hit_resptime_now', value=section.cache_hit_resptime_now) + yield Metric(name='cache_miss_resptime_now', value=section.cache_miss_resptime_now) + yield Metric(name='cache_total_resptime', value=section.cache_total_resptime) + +register.snmp_section( + name='cisco_asyncos_cache', + parse_function=parse_cisco_asyncos_cache, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.15497.1.2.3.7', # ASYNCOSWEBSECURITYAPPLIANCE-MIB::proxyRecentPerf + oids=[ + '5.1', # cacheHitsNow + '6.1', # cacheMissesNow + '7.1', # cacheHitRespTimeNow + '8.1', # cacheMissRespTimeNow + '9.1', # cacheTotalRespTimeNow + ] + ), + ], + detect=contains('.1.3.6.1.2.1.1.1.0', 'AsyncOS'), +) + +register.check_plugin( + name='cisco_asyncos_cache', + service_name='Cache Stats', + discovery_function=discovery_cisco_asyncos_cache, + check_function=check_cisco_asyncos_cache, + check_default_parameters={}, +) diff --git a/checks/cisco_asyncos_bandwidth b/checks/cisco_asyncos_bandwidth deleted file mode 100644 index 5829e7b7652274aad153b6ec36abd1afa2261b24..0000000000000000000000000000000000000000 --- a/checks/cisco_asyncos_bandwidth +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# +------------------------------------------------------------------+ -# | ____ _ _ __ __ _ __ | -# | / ___| |__ ___ ___| | __ | \/ | |/ / | -# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | -# | | |___| | | | __/ (__| < | | | | . \ | -# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | -# | | -# | Copyright Mathias Kettner 2013 mk@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- -# 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. -# -# only use full for Cisco WSA appliances -# - -cisco_asyncos_bandwidth_default_levels = {} - - -def inventory_cisco_asyncos_bandwidth(info): - if len(info) > 0: - return [(None, 'cisco_asyncos_bandwidth_default_levels')] - - -def check_cisco_asyncos_bandwidth(item, params, info): - state = 0 - perfdata = [] - warn, crit = None, None - now, onehour, oneday = info[0] - perfdata.append( ('now', now, warn, crit, 0, 1000000) ) - perfdata.append( ('onehour', onehour, warn, crit, 0, 1000000) ) - perfdata.append( ('oneday', oneday, warn, crit, 0, 1000000) ) - - infotext = 'Bandbreitennutzung aktuell %skBits - 1h Durchschnitt %skBits - 1d Durchschnitt %skBits' % (now, onehour, oneday) - return state, infotext, perfdata - - -check_info['cisco_asyncos_bandwidth'] = { - 'check_function': check_cisco_asyncos_bandwidth, - 'inventory_function': inventory_cisco_asyncos_bandwidth, - 'service_description': 'Bandwidth total', - 'has_perfdata': True, - 'snmp_info': ('.1.3.6.1.4.1.15497.1.2.3.7.4', [ # ASYNCOSWEBSECURITYAPPLIANCE-MIB::proxyRecentBandWTotPerf - '1', # cacheBwidthTotalNow - '3', # cacheBwidthTotal1hrMean - '5', # cacheBwidthTotal1dayMean - ]), - '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 deleted file mode 100644 index a52a3b95fbf24737d3b0844b5c7c862a0cb6378e..0000000000000000000000000000000000000000 --- a/checks/cisco_asyncos_cache +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- -# +------------------------------------------------------------------+ -# | ____ _ _ __ __ _ __ | -# | / ___| |__ ___ ___| | __ | \/ | |/ / | -# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | -# | | |___| | | | __/ (__| < | | | | . \ | -# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | -# | | -# | Copyright Mathias Kettner 2013 mk@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- -# 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. -# -# only use full for Cisco WSA appliances -# - - -cisco_asyncos_cache_default_levels = {} - - -def inventory_cisco_asyncos_cache(info): - if len(info) > 0: - return [(None, 'cisco_asyncos_cache_default_levels')] - - -def check_cisco_asyncos_cache(item, params, info): - state = 0 - perfdata = [] - warn, crit = None, None - hits, misses, hitresp, missresp, totalresp = info[0] - perfdata.append( ('hits', int(hits) ) ) - perfdata.append( ('misses', int(misses) ) ) - perfdata.append( ('hitresp', int(hitresp) ) ) - perfdata.append( ('missresp', int(missresp) ) ) - perfdata.append( ('totalresp', int(totalresp) ) ) - - infotext = 'Cache Stats aktuell %s Hits (%sms Antwortzeit), %s Misses (%sms Antwortzeit) und %sms gesamt Antwortzeit' % (hits, hitresp, misses, missresp, totalresp) - return state, infotext, perfdata - - -check_info['cisco_asyncos_cache'] = { - 'check_function': check_cisco_asyncos_cache, - 'inventory_function': inventory_cisco_asyncos_cache, - 'service_description': 'Cache Stats', - 'has_perfdata': True, - 'snmp_info': ('.1.3.6.1.4.1.15497.1.2.3.7', [ # ASYNCOSWEBSECURITYAPPLIANCE-MIB::proxyRecentPerf - '5.1', # cacheHitsNow - '6.1', # cacheMissesNow - '7.1', # cacheHitRespTimeNow - '8.1', # cacheMissRespTimeNow - '9.1', # cacheTotalRespTimeNow - ]), - '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/cisco_asyncos.mkp b/cisco_asyncos.mkp index ba5d874055af624ee806e377b40b58afb5b5c37b..be691ccdddc54f9082d6cd64f3b2730339bad591 100644 Binary files a/cisco_asyncos.mkp and b/cisco_asyncos.mkp differ diff --git a/packages/cisco_asyncos b/packages/cisco_asyncos index c319a77329c6284010020086dee1c569a3949748..d5850fb9dee82ed23af6a8b2c6a13e0828795873 100644 --- a/packages/cisco_asyncos +++ b/packages/cisco_asyncos @@ -20,17 +20,18 @@ '\n' '- 2021-03-21: rewrite cisco_asyncos_cpu, cisco_asyncos_mem, ' 'cisco_asyncos_temp for CMK 2.0\n' - '- 2021-03-24: rewrite cisco_asyncos_raid\n', + '- 2021-03-24: rewrite cisco_asyncos_raid, ' + 'cisco_asyncos_bandwidth, cisco_asyncos_cache\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_asyncos_cpu.py', 'cisco_asyncos_mem.py', 'cisco_asyncos_temp.py', 'cisco_asyncos_fan.py', 'cisco_asyncos_power.py', - 'cisco_asyncos_raid.py'], - 'checks': ['cisco_asyncos_bandwidth', - 'cisco_asyncos_cache', - 'cisco_asyncos_conn', + 'cisco_asyncos_raid.py', + 'cisco_asyncos_bandwidth.py', + 'cisco_asyncos_cache.py'], + 'checks': ['cisco_asyncos_conn', 'cisco_asyncos_license', 'cisco_asyncos_queue', 'cisco_asyncos_update', diff --git a/web/plugins/metrics/cisco_asyncos.py b/web/plugins/metrics/cisco_asyncos.py index ee23130a00b755078a23ad31fa43f8d35b0b8819..6159bc9078f058b5016f0307f373a01ada4c0e58 100644 --- a/web/plugins/metrics/cisco_asyncos.py +++ b/web/plugins/metrics/cisco_asyncos.py @@ -63,22 +63,22 @@ metric_info['cisco_asyncos_mem_mem_used'] = { # ###################################################################################################################### -check_metrics['check_mk-cisco_asyncos_dns'] = { - 'outstandingdnsrequests': {'name': 'cisco_asyncos_dns_outstandingdnsrequests', }, - 'pendingdnsrequests': {'name': 'cisco_asyncos_dns_pendingdnsrequests', }, -} - -check_metrics['check_mk-cisco_asyncos_messageage'] = { - 'oldestmessageage': {'name': 'cisco_asyncos_messageage_oldestmessageage', }, -} - -check_metrics['check_mk-cisco_asyncos_queue'] = { - 'queue': {'name': 'cisco_asyncos_queue_work_queue', }, -} - -check_metrics['check_mk-cisco_asyncos_mem'] = { - 'mem_used': {'name': 'cisco_asyncos_mem_mem_used', }, -} +# check_metrics['check_mk-cisco_asyncos_dns'] = { +# 'outstandingdnsrequests': {'name': 'cisco_asyncos_dns_outstandingdnsrequests', }, +# 'pendingdnsrequests': {'name': 'cisco_asyncos_dns_pendingdnsrequests', }, +# } +# +# check_metrics['check_mk-cisco_asyncos_messageage'] = { +# 'oldestmessageage': {'name': 'cisco_asyncos_messageage_oldestmessageage', }, +# } +# +# check_metrics['check_mk-cisco_asyncos_queue'] = { +# 'queue': {'name': 'cisco_asyncos_queue_work_queue', }, +# } +# +# check_metrics['check_mk-cisco_asyncos_mem'] = { +# 'mem_used': {'name': 'cisco_asyncos_mem_mem_used', }, +# } ######################################################################################################################