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

update project

parent 2a13b09a
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
# 2021-02-25: rewrite for CMK 2.x # 2021-02-25: rewrite for CMK 2.x
# added warning/critical is chassis grade not equeal maxGrade # added warning/critical is chassis grade not equeal maxGrade
# 2021-09-10: rewrite parse function # 2021-09-10: rewrite parse function
# # 2021-09-11: added WATO, cleanup
# ToDo: add warning if SGM/Chassis is missing compared to inventory time
# #
# sample snmpwalk # sample snmpwalk
# .1.3.6.1.4.1.2620.1.48.28.1.0 = STRING: "Multi" # .1.3.6.1.4.1.2620.1.48.28.1.0 = STRING: "Multi"
...@@ -48,25 +47,24 @@ ...@@ -48,25 +47,24 @@
# .1.3.6.1.4.1.2620.1.48.28.5.1.5.2.0 = STRING: "N/A" # .1.3.6.1.4.1.2620.1.48.28.5.1.5.2.0 = STRING: "N/A"
# .1.3.6.1.4.1.2620.1.48.28.5.1.5.3.0 = STRING: "N/A" # .1.3.6.1.4.1.2620.1.48.28.5.1.5.3.0 = STRING: "N/A"
# #
# sample info # sample string_table
# [ # [
# [ # [
# [u'Multi', u'Primary Up', u'Enabled', u'Enabled'] # ['Multi', 'Primary Up', 'Enabled', 'Enabled']
# ], # ],
# [ # [
# [u'1', u'ACTIVE', u'34', u'34', u'N/A'], # ['1', 'ACTIVE', '34', '34', 'N/A'],
# [u'2', u'STANDBY', u'28', u'28', u'N/A'] # ['2', 'STANDBY', '28', '28', 'N/A']
# ], # ],
# [ # [
# [u'1_01', u'ACTIVE'], # ['1_01', 'ACTIVE'],
# [u'1_02', u'ACTIVE'], # ['1_02', 'ACTIVE'],
# [u'2_01', u'ACTIVE'] # ['2_01', 'ACTIVE']
# ] # ]
# ] # ]
# #
from pprint import pprint
from typing import Mapping, Dict, List, Tuple, NamedTuple, Optional from typing import List, NamedTuple, Optional
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult, DiscoveryResult,
...@@ -117,55 +115,74 @@ def parse_checkpoint_asg_chassis(string_table: List[StringTable]) -> Optional[Ch ...@@ -117,55 +115,74 @@ def parse_checkpoint_asg_chassis(string_table: List[StringTable]) -> Optional[Ch
try: try:
return CheckPointASGChassis( return CheckPointASGChassis(
info=CheckPointASGChassisInfo(*string_table[0][0]), info=CheckPointASGChassisInfo(*string_table[0][0]),
chassis=string_table[1], chassis=[CheckPointASGChassisParams(*chassis) for chassis in string_table[1]],
sgms=string_table[2] sgms=[CheckPointASGChassisSgms(*sgm) for sgm in string_table[2]]
) )
except (TypeError, IndexError): except (TypeError, IndexError):
pass pass
def discovery_checkpoint_asg_chassis(section: CheckPointASGChassis) -> DiscoveryResult: def discovery_checkpoint_asg_chassis(section: CheckPointASGChassis) -> DiscoveryResult:
yield Service(parameters={'inv_chassis_parms': section.chassis}) yield Service(parameters={
'discovery_chassis': len(section.chassis),
'discovery_sgms': len(section.sgms),
})
def check_checkpoint_asg_chassis(params, section: CheckPointASGChassis) -> CheckResult: def check_checkpoint_asg_chassis(params, section: CheckPointASGChassis) -> CheckResult:
details = '' notice = ''
details += '\nTo verify this output use the "asg monitor" CLI command on the Check Point SMO,\n' notice += '\nTo verify this output use the "asg monitor" CLI command on the Check Point SMO,\n'
details += '\nChassis Mode: %s' % section.info.mode notice += f'\nChassis Mode: {section.info.mode}'
details += '\nH/A Mode: %s' % section.info.hamode notice += f'\nH/A Mode: {section.info.hamode}'
details += '\nSync to active: %s' % section.info.synctoactive notice += f'\nSync to active: {section.info.synctoactive}'
details += '\nSync to standby: %s' % section.info.synctostandby notice += f'\nSync to standby: {section.info.synctostandby}'
inv_chassis_parms = params['inv_chassis_parms'] yield Result(state=State.OK, notice=notice)
for chassis in section.chassis: for chassis in section.chassis:
chassis = CheckPointASGChassisParams(*chassis)
if chassis.uniqueip != 'N/A': if chassis.uniqueip != 'N/A':
details += '\nChassis %s unique IP: %s' % (chassis.id, chassis.uniqueip) yield Result(state=State.OK, notice=f'\nChassis {chassis.id} unique IP: {chassis.uniqueip}')
for inv_chassis in inv_chassis_parms: if not chassis.status.lower() in ['active', 'standby']:
inv_chassis = CheckPointASGChassisParams(*inv_chassis) yield Result(
if chassis.id == inv_chassis.id: state=State(params['state_chassis_not_active_standby']),
yield_text = 'Chassis %s: %s, grade: %s/%s' % (chassis.id, chassis.status, chassis.grade, chassis.maxgrade) summary=f'Chassis {chassis.id}: {chassis.status}'
if not chassis.status.lower() in ['active', 'standby'] or chassis.grade != chassis.maxgrade: )
yield Result(state=State.CRIT, summary=yield_text) elif chassis.id == params['desired_chassis_active'] and chassis.status.lower() != 'active':
elif (chassis.status != inv_chassis.status) or (chassis.grade != inv_chassis.grade) or (chassis.maxgrade != inv_chassis.maxgrade): yield Result(
yield Result(state=State.WARN, notice=yield_text + ' (expected: %s, grade: %s/%s)' % (inv_chassis.status, inv_chassis.grade, inv_chassis.maxgrade)) state=State(params['state_chassis_not_desired_active']),
else: notice=f'Chassis {chassis.id}: {chassis.status} should be active'
yield Result(state=State.OK, summary=yield_text) )
else:
yield Result(state=State.OK, summary=f'Chassis {chassis.id}: {chassis.status}')
summary = f'grade: {chassis.grade}/{chassis.maxgrade}'
details = f'Chassis {chassis.id} grade: {chassis.grade}/{chassis.maxgrade}'
if chassis.grade != chassis.maxgrade:
yield Result(state=State(params['state_chassis_not_max_grade']), summary=summary, details=details)
else:
yield Result(state=State.OK, summary=summary, details=details)
if len(section.chassis) != params['discovery_chassis']:
yield Result(
state=State(params['state_chassis_number_changed']),
notice=f'Number of chassis changed ({len(section.chassis)}/{params["discovery_chassis"]}'
)
active_sgms = 0 active_sgms = 0
for asgSgm in section.sgms: for sgm in section.sgms:
asgSgm = CheckPointASGChassisSgms(*asgSgm) if sgm.status.lower() == 'active':
if asgSgm.status.lower() == 'active':
active_sgms += 1 active_sgms += 1
else: else:
yield Result(state=State.CRIT, notice='SGM %s state: %s' % (asgSgm.id, asgSgm.status)) yield Result(state=State(params['state_sgm_not_active']), notice=f'SGM {sgm.id} state: {sgm.status}')
yield Result(state=State.OK, yield Result(state=State.OK, summary=f'{active_sgms}/{len(section.sgms)} SGMs active')
summary='%d/%d SGMs active' % (active_sgms, len(section.sgms)),
details=details) if len(section.sgms) != params['discovery_sgms']:
yield Result(
state=State(params['state_sgms_number_changed']),
notice=f'Number of SGMs changed ({len(section.sgms)}/{params["state_sgms_number_changed"]}'
)
register.snmp_section( register.snmp_section(
...@@ -213,5 +230,14 @@ register.check_plugin( ...@@ -213,5 +230,14 @@ register.check_plugin(
service_name='ASG Chassis', service_name='ASG Chassis',
discovery_function=discovery_checkpoint_asg_chassis, discovery_function=discovery_checkpoint_asg_chassis,
check_function=check_checkpoint_asg_chassis, check_function=check_checkpoint_asg_chassis,
check_default_parameters={}, check_default_parameters={
) 'state_chassis_number_changed': 2,
\ No newline at end of file 'desired_chassis_active': '1',
'state_chassis_not_desired_active': 1,
'state_chassis_not_active_standby': 2,
'state_chassis_not_max_grade': 2,
'state_sgm_not_active': 2,
'state_sgms_number_changed': 2,
},
check_ruleset_name='checkpoint_asg_chassis',
)
No preview for this file type
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
'monitor)\n', 'monitor)\n',
'download_url': 'http://thl-cmk.hopto.org/', 'download_url': 'http://thl-cmk.hopto.org/',
'files': {'agent_based': ['checkpoint_asg_chassis.py'], 'files': {'agent_based': ['checkpoint_asg_chassis.py'],
'checkman': ['checkpoint_asg_chassis']}, 'checkman': ['checkpoint_asg_chassis'],
'web': ['plugins/wato/checkpoint_asg_chassis.py']},
'name': 'checkpoint_asg_chassis', 'name': 'checkpoint_asg_chassis',
'num_files': 2, 'num_files': 3,
'title': 'Check Point Maestro SMO ASG Chassis', 'title': 'Check Point Maestro SMO ASG Chassis',
'version': '20210225.v0.2', 'version': '20210911.v0.3',
'version.min_required': '2.0.0b8', 'version.min_required': '2.0.0b8',
'version.packaged': '2021.07.14', 'version.packaged': '2021.07.14',
'version.usable_until': None} '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.valuespec import (
Dictionary,
TextAscii,
DropdownChoice,
MonitoringState,
Transform,
)
from cmk.gui.plugins.wato import (
CheckParameterRulespecWithItem,
rulespec_registry,
RulespecGroupCheckParametersNetworking,
)
def _parameter_valuespec_checkpoint_asg_chassis():
return Transform(
Dictionary(elements=[
('desired_chassis_active',
DropdownChoice(
title=_('Desired active chassis'),
help=_('Select witch chassis should be active'),
sorted=True,
default_value='1',
choices=[
('1', _('Chassis ID 1')),
('2', _('Chassis ID 2')),
],
)),
('state_chassis_not_desired_active',
MonitoringState(
default_value=1,
title=_('State if desired chassis not active'),
help=_('Monitoring state if the desired chassis not active'),
)),
('state_chassis_number_changed',
MonitoringState(
default_value=2,
title=_('State if number of chassis has changed'),
help=_('Monitoring state if number of chassis differs from discovery time'),
)),
('state_chassis_not_active_standby',
MonitoringState(
default_value=2,
title=_('State if chassis not active/standby'),
help=_('Monitoring state if the chassis not active or standby'),
)),
('state_chassis_not_max_grade',
MonitoringState(
default_value=2,
title=_('State if chassis is not optimal'),
help=_('Monitoring state if the chassis grade is less than max grade'),
)),
('state_sgm_not_active',
MonitoringState(
default_value=2,
title=_('State if SGM is not active'),
help=_('Monitoring state if the SGM state is not active'),
)),
('state_sgms_number_changed',
MonitoringState(
default_value=2,
title=_('State if number of SGMs has canged'),
help=_('Monitoring state if number of SGMs differs from discovery time'),
)),
]))
rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='checkpoint_asg_chassis',
group=RulespecGroupCheckParametersNetworking,
match_type='dict',
parameter_valuespec=_parameter_valuespec_checkpoint_asg_chassis,
title=lambda: _('Check Point ASG Monitor'),
))
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