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

update project

parent 312d4b1f
No related branches found
No related tags found
No related merge requests found
#!/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 : 2020-11-29
#
# Monitor Check Point MHO ports
#
#
#
# sample snmpwalk
#
#
# sample string_table
#
#
#
# sample section
#
import time
from typing import List, NamedTuple, Optional, Dict
from dataclasses import dataclass
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,
equals,
Result,
State,
SNMPTree,
startswith,
all_of,
any_of,
Metric,
GetRateError,
get_rate,
get_value_store,
IgnoreResultsError,
render,
)
@dataclass
class CheckPointMhoPortCounter:
ucast: int
mcast: int
bcast: int
err: int
frames: int
bytes: int
fcs_err: int
@dataclass
class CheckPointMhoPort:
label: str
admin_state: str
link_state: str
speed: str
rx: CheckPointMhoPortCounter
tx: CheckPointMhoPortCounter
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(
label=label,
admin_state=admin_state,
link_state=link_state,
speed=speed,
tx=CheckPointMhoPortCounter(
ucast=int(tx_ucast) if tx_ucast.isdigit() else 0,
mcast=int(tx_mcast) if tx_mcast.isdigit() else 0,
bcast=int(tx_bcast) if tx_bcast.isdigit() else 0,
err=int(tx_err) if tx_err.isdigit() else 0,
frames=int(tx_frames) if tx_frames.isdigit() else 0,
bytes=int(rx_bytes) if rx_bytes.isdigit() else 0,
fcs_err=int(tx_fcs_err) if tx_fcs_err.isdigit() else 0
),
rx=CheckPointMhoPortCounter(
ucast=int(rx_ucast) if rx_ucast.isdigit() else 0,
mcast=int(rx_mcast) if rx_mcast.isdigit() else 0,
bcast=int(rx_bcast) if rx_bcast.isdigit() else 0,
err=int(rx_err) if rx_err.isdigit() else 0,
frames=int(rx_frames) if rx_frames.isdigit() else 0,
bytes=int(rx_bytes) if rx_bytes.isdigit() else 0,
fcs_err=int(rx_fcs_err) if rx_fcs_err.isdigit() else 0
)
)
return section
def discovery_checkpoint_mho_ports(params, section: Dict[str, CheckPointMhoPort]) -> DiscoveryResult:
for item in section.keys():
if params['add_admin_down'] is not True and section[item].admin_state.lower() in ['down', 'na']:
continue
if params['add_link_down'] is not True and section[item].link_state.lower() == 'down':
continue
yield Service(item=item)
def check_checkpoint_mho_ports(item, params, section: Dict[str, CheckPointMhoPort]) -> CheckResult:
try:
port = section[item]
except KeyError:
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}')
now = time.time()
value_store = get_value_store()
metric_prefix = 'checkpoint_mho_port'
raise_ingore_res = False
for metric, value in [
('rx_ucats', port.rx.ucast),
('rx_mcats', port.rx.mcast),
('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),
('tx_mcats', port.tx.mcast),
('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
else:
yield Metric(
value=value,
name=f'{metric_prefix}_{metric}',
)
if raise_ingore_res:
raise IgnoreResultsError('Initializing counters')
register.snmp_section(
name='checkpoint_mho_ports',
parse_function=parse_checkpoint_mho_ports,
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
'1.1.6', # mhoRxErr
'1.1.7', # mhoRxFrames
'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
'2.1.6', # mhoTxErr
'2.1.7', # mhoTxFrames
'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
'4.1.4', # mhoStateAdminState
'4.1.5', # mhoStateSpeed
# '5.1.1', # mhoSummaryPortIndex
# '5.1.2', # mhoSummaryPortLabel
# '5.1.3', # mhoSummaryLinkState
# '5.1.4', # mhoSummaryAdminState
# '5.1.5', # mhoSummarySpeed
# '5.1.6', # mhoSummaryRxFcsErr
# '5.1.7', # mhoSummaryRxErr
# '5.1.8', # mhoSummaryRxFrames
# '5.1.9', # mhoSummaryRxBytes
# '5.1.10', # mhoSummaryTxErr
# '5.1.11', # mhoSummaryTxFrames
# '5.1.12', # mhoSummaryTxBytes
]
),
detect=any_of(
startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2620'),
all_of(
equals('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.8072.3.2.10'),
equals('.1.3.6.1.4.1.2620.1.6.1.0', 'SVN Foundation'),
)
)
)
register.check_plugin(
name='checkpoint_mho_ports',
service_name='Port %s',
discovery_function=discovery_checkpoint_mho_ports,
discovery_ruleset_name='discovery_checkpoint_mho_ports',
discovery_default_parameters={
'add_admin_down': False,
'add_link_down': False,
},
check_function=check_checkpoint_mho_ports,
check_default_parameters={},
check_ruleset_name='checkpoint_mho_ports',
)
File added
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Monitors Check Point MHO Port statistics\n'
'\n'
'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']},
'name': 'checkpoint_mho_ports',
'num_files': 2,
'title': 'Check Point MHO Ports',
'version': '201129.v0.0.1',
'version.min_required': '2.0.0',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from cmk.gui.i18n import _
from cmk.gui.plugins.metrics import (
metric_info,
graph_info,
perfometer_info,
)
metric_info['checkpoint_mho_port_rx_ucats'] = {
'title': _('RX Unicasts'),
'unit': '1/s',
'color': '11/a',
}
metric_info['checkpoint_mho_port_tx_ucats'] = {
'title': _('TX Unicasts'),
'unit': '1/s',
'color': '11/b',
}
metric_info['checkpoint_mho_port_rx_mcats'] = {
'title': _('RX Multicasts'),
'unit': '1/s',
'color': '12/a',
}
metric_info['checkpoint_mho_port_tx_mcats'] = {
'title': _('TX Multicasts'),
'unit': '1/s',
'color': '12/b',
}
metric_info['checkpoint_mho_port_rx_bcats'] = {
'title': _('RX Broadcasts'),
'unit': '1/s',
'color': '13/a',
}
metric_info['checkpoint_mho_port_tx_bcats'] = {
'title': _('TX Broadcasts'),
'unit': '1/s',
'color': '13/b',
}
metric_info['checkpoint_mho_port_rx_err'] = {
'title': _('RX Errors'),
'unit': '1/s',
'color': '14/a',
}
metric_info['checkpoint_mho_port_tx_err'] = {
'title': _('TX Errors'),
'unit': '1/s',
'color': '14/b',
}
metric_info['checkpoint_mho_port_rx_frames'] = {
'title': _('RX Frames'),
'unit': '1/s',
'color': '15/a',
}
metric_info['checkpoint_mho_port_tx_frames'] = {
'title': _('TX Frames'),
'unit': '1/s',
'color': '15/b',
}
metric_info['checkpoint_mho_port_rx_bytes'] = {
'title': _('RX Bytes'),
'unit': 'bytes/s',
'color': '16/a',
}
metric_info['checkpoint_mho_port_tx_bytes'] = {
'title': _('TX Bytes'),
'unit': 'bytes/s',
'color': '16/b',
}
metric_info['checkpoint_mho_port_rx_fcs_err'] = {
'title': _('RX FCS Errors'),
'unit': '1/s',
'color': '21/a',
}
metric_info['checkpoint_mho_port_tx_fcs_err'] = {
'title': _('TX FCS Errors'),
'unit': '1/s',
'color': '21/b',
}
graph_info['checkpoint_mho_port_bytes'] = {
'title': _('Check Point MHO port bytes'),
'metrics': [
('checkpoint_mho_port_rx_bytes', 'area'),
('checkpoint_mho_port_tx_bytes', '-area'),
],
}
graph_info['checkpoint_mho_port_frames'] = {
'title': _('Check Point MHO port frames'),
'metrics': [
('checkpoint_mho_port_rx_frames', 'line'),
('checkpoint_mho_port_rx_ucats', 'stack'),
('checkpoint_mho_port_rx_mcats', 'stack'),
('checkpoint_mho_port_rx_bcats', 'stack'),
('checkpoint_mho_port_tx_frames', '-line'),
('checkpoint_mho_port_tx_ucats', '-stack'),
('checkpoint_mho_port_tx_mcats', '-stack'),
('checkpoint_mho_port_tx_bcats', '-stack'),
],
}
graph_info['checkpoint_mho_port_errors'] = {
'title': _('Check Point MHO port errors'),
'metrics': [
('checkpoint_mho_port_rx_err', 'line'),
('checkpoint_mho_port_rx_fcs_err', 'line'),
('checkpoint_mho_port_tx_err', '-line'),
('checkpoint_mho_port_tx_fcs_err', '-line'),
],
}
perfometer_info.append(('stacked', [
{
'type': 'logarithmic',
'metric': 'checkpoint_mho_port_rx_bytes',
'half_value': 100.0 * 48,
'exponent': 2,
},
{
'type': 'logarithmic',
'metric': 'checkpoint_mho_port_tx_bytes',
'half_value': 100.0 * 48,
'exponent': 2,
},
]))
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