diff --git a/agent_based/cisco_asa_connections.py b/agent_based/cisco_asa_connections.py index 99c0818205f1d630a87407ff975f5ee49185655c..1b9ea76c13929f51fd6185e84fc3e9ef40c11a24 100644 --- a/agent_based/cisco_asa_connections.py +++ b/agent_based/cisco_asa_connections.py @@ -19,7 +19,9 @@ # 2020-02-24: added support for Cisco Firepower Threat Defense # 2020-04-28: changed item from Cisco ASA connections to Firewall connections --> more clear, with cisco_asa_conn check # 2021-03-24: rewrite for CMK 2.0 Check API, added lower levels +# 2023-06-07: fixed IndexError (list index out of range) in parse function # + # sample snmp walk # # .1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6 = Gauge32: 4987 @@ -30,7 +32,7 @@ # # -from typing import List, NamedTuple +from typing import NamedTuple, Optional from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( DiscoveryResult, @@ -54,11 +56,16 @@ class CiscoAsaFwConnections(NamedTuple): peak: int -# [[['1102', '2290']]] -def parse_cisco_asa_connections(string_table: List[StringTable]) -> CiscoAsaFwConnections: +# [['1102', '2290']] +def parse_cisco_asa_connections(string_table: StringTable) -> Optional[CiscoAsaFwConnections]: + try: + current, peak = string_table[0] + except (IndexError, ValueError): + return + return CiscoAsaFwConnections( - current=int(string_table[0][0][0]), - peak=int(string_table[0][0][1]) + current=int(current), + peak=int(peak) ) @@ -87,15 +94,13 @@ def check_cisco_asa_connections(params, section: CiscoAsaFwConnections) -> Check register.snmp_section( name='cisco_asa_connections', parse_function=parse_cisco_asa_connections, - fetch=[ - SNMPTree( - base='.1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40', # CISCO-FIREWALL-MIB::cfwConnectionStatValue.protoIp - oids=[ - '6', # currentInUse - '7', # protoIp.high - ] - ), - ], + fetch=SNMPTree( + base='.1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40', # CISCO-FIREWALL-MIB::cfwConnectionStatValue.protoIp + oids=[ + '6', # currentInUse + '7', # protoIp.high + ] + ), detect=any_of( startswith('.1.3.6.1.2.1.1.1.0', 'cisco adaptive security'), startswith('.1.3.6.1.2.1.1.1.0', 'cisco firepower threat defense'), diff --git a/checks/cisco_asa_connections b/checks/cisco_asa_connections new file mode 100644 index 0000000000000000000000000000000000000000..58a364eca45416c28d08a9487cba8cf2518fa7f6 --- /dev/null +++ b/checks/cisco_asa_connections @@ -0,0 +1,8 @@ +# +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2023-06-07 +# +# dummy for new cisco_asa_connections plugin +# ~/local/lib/check_mk/base/plugins/cisco_asa_connections.py +# \ No newline at end of file diff --git a/cisco_asa_connections-200607.v.0.5.mkp b/cisco_asa_connections-200607.v.0.5.mkp new file mode 100644 index 0000000000000000000000000000000000000000..6b4a80b38c88e671dbd57bcf5982770678309bce Binary files /dev/null and b/cisco_asa_connections-200607.v.0.5.mkp differ diff --git a/cisco_asa_connections.mkp b/cisco_asa_connections.mkp index 8cb57656887ea44600d4bb1a8a9b8b25dda5875c..6b4a80b38c88e671dbd57bcf5982770678309bce 100644 Binary files a/cisco_asa_connections.mkp and b/cisco_asa_connections.mkp differ diff --git a/packages/cisco_asa_connections b/packages/cisco_asa_connections index 7f1dd3c0334e863845de9731fe574f41da585554..068fa9428140a1781d525c70e893fb652416ffb0 100644 --- a/packages/cisco_asa_connections +++ b/packages/cisco_asa_connections @@ -10,12 +10,12 @@ 'connections\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_asa_connections.py'], + 'checks': ['cisco_asa_connections'], 'web': ['plugins/metrics/cisco_asa_connections.py', 'plugins/wato/cisco_fw_connections.py']}, 'name': 'cisco_asa_connections', - 'num_files': 3, 'title': 'Monitor Cisco ASA connections', - 'version': '20210324.v.0.4', - 'version.min_required': '2.0.0', - 'version.packaged': '2.0.0p1', + 'version': '200607.v.0.5', + 'version.min_required': '2.0.0b1', + 'version.packaged': '2.1.0p21', 'version.usable_until': None} \ No newline at end of file