diff --git a/agent_based/cisco_asa_connections.py b/agent_based/cisco_asa_connections.py index d6be45d6e151d80c9555f080eccb5f2c1f0c8c58..99c0818205f1d630a87407ff975f5ee49185655c 100644 --- a/agent_based/cisco_asa_connections.py +++ b/agent_based/cisco_asa_connections.py @@ -18,7 +18,7 @@ # more specific "1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40" # 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 +# 2021-03-24: rewrite for CMK 2.0 Check API, added lower levels # # sample snmp walk # @@ -70,7 +70,7 @@ def discovery_cisco_asa_connections(section: CiscoAsaFwConnections) -> Discovery def check_cisco_asa_connections(params, section: CiscoAsaFwConnections) -> CheckResult: yield from check_levels( section.current, - levels_lower=params.get('lower', None), + levels_lower=params.get('connections_lower', None), levels_upper=params.get('connections', None), metric_name='fw_connections_active', render_func=lambda v: '%s' % str(v), @@ -79,7 +79,7 @@ def check_cisco_asa_connections(params, section: CiscoAsaFwConnections) -> Check yield from check_levels( section.peak, label='Max. since system startup', - metric_name='peak_connections', + metric_name='fw_connections_peak', render_func=lambda v: '%s' % str(v), ) diff --git a/cisco_asa_connections.mkp b/cisco_asa_connections.mkp index 84f04cfc5cbc3059b0951346203c46a360bd8eb0..4bb7115c46edc6d269ff923a840d6fef5a40bcda 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 19c2cb79b86f9c815ff44b6c921be20506674cc2..b081f15bffd85ce0062e890df4728e9850f79ae7 100644 --- a/packages/cisco_asa_connections +++ b/packages/cisco_asa_connections @@ -10,9 +10,10 @@ 'connections\n', 'download_url': 'https://thl-cmk.hopto.org', 'files': {'agent_based': ['cisco_asa_connections.py'], - 'web': ['plugins/metrics/cisco_asa_connections.py']}, + 'web': ['plugins/metrics/cisco_asa_connections.py', + 'plugins/wato/cisco_fw_connections.py']}, 'name': 'cisco_asa_connections', - 'num_files': 2, + 'num_files': 3, 'title': 'Monitor Cisco ASA connections', 'version': '20210324.v.0.4', 'version.min_required': '2.0.0', diff --git a/web/plugins/metrics/cisco_asa_connections.py b/web/plugins/metrics/cisco_asa_connections.py index 7c33f9ea75811f5cdb478ba748eb1d796ab75591..779627f274cc6367f69fbbc09239e4add64be837 100644 --- a/web/plugins/metrics/cisco_asa_connections.py +++ b/web/plugins/metrics/cisco_asa_connections.py @@ -1,77 +1,36 @@ -#!/usr/bin/python -# -*- encoding: utf-8; py-indent-offset: 4 -*- +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # # Cisco ASA connections metrics plugin # -# Author: Th.L. -# Date : 2018-01-09 -# - -##################################################################################################################### -# -# define units -# -##################################################################################################################### +from cmk.gui.i18n import _ -##################################################################################################################### -# -# define metrics -# -##################################################################################################################### +from cmk.gui.plugins.metrics import ( + metric_info, + graph_info, +) -metric_info['cisco_asa_connections_current_connections'] = { - 'title': _('current conections'), +metric_info['fw_connections_active'] = { + 'title': _('Active conections'), 'unit': 'count', 'color': '26/a', } - -metric_info['cisco_asa_connections_max_connections'] = { - 'title': _('max conections'), +metric_info['fw_connections_peak'] = { + 'title': _('Peak conections'), 'unit': 'count', - 'color': '11/a', + 'color': '16/a', } -###################################################################################################################### -# -# map perfdata to metric -# -###################################################################################################################### - -check_metrics['check_mk-cisco_asa_connections'] = { - 'current_connections': {'name': 'cisco_asa_connections_current_connections', }, - 'max_connections': {'name': 'cisco_asa_connections_max_connections',} -} - -###################################################################################################################### -# -# how to graph perdata -# -###################################################################################################################### - -graph_info.append({ - 'title': _('connections'), +graph_info['cisco_asa_connections'] = { + 'title': _('Firewall connections'), 'metrics': [ - ('cisco_asa_connections_max_connections', 'line'), - ('cisco_asa_connections_current_connections', 'area'), + ('fw_connections_active', 'line'), + ('fw_connections_peak', 'area'), ], 'scalars': [ - ('cisco_asa_connections_current_connections:crit', _('crit level')), - ('cisco_asa_connections_current_connections:warn', _('warn level')), + ('fw_connections_active:crit', _('crit level')), + ('fw_connections_active:warn', _('warn level')), ], -}) - -###################################################################################################################### -# -# define perf-o-meter -# -###################################################################################################################### - - -perfometer_info.append({ - 'type': 'logarithmic', - 'metric': 'cisco_asa_connections_current_connections', - 'half_value': 50000.0, - 'exponent': 2, -}) \ No newline at end of file +} diff --git a/web/plugins/wato/cisco_fw_connections.py b/web/plugins/wato/cisco_fw_connections.py new file mode 100644 index 0000000000000000000000000000000000000000..69a13912507147e38650afce6a90f45c375bc531 --- /dev/null +++ b/web/plugins/wato/cisco_fw_connections.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 +# 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 cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + Tuple, +) + +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithoutItem, + rulespec_registry, + RulespecGroupCheckParametersApplications, +) + + +def _parameter_valuespec_cisco_fw_connections(): + return Dictionary(elements=[ + ('connections', + Tuple( + help=_('This rule sets ipper limits to the current number of connections through a Cisco firewall.'), + title=_('Maximum number of firewall connections'), + elements=[ + Integer(title=_('Warning at'), unit='connections'), + Integer(title=_('Critical at'), unit='connections'), + ], + )), + ('connections_lower', + Tuple( + help=_('This rule sets lower limits to the current number of connections through a Cisco firewall.'), + title=_('Minimum number of firewall connections'), + elements=[ + Integer(title=_('Warning if below'), unit='connections'), + Integer(title=_('Critical if below'), unit='connections'), + ], + )), + + ],) + + +rulespec_registry.register( + CheckParameterRulespecWithoutItem( + check_group_name='cisco_fw_connections', + group=RulespecGroupCheckParametersApplications, + match_type='dict', + parameter_valuespec=_parameter_valuespec_cisco_fw_connections, + title=lambda: _('Cisco Firewall Connections'), + )) \ No newline at end of file