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 bef98ee7 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 9a201243
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
get_rate,
get_value_store,
IgnoreResultsError,
check_levels,
render,
)
......@@ -72,11 +73,17 @@ class CheckPointMhoPort:
def parse_checkpoint_mho_ports(string_table: StringTable) -> Dict[str, CheckPointMhoPort]:
section = {}
for line in string_table:
rx_ucast, rx_mcast, rx_bcast, rx_err, rx_frames, rx_bytes, rx_fcs_err, tx_ucast, tx_mcast, tx_bcast, tx_err, \
tx_frames, tx_bytes, tx_fcs_err, index, label, link_state, admin_state, speed = line
section[str(index)] = CheckPointMhoPort(
if len(string_table) < 100:
index = f'{int(index):02}'
else:
index = f'{int(index):03}'
section[index] = CheckPointMhoPort(
label=label,
admin_state=admin_state,
link_state=link_state,
......@@ -110,7 +117,7 @@ def discovery_checkpoint_mho_ports(params, section: Dict[str, CheckPointMhoPort]
continue
if params['add_link_down'] is not True and section[item].link_state.lower() == 'down':
continue
yield Service(item=item)
yield Service(item=item, parameters={'discovery_speed': section[item].speed})
def check_checkpoint_mho_ports(item, params, section: Dict[str, CheckPointMhoPort]) -> CheckResult:
......@@ -120,15 +127,46 @@ def check_checkpoint_mho_ports(item, params, section: Dict[str, CheckPointMhoPor
yield Result(state=State.UNKNOWN, notice='Item not found in SNMP data.')
return
yield Result(state=State.OK, summary=f'Label: {port.label}')
yield Result(state=State.OK, summary=f'Admin state: {port.admin_state}')
yield Result(state=State.OK, summary=f'Link state: {port.link_state}')
yield Result(state=State.OK, summary=f'Speed: {port.speed}')
yield Result(state=State.OK, notice=f'Label: {port.label}')
if port.admin_state.lower() in ['down', 'na']:
yield Result(state=State(params['state_admin_down']), notice=f'Admin state: {port.admin_state}')
yield Result(state=State.OK, notice=f'Link state: {port.link_state}')
else:
yield Result(state=State.OK, notice=f'Admin state: {port.admin_state}')
if port.link_state.lower() in ['down', 'na']:
yield Result(state=State(params['state_link_down']), notice=f'Link state: {port.link_state}')
else:
yield Result(state=State.OK, notice=f'Link state: {port.link_state}')
if params.get('discovery_speed') != port.speed:
yield Result(
state=State(params['state_speed_changed']),
notice=f'Speed: {port.speed} (expected: {params.get("discovery_speed")})')
else:
yield Result(state=State.OK, summary=f'Speed: {port.speed}')
now = time.time()
value_store = get_value_store()
metric_prefix = 'checkpoint_mho_port'
raise_ingore_res = False
raise_ignore_res = False
for metric, value, label in [
('tx_bytes', port.tx.bytes, 'RX bandwidth'),
('rx_bytes', port.rx.bytes, 'TX bandwidth'),
]:
try:
value = get_rate(value_store, metric, now, value, raise_overflow=True, )
except GetRateError:
raise_ignore_res = True
else:
yield from check_levels(
value=value,
label=label,
metric_name=f'{metric_prefix}_{metric}',
render_func=render.networkbandwidth,
)
for metric, value in [
('rx_ucats', port.rx.ucast),
......@@ -136,7 +174,6 @@ def check_checkpoint_mho_ports(item, params, section: Dict[str, CheckPointMhoPor
('rx_bcats', port.rx.bcast),
('rx_err', port.rx.err),
('rx_frames', port.rx.frames),
('rx_bytes', port.rx.bytes),
('rx_fcs_err', port.rx.fcs_err),
('tx_ucats', port.tx.ucast),
......@@ -144,22 +181,20 @@ def check_checkpoint_mho_ports(item, params, section: Dict[str, CheckPointMhoPor
('tx_bcats', port.tx.bcast),
('tx_err', port.tx.err),
('tx_frames', port.tx.frames),
('tx_bytes', port.tx.bytes),
('tx_fcs_err', port.tx.fcs_err),
]:
try:
value = get_rate(value_store, metric, now, value, raise_overflow=True, )
except GetRateError:
raise_ingore_res = True
raise_ignore_res = True
else:
yield Metric(
value=value,
name=f'{metric_prefix}_{metric}',
)
if raise_ingore_res:
raise IgnoreResultsError('Initializing counters')
if raise_ignore_res:
raise IgnoreResultsError('Initializing counters')
register.snmp_section(
......@@ -168,8 +203,6 @@ register.snmp_section(
fetch=SNMPTree(
base='.1.3.6.1.4.1.2620.1.55.1', # CHECKPOINT-MIB::mhoPortsStatus
oids=[
# '1.1.1', # mhoRxPortIndex
# '1.1.2', # mhoRxPortLabel
'1.1.3', # mhoRxUcast
'1.1.4', # mhoRxMcast
'1.1.5', # mhoRxBcast
......@@ -178,8 +211,6 @@ register.snmp_section(
'1.1.8', # mhoRxBytes
'1.1.9', # mhoRxFcsErr
# '2.1.1', # mhoTxPortIndex
# '2.1.2', # mhoTxPortLabel
'2.1.3', # mhoTxUcast
'2.1.4', # mhoTxMcast
'2.1.5', # mhoTxBcast
......@@ -188,33 +219,6 @@ register.snmp_section(
'2.1.8', # mhoTxBytes
'2.1.9', # mhoTxFcsErr
# '3.1.1', # mhoRxBuffPortIndex
# '3.1.2', # mhoRxBuffPortLabel
# '3.1.3', # mhoRxBuff0Frames
# '3.1.4', # mhoRxBuff0Octet
# '3.1.5', # mhoRxBuff0Discard
# '3.1.6', # mhoRxBuff1Frames
# '3.1.7', # mhoRxBuff1Octet
# '3.1.8', # mhoRxBuff1Discard
# '3.1.9', # mhoRxBuff2Frames
# '3.1.10', # mhoRxBuff2Octet
# '3.1.11', # mhoRxBuff2Discard
# '3.1.12', # mhoRxBuff3Frames
# '3.1.13', # mhoRxBuff3Octet
# '3.1.14', # mhoRxBuff3Discard
# '3.1.15', # mhoRxBuff4Frames
# '3.1.16', # mhoRxBuff4Octet
# '3.1.17', # mhoRxBuff4Discard
# '3.1.18', # mhoRxBuff5Frames
# '3.1.19', # mhoRxBuff5Octet
# '3.1.20', # mhoRxBuff5Discard
# '3.1.21', # mhoRxBuff6Frames
# '3.1.22', # mhoRxBuff6Octet
# '3.1.23', # mhoRxBuff6Discard
# '3.1.24', # mhoRxBuff7Frames
# '3.1.25', # mhoRxBuff7Octet
# '3.1.26', # mhoRxBuff7Discard
'4.1.1', # mhoStatePortIndex
'4.1.2', # mhoStatePortLabel
'4.1.3', # mhoStateLinkState
......@@ -251,10 +255,14 @@ register.check_plugin(
discovery_function=discovery_checkpoint_mho_ports,
discovery_ruleset_name='discovery_checkpoint_mho_ports',
discovery_default_parameters={
'add_admin_down': False,
'add_link_down': False,
'add_admin_down': True,
'add_link_down': True,
},
check_function=check_checkpoint_mho_ports,
check_default_parameters={},
check_default_parameters={
'state_admin_down': 1,
'state_link_down': 2,
'state_speed_changed': 1,
},
check_ruleset_name='checkpoint_mho_ports',
)
No preview for this file type
......@@ -4,9 +4,10 @@
'Tested on Orchestrator MHO-140 with R8020.SP HFA_317\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['checkpoint_mho_ports.py'],
'web': ['plugins/metrics/checkpoint_mho_ports.py']},
'web': ['plugins/metrics/checkpoint_mho_ports.py',
'plugins/wato/checkpoint_mho_ports.py']},
'name': 'checkpoint_mho_ports',
'num_files': 2,
'num_files': 3,
'title': 'Check Point MHO Ports',
'version': '201129.v0.0.1',
'version.min_required': '2.0.0',
......
......@@ -66,13 +66,13 @@ metric_info['checkpoint_mho_port_tx_frames'] = {
}
metric_info['checkpoint_mho_port_rx_bytes'] = {
'title': _('RX Bytes'),
'unit': 'bytes/s',
'title': _('RX bandwidth'),
'unit': 'bits/s',
'color': '16/a',
}
metric_info['checkpoint_mho_port_tx_bytes'] = {
'title': _('TX Bytes'),
'unit': 'bytes/s',
'title': _('TX bandwidth'),
'unit': 'bits/s',
'color': '16/b',
}
......
#!/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-12-02
#
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
TextAscii,
MonitoringState,
FixedValue,
)
from cmk.gui.plugins.wato import (
CheckParameterRulespecWithItem,
rulespec_registry,
RulespecGroupCheckParametersNetworking,
RulespecGroupCheckParametersDiscovery,
HostRulespec,
)
def _parameter_valuespec_checkpoint_mho_ports():
return Dictionary(
elements=[
('state_admin_down',
MonitoringState(
title=_('State if port is Admin down'),
help=_('Monitoring state if port is Admin down'),
default_value=1,
)),
('state_link_down',
MonitoringState(
title=_('State if port Link state is down'),
help=_('Monitoring state if port link state is down'),
default_value=2,
)),
('state_speed_changed',
MonitoringState(
title=_('State if port speed has changed'),
help=_('Monitoring state if port speed has changed from discovery'),
default_value=1,
)),
],
)
rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='checkpoint_mho_ports',
group=RulespecGroupCheckParametersNetworking,
match_type='dict',
parameter_valuespec=_parameter_valuespec_checkpoint_mho_ports,
title=lambda: _('Check Point MHO port'),
item_spec=lambda: TextAscii(title=_('Port index'), ),
))
def _valuespec_discovery_checkpoint_mho_ports():
return Dictionary(
title=_('Check Point MHO ports'),
elements=[
('add_admin_down',
FixedValue(
False,
title=_('Do not add Admin down ports'),
totext=_('If enabled the plugin will not add ports in Admin down state'),
)),
('add_link_down',
FixedValue(
False,
title=_('Do not add Link down ports'),
totext=_('If enabled the plugin will not add ports in Link down state'),
)),
],
)
rulespec_registry.register(
HostRulespec(
group=RulespecGroupCheckParametersDiscovery,
match_type='dict',
name='discovery_checkpoint_mho_ports',
valuespec=_valuespec_discovery_checkpoint_mho_ports,
))
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