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

update project

parent e23e99da
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-30
#
# Monitor Check Point MHO port buffers
#
#
#
# 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 CheckPointMhoRxBuffer:
frames: int
octets: int
discard: int
@dataclass
class CheckPointMhoPortBuffer:
label: str
admin_state: str
link_state: str
buffer: Dict[str, CheckPointMhoRxBuffer]
def parse_checkpoint_mho_buffer(string_table: StringTable) -> Dict[str, CheckPointMhoPortBuffer]:
section = {}
for line in string_table:
_0_frames, _0_octet, _0_discard, _1_frames, _1_octet, _1_discard, _2_frames, _2_octet, _2_discard, _3_frames,\
_3_octet, _3_discard, _4_frames, _4_octet, _4_discard, _5_frames, _5_octet, _5_discard, _6_frames, _6_octet,\
_6_discard, _7_frames, _7_octet, _7_discard, index, label, link_state, admin_state = line
_i = 0
buffer = {}
for frames, octet, discard in [
(_0_frames, _0_octet, _0_discard),
(_1_frames, _1_octet, _1_discard),
(_2_frames, _2_octet, _2_discard),
(_3_frames, _3_octet, _3_discard),
(_4_frames, _4_octet, _4_discard),
(_5_frames, _5_octet, _5_discard),
(_6_frames, _6_octet, _6_discard),
(_7_frames, _7_octet, _7_discard),
]:
buffer[str(_i)] = CheckPointMhoRxBuffer(
frames=int(frames) if frames.isdigit() else 0,
octets=int(octet) if octet.isdigit() else 0,
discard=int(discard) if discard.isdigit() else 0,
)
_i += 1
section[str(index)] = CheckPointMhoPortBuffer(
label=label,
admin_state=admin_state,
link_state=link_state,
buffer=buffer,
)
return section
def discovery_checkpoint_mho_buffer(params, section: Dict[str, CheckPointMhoPortBuffer]) -> 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_buffer(item, params, section: Dict[str, CheckPointMhoPortBuffer]) -> 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}')
now = time.time()
value_store = get_value_store()
metric_prefix = 'checkpoint_mho_port_buffer'
raise_ingore_res = False
for buffer in port.buffer.keys():
try:
value = get_rate(value_store, f'{buffer}_frames', now, port.buffer[buffer].frames, raise_overflow=True, )
except GetRateError:
raise_ingore_res = True
else:
yield Metric(value=value, name=f'{metric_prefix}_{buffer}_frames')
try:
value = get_rate(value_store, f'{buffer}_octets', now, port.buffer[buffer].octets, raise_overflow=True, )
except GetRateError:
raise_ingore_res = True
else:
yield Metric(value=value, name=f'{metric_prefix}_{buffer}_octets')
try:
value = get_rate(value_store, f'{buffer}_discards', now, port.buffer[buffer].discard, raise_overflow=True, )
except GetRateError:
raise_ingore_res = True
else:
yield Metric(value=value, name=f'{metric_prefix}_{buffer}_discards')
if raise_ingore_res:
raise IgnoreResultsError('Initializing counters')
register.snmp_section(
name='checkpoint_mho_buffer',
parse_function=parse_checkpoint_mho_buffer,
fetch=SNMPTree(
base='.1.3.6.1.4.1.2620.1.55.1', # CHECKPOINT-MIB::mhoPortsStatus
oids=[
# '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_buffer',
service_name='RX buffers port %s',
discovery_function=discovery_checkpoint_mho_buffer,
discovery_ruleset_name='discovery_checkpoint_mho_buffer',
discovery_default_parameters={
'add_admin_down': False,
'add_link_down': False,
},
check_function=check_checkpoint_mho_buffer,
check_default_parameters={},
check_ruleset_name='checkpoint_mho_buffer',
)
No preview for this file type
{'author': 'cmkadmin',
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Monitors Check Point MHO port RX buffers\n'
'\n'
'Tested on Orchestrator MHO-140 with R8020.SP HFA_317\n',
'download_url': '',
'files': {'agent_based': ['checkpoint_mho_buffer.py'],
'web': ['plugins/metrics/checkpoint_mho_buffer.py']},
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['checkpoint_mho_buffers.py'],
'web': ['plugins/metrics/checkpoint_mho_buffers.py']},
'name': 'checkpoint_mho_buffers',
'num_files': 2,
'title': 'Check Point MHO port RX buffers',
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from cmk.gui.i18n import _
from cmk.gui.plugins.metrics import (
metric_info,
graph_info,
perfometer_info,
)
_i = 0
while _i < 8:
metric_info[f'checkpoint_mho_port_buffer_{_i}_frames'] = {
'title': _(f'RX buffer {_i} frames'),
'unit': '1/s',
'color': f'1{_i // 2 + 1}/{chr(97 + _i % 2)}',
}
metric_info[f'checkpoint_mho_port_buffer_{_i}_octets'] = {
'title': _(f'RX buffer {_i} octets'),
'unit': '1/s',
'color': f'2{_i // 2 + 1}/{chr(97 + _i % 2)}',
}
metric_info[f'checkpoint_mho_port_buffer_{_i}_discards'] = {
'title': _(f'RX buffer {_i} discards'),
'unit': '1/s',
'color': f'3{_i // 2 + 1}/{chr(97 + _i % 2)}',
}
_i += 1
graph_info['checkpoint_mho_port_buffer_frames'] = {
'title': _('Check Point MHO RX buffer frames'),
'metrics': [
('checkpoint_mho_port_buffer_0_frames', 'line'),
('checkpoint_mho_port_buffer_1_frames', 'line'),
('checkpoint_mho_port_buffer_2_frames', 'line'),
('checkpoint_mho_port_buffer_3_frames', 'line'),
('checkpoint_mho_port_buffer_4_frames', 'line'),
('checkpoint_mho_port_buffer_5_frames', 'line'),
('checkpoint_mho_port_buffer_6_frames', 'line'),
('checkpoint_mho_port_buffer_7_frames', 'line'),
],
}
graph_info['checkpoint_mho_port_buffer_octets'] = {
'title': _('Check Point MHO RX buffer octets'),
'metrics': [
('checkpoint_mho_port_buffer_0_octets', 'line'),
('checkpoint_mho_port_buffer_1_octets', 'line'),
('checkpoint_mho_port_buffer_2_octets', 'line'),
('checkpoint_mho_port_buffer_3_octets', 'line'),
('checkpoint_mho_port_buffer_4_octets', 'line'),
('checkpoint_mho_port_buffer_5_octets', 'line'),
('checkpoint_mho_port_buffer_6_octets', 'line'),
('checkpoint_mho_port_buffer_7_octets', 'line'),
],
}
graph_info['checkpoint_mho_port_buffer_discards'] = {
'title': _('Check Point MHO RX buffer discards'),
'metrics': [
('checkpoint_mho_port_buffer_0_discards', 'line'),
('checkpoint_mho_port_buffer_1_discards', 'line'),
('checkpoint_mho_port_buffer_2_discards', 'line'),
('checkpoint_mho_port_buffer_3_discards', 'line'),
('checkpoint_mho_port_buffer_4_discards', 'line'),
('checkpoint_mho_port_buffer_5_discards', 'line'),
('checkpoint_mho_port_buffer_6_discards', 'line'),
('checkpoint_mho_port_buffer_7_discards', 'line'),
],
}
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