Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit 0553542f authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent b905072b
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,11 @@ ...@@ -21,8 +21,11 @@
# added relative thresholds (idea and code based on cmk PR #312 by https://github.com/gradecke) # added relative thresholds (idea and code based on cmk PR #312 by https://github.com/gradecke)
# added lower levels and admin_table_limit, removed default values except for 'levels_upper_relative' # added lower levels and admin_table_limit, removed default values except for 'levels_upper_relative'
# 2023-03-04: changed for CMK 2.1 (moved gui files from local/share/.. to local/lib/..) # 2023-03-04: changed for CMK 2.1 (moved gui files from local/share/.. to local/lib/..)
# removed default levels for Connection limits (Percent)
# removed dependencies between relative and absolute levels
# added predictive monitoring for current connections absolute and relative
# #
#
# sample string_table # sample string_table
# [[[u'559684419', u'203840211', u'51093794', u'786231', u'815404655', u'0']], [[u'11172', u'27598', u'0']]] # [[[u'559684419', u'203840211', u'51093794', u'786231', u'815404655', u'0']], [[u'11172', u'27598', u'0']]]
# #
...@@ -39,6 +42,7 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import ( ...@@ -39,6 +42,7 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
Service, Service,
Result, Result,
check_levels, check_levels,
check_levels_predictive,
State, State,
SNMPTree, SNMPTree,
all_of, all_of,
...@@ -99,10 +103,17 @@ def discovery_checkpoint_fw_connections(section: CheckpointFwConnections) -> Dis ...@@ -99,10 +103,17 @@ def discovery_checkpoint_fw_connections(section: CheckpointFwConnections) -> Dis
def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) -> CheckResult: def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) -> CheckResult:
fwConnTableLimit = params.get('admin_table_limit', section.fwConnTableLimit) fwConnTableLimit = max(params.get('admin_table_limit', section.fwConnTableLimit), section.fwConnTableLimit)
if fwConnTableLimit > 0: if fwConnTableLimit > 0:
yield from check_levels( yield from check_levels_predictive(
value=section.fwCurrnetNumConn * 100 / fwConnTableLimit,
levels=params.get('levels_upper_relative'),
boundaries=(0, 100),
label='Connections relative',
render_func=render.percent,
metric_name='checkpoint_fw_connections_relative'
) if isinstance(params.get('levels_upper_relative'), dict) else check_levels(
value=section.fwCurrnetNumConn * 100 / fwConnTableLimit, value=section.fwCurrnetNumConn * 100 / fwConnTableLimit,
levels_upper=params.get('levels_upper_relative'), levels_upper=params.get('levels_upper_relative'),
levels_lower=params.get('levels_lower_relative'), levels_lower=params.get('levels_lower_relative'),
...@@ -112,30 +123,20 @@ def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) -> ...@@ -112,30 +123,20 @@ def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) ->
metric_name='checkpoint_fw_connections_relative' metric_name='checkpoint_fw_connections_relative'
) )
if fwConnTableLimit > 0 and 'levels_upper_relative' in params:
warn_pct, crit_pct = params['levels_upper_relative']
warn = fwConnTableLimit * warn_pct / 100
crit = fwConnTableLimit * crit_pct / 100
levels_upper = (warn, crit)
else:
# use absolute levels if no relative levels provided or no maximum set on CP
levels_upper = params.get('levels_upper_absolute', (None, None))
if section.fwConnTableLimit > 0 and 'levels_lower_relative' in params:
warn_pct, crit_pct = params['levels_lower_relative']
warn = fwConnTableLimit * warn_pct / 100
crit = fwConnTableLimit * crit_pct / 100
levels_lower = (warn, crit)
else:
# use absolute levels if no relative levels provided or no maximum set on CP
levels_lower = params.get('levels_lower_absolute', (None, None))
for label, unit, metric, value, levels_upper, levels_lower in [ for label, unit, metric, value, levels_upper, levels_lower in [
('Current', '', 'fwcurrentnumconn', section.fwCurrnetNumConn, levels_upper, levels_lower), ('Current', '', 'fwcurrentnumconn', section.fwCurrnetNumConn, params.get('levels_upper_absolute'),
('Peak', '', 'fwpeaknumconn', section.fwPeakNumConn, (None, None), (None, None)), params.get('levels_lower_absolute')),
('Rate', '/s', 'fwconnectionrate', section.fwConnectionRate, (None, None), (None, None)), ('Peak', '', 'fwpeaknumconn', section.fwPeakNumConn, None, None),
('Rate', '/s', 'fwconnectionrate', section.fwConnectionRate, None, None),
]: ]:
yield from check_levels( yield from check_levels_predictive(
value=value,
label=label,
metric_name=f'checkpoint_fw_connections_{metric}',
render_func=lambda v: f'{v:.0f}{unit}',
levels=levels_upper,
boundaries=(0, None),
) if isinstance(levels_upper, dict) else check_levels(
value=value, value=value,
label=label, label=label,
metric_name=f'checkpoint_fw_connections_{metric}', metric_name=f'checkpoint_fw_connections_{metric}',
...@@ -145,12 +146,12 @@ def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) -> ...@@ -145,12 +146,12 @@ def check_checkpoint_fw_connections(params, section: CheckpointFwConnections) ->
boundaries=(0, None), boundaries=(0, None),
) )
if fwConnTableLimit == 0: if section.fwConnTableLimit == 0 and params.get('admin_table_limit', 0) == 0:
yield Result(state=State.OK, summary=f'Table limit: automatically adjusted') yield Result(state=State.OK, summary=f'Table limit: automatically adjusted')
elif section.fwConnTableLimit == fwConnTableLimit: elif section.fwConnTableLimit > params.get('admin_table_limit', 0):
yield Result(state=State.OK, summary=f'Table limit: {section.fwConnTableLimit}') yield Result(state=State.OK, summary=f'Table limit: {section.fwConnTableLimit} (set on firewall)')
else: else:
yield Result(state=State.OK, summary=f'Table limit: {section.fwConnTableLimit} (CMK admin limit') yield Result(state=State.OK, summary=f'Table limit: {params.get("admin_table_limit", 0)} (CMK admin limit)')
now_time = time.time() now_time = time.time()
value_store = get_value_store() value_store = get_value_store()
...@@ -212,7 +213,5 @@ register.check_plugin( ...@@ -212,7 +213,5 @@ register.check_plugin(
discovery_function=discovery_checkpoint_fw_connections, discovery_function=discovery_checkpoint_fw_connections,
check_function=check_checkpoint_fw_connections, check_function=check_checkpoint_fw_connections,
check_ruleset_name='checkpoint_fw_connections', check_ruleset_name='checkpoint_fw_connections',
check_default_parameters={ check_default_parameters={},
'levels_upper_relative': (80, 90),
}
) )
No preview for this file type
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
# Check Point Firewall connections metrics plugins # Check Point Firewall connections metrics plugins
# checkpoint_fw_connections # checkpoint_fw_connections
# #
# 2023-02-18: moved metrics file from ~/local/share/check_mk/... to ~/local/lib/check_mk/... # 2023-03-04: moved metrics file from ~/local/share/check_mk/... to ~/local/lib/check_mk/...
# # added predictive metrics
from cmk.gui.i18n import _ from cmk.gui.i18n import _
...@@ -19,8 +19,28 @@ from cmk.gui.plugins.metrics.utils import ( ...@@ -19,8 +19,28 @@ from cmk.gui.plugins.metrics.utils import (
metric_info, metric_info,
graph_info, graph_info,
perfometer_info, perfometer_info,
check_metrics,
) )
# for predictive monitoring
check_metrics["check_mk-checkpoint_fw_connections"] = {
"predict_checkpoint_fw_connections_fwcurrentnumconn": {"auto_graph": False},
"predict_checkpoint_fw_connections_relative": {"auto_graph": False},
}
metric_info['predict_checkpoint_fw_connections_fwcurrentnumconn'] = {
'title': _('_Predicted connections (absolute)'),
'unit': 'count',
'color': '26/b',
}
metric_info['predict_checkpoint_fw_connections_relative'] = {
'title': _('_Predicted connections (relative)'),
'unit': '%',
'color': '36/b',
}
#
# normal metrics
metric_info['checkpoint_fw_connections_fwconnectionstcp'] = { metric_info['checkpoint_fw_connections_fwconnectionstcp'] = {
'title': _('TCP connections'), 'title': _('TCP connections'),
'unit': '1/s', 'unit': '1/s',
...@@ -72,6 +92,7 @@ metric_info['checkpoint_fw_connections_relative'] = { ...@@ -72,6 +92,7 @@ metric_info['checkpoint_fw_connections_relative'] = {
graph_info['checkpoint_fw_connections_fwpeaknumconn'] = { graph_info['checkpoint_fw_connections_fwpeaknumconn'] = {
'title': _('Check Point Firewall Connections absolute'), 'title': _('Check Point Firewall Connections absolute'),
'metrics': [ 'metrics': [
('predict_checkpoint_fw_connections_fwcurrentnumconn', 'line'),
('checkpoint_fw_connections_fwcurrentnumconn', 'area'), ('checkpoint_fw_connections_fwcurrentnumconn', 'area'),
('checkpoint_fw_connections_fwpeaknumconn', 'line'), ('checkpoint_fw_connections_fwpeaknumconn', 'line'),
], ],
...@@ -79,11 +100,15 @@ graph_info['checkpoint_fw_connections_fwpeaknumconn'] = { ...@@ -79,11 +100,15 @@ graph_info['checkpoint_fw_connections_fwpeaknumconn'] = {
('checkpoint_fw_connections_fwcurrentnumconn:crit', _('crit')), ('checkpoint_fw_connections_fwcurrentnumconn:crit', _('crit')),
('checkpoint_fw_connections_fwcurrentnumconn:warn', _('warn')), ('checkpoint_fw_connections_fwcurrentnumconn:warn', _('warn')),
], ],
'optional_metrics': [
'predict_checkpoint_fw_connections_fwcurrentnumconn',
],
} }
graph_info['checkpoint_fw_connections_relative'] = { graph_info['checkpoint_fw_connections_relative'] = {
'title': _('Check Point Firewall Connections relative to connection table limit'), 'title': _('Check Point Firewall Connections relative to connection table limit'),
'metrics': [ 'metrics': [
('predict_checkpoint_fw_connections_relative', 'line'),
('checkpoint_fw_connections_relative', 'area'), ('checkpoint_fw_connections_relative', 'area'),
], ],
'scalars': [ 'scalars': [
...@@ -91,6 +116,9 @@ graph_info['checkpoint_fw_connections_relative'] = { ...@@ -91,6 +116,9 @@ graph_info['checkpoint_fw_connections_relative'] = {
('checkpoint_fw_connections_relative:warn', _('warn')), ('checkpoint_fw_connections_relative:warn', _('warn')),
], ],
'range': (0, 110), 'range': (0, 110),
'optional_metrics': [
'predict_checkpoint_fw_connections_relative',
],
} }
graph_info['checkpoint_fw_connections_fwconnectionstcp'] = { graph_info['checkpoint_fw_connections_fwconnectionstcp'] = {
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
# URL : https://thl-cmk.hopto.org # URL : https://thl-cmk.hopto.org
# Date : 2020-06-07 # Date : 2020-06-07
# #
# 2023-02-18: moved wato file from ~/local/share/check_mk/... to ~/local/lib/check_mk/... # 2023-03-04: moved wato file from ~/local/share/check_mk/... to ~/local/lib/check_mk/...
# fix: CheckParameterRulespecWithItem -> CheckParameterRulespecWithoutItem
# changed levels_upper_absolute/levels_upper_relative from Tuple to Levels for predictive monitoring
# #
from cmk.gui.i18n import _ from cmk.gui.i18n import _
from cmk.gui.valuespec import ( from cmk.gui.valuespec import (
Dictionary, Dictionary,
...@@ -19,66 +20,57 @@ from cmk.gui.valuespec import ( ...@@ -19,66 +20,57 @@ from cmk.gui.valuespec import (
Percentage, Percentage,
) )
from cmk.gui.plugins.wato.utils import ( from cmk.gui.plugins.wato.utils import (
CheckParameterRulespecWithItem, CheckParameterRulespecWithoutItem,
rulespec_registry, rulespec_registry,
RulespecGroupCheckParametersNetworking, RulespecGroupCheckParametersNetworking,
Levels,
) )
def _parameter_valuespec_checkpoint_fw_connections(): def _parameter_valuespec_checkpoint_fw_connections():
return Dictionary( return Dictionary(
elements=[ elements=[
('levels_upper_absolute',
Tuple(
title=_('Maximum number of firewall connections'),
help=_('This rule sets upper limits to the current number of connections through '
'a Checkpoint firewall.'),
elements=[
Integer(title=_('Warning at'), minvalue=0, unit=_('connections')),
Integer(title=_('Critical at'), minvalue=0, unit=_('connections')),
])),
('levels_lower_absolute',
Tuple(
title=_('Minimum number of firewall connections'),
help=_('This rule sets lower limits to the current number of connections through '
'a Checkpoint firewall.'),
elements=[
Integer(title=_('Warning blow'), minvalue=0, unit=_('connections')),
Integer(title=_('Critical below'), minvalue=0, unit=_('connections')),
])),
('admin_table_limit', ('admin_table_limit',
Integer( Integer(
title=_('Admin connection table limit'), title=_('Connection table limit'),
help=_('This rule sets the maximum number of connections through the firewall. This is use full ' help=_('This sets the maximum number of connections through the firewall. This is use full '
'if your firewall is set to automatic connection table limit and you still want ' 'if your firewall is set to automatic connection table limit and you still want '
'relative metrics. This setting takes precedence over the the fwConnTableLimit ' 'relative metrics. This setting takes precedence over the the onnection table limit '
'configured on the firewall (only for monitoring purposes of curse). This value should match' 'configured on the firewall (only for monitoring purposes of curse). This value should match '
'the real values of your firewall, if not you might get relative values above 100%.'), 'the real values of your firewall, if not you might get relative values above 100%.'),
minvalue=0, minvalue=0,
unit=_('connections'), unit=_('connections'),
)), )),
('levels_upper_relative', ('levels_upper_absolute',
Levels(
title=_('Max. connections (Absolute)'),
help=_('This sets the upper limits for the current number of connections through the firewall.'),
unit=_('connections'),
)),
('levels_lower_absolute',
Tuple( Tuple(
title=_('Percentage of maximum connections (only used if a limit is defined on ' title=_('Min. connections (Absolute)'),
'the Check Point device)'), help=_('This sets the lower limits for the current number of connections through the firewall. '
help=_('This relative threshold can only be used if a maximum number is defined on ' '"Min. connections (Absolute)" will only be used if "Max. connections (Absolute)" is not using '
'the firewall side and then read from fwConnTableLimit. By default, this ' 'Predictive Levels.'),
'limit is not set in Check Point devices and this check than falls back to '
'the absolute defaults or the ones defined above'),
elements=[ elements=[
Percentage( Integer(title=_('Warning blow'), minvalue=0, unit=_('connections')),
title=_('Warning at'), unit='%', minvalue=0.0, maxvalue=100.0, default_value=80.0), Integer(title=_('Critical below'), minvalue=0, unit=_('connections')),
Percentage(
title=_('Critical at'), unit='%', minvalue=0.0, maxvalue=100.0, default_value=90.0),
])), ])),
('levels_upper_relative',
Levels(
title=_('Max. connections (Percentage)'),
help=_('This relative threshold can only be used if a connection table limit is defined (on the '
'firewall side or with the above "Connection table limit").By default, this limit is not '
'set on Check Point devices.'),
unit=_('%'),
)),
('levels_lower_relative', ('levels_lower_relative',
Tuple( Tuple(
title=_('Percentage of minimum connections (only used if a limit is defined on ' title=_('Min. connections (Percentage)'),
'the Check Point device)'), help=_('This relative threshold can only be used if a maximum number is defined (on the '
help=_('This relative threshold can only be used if a maximum number is defined on ' 'firewall side or with the above "Connection table limit"). By default, this limit is not '
'the firewall side and then read from fwConnTableLimit. By default, this ' 'set on Check Point devices.'),
'limit is not set in Check Point devices and this check than falls back to '
'the absolute defaults or the ones defined above'),
elements=[ elements=[
Percentage( Percentage(
title=_('Warning below'), unit='%', minvalue=0.0, maxvalue=100.0), title=_('Warning below'), unit='%', minvalue=0.0, maxvalue=100.0),
...@@ -86,12 +78,11 @@ def _parameter_valuespec_checkpoint_fw_connections(): ...@@ -86,12 +78,11 @@ def _parameter_valuespec_checkpoint_fw_connections():
title=_('Critical below'), unit='%', minvalue=0.0, maxvalue=100.0), title=_('Critical below'), unit='%', minvalue=0.0, maxvalue=100.0),
])), ])),
], ],
# optional_keys=['levels_upper_relative'],
) )
rulespec_registry.register( rulespec_registry.register(
CheckParameterRulespecWithItem( CheckParameterRulespecWithoutItem(
check_group_name='checkpoint_fw_connections', check_group_name='checkpoint_fw_connections',
group=RulespecGroupCheckParametersNetworking, group=RulespecGroupCheckParametersNetworking,
match_type='dict', match_type='dict',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment