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

update project

parent 6262f9d3
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
#
......@@ -9,6 +9,8 @@
#
# Monitor Check Point Maestro SMO Chassis status (asg monitor)
#
# 2021-02-25: rewrite for CMK 2.x
#
# 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.2.0 = STRING: "Primary Up"
......@@ -58,93 +60,156 @@
# ]
# ]
#
def inventory_checkpoint_asg_chassis(info):
chassis_info, chassis_params, asgsgms = info
from pprint import pprint
from typing import Mapping, Dict, List, Tuple, NamedTuple
from .agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from .agent_based_api.v1 import (
register,
Service,
equals,
check_levels,
Result,
State,
SNMPTree,
startswith,
all_of,
any_of,
)
class CheckPointASGChassisInfo(NamedTuple):
mode: str
hamode: str
synctoactive: str
synctostandby: str
class CheckPointASGChassisParams(NamedTuple):
id: str
status: str
grade: str
maxgrade: str
uniqueip: str
class CheckPointASGChassisSgms(NamedTuple):
id: str
status: str
class CheckPointASGChassis(NamedTuple):
info: CheckPointASGChassisInfo
chassis: List
sgms: List
def parse_checkpoint_asg_chassis(string_table: List[StringTable]): #-> CheckPointASGChassis:
chassis = CheckPointASGChassis
try:
asgChassisMode, asgChassisHAMode, asgSyncToActive, asgSyncToStandby = chassis_info[0]
yield None, {'inv_state': info}
except IndexError:
pass
chassis.info = CheckPointASGChassisInfo(*string_table[0][0])
except TypeError:
return None
chassis.chassis = string_table[1]
chassis.sgms = string_table[2]
parsed = chassis
return parsed
def check_checkpoint_asg_chassis(_no_item, params, info):
chassis_info, chassis_params, asgsgms = info
def discovery_checkpoint_asg_chassis(section: CheckPointASGChassis) -> DiscoveryResult:
yield Service(parameters={'inv_chassis_parms': section.chassis})
asgChassisMode, asgChassisHAMode, asgSyncToActive, asgSyncToStandby = chassis_info[0]
if params:
inv_chassis_info, inv_chassis_params, inv_asgsgms = params.get('inv_state')
def check_checkpoint_asg_chassis(params, section: CheckPointASGChassis) -> CheckResult:
infotext = ''
longoutput = ''
state = 0
details = ''
details += '\n\nTo verify this output use the "asg monitor" CLI command on the Check Point SMO,\n'
details += '\nChassis Mode: %s' % section.info.mode
details += '\nH/A Mode: %s' % section.info.hamode
details += '\nSync to active: %s' % section.info.synctoactive
details += '\nSync to standby: %s' % section.info.synctostandby
longoutput += '\n\nTo verify this output use the "asg monitor" CLI command on the Check Point SMO,\n'
longoutput += '\nChassis Mode: %s' % asgChassisMode
longoutput += '\nH/A Mode: %s' % asgChassisHAMode
longoutput += '\nSync to active: %s' % asgSyncToActive
longoutput += '\nSync to standby: %s' % asgSyncToStandby
inv_chassis_parms = params['inv_chassis_parms']
for chassis in chassis_params:
asgChassisParamsID, asgChassisParamsStatus, asgChassisParamsGrade, asgChassisParamsMaxGrade, asgChassisParamsUniqueIP = chassis
for chassis in section.chassis:
chassis = CheckPointASGChassisParams(*chassis)
if asgChassisParamsUniqueIP != 'N/A':
longoutput += '\nChassis %s unique IP: %s' % (asgChassisParamsID, asgChassisParamsUniqueIP)
if chassis.uniqueip != 'N/A':
details += '\nChassis %s unique IP: %s' % (chassis.id, chassis.uniqueip)
for inv_chassis in inv_chassis_params:
inv_asgChassisParamsID, inv_asgChassisParamsStatus, inv_asgChassisParamsGrade, inv_asgChassisParamsMaxGrade, inv_asgChassisParamsUniqueIP = inv_chassis
if asgChassisParamsID == inv_asgChassisParamsID:
yield_text = 'Chassis %s: %s, grade: %s/%s' % (asgChassisParamsID, asgChassisParamsStatus, asgChassisParamsGrade, asgChassisParamsMaxGrade)
if not asgChassisParamsStatus.lower() in ['active', 'standby']:
yield 2, yield_text
elif (asgChassisParamsStatus != inv_asgChassisParamsStatus) or (asgChassisParamsGrade != inv_asgChassisParamsGrade) or (asgChassisParamsMaxGrade != inv_asgChassisParamsMaxGrade):
yield 1, yield_text + ' (expected: %s, grade: %s/%s)' % (inv_asgChassisParamsStatus, asgChassisParamsGrade, asgChassisParamsMaxGrade)
for inv_chassis in inv_chassis_parms:
inv_chassis = CheckPointASGChassisParams(*inv_chassis)
if chassis.id == inv_chassis.id:
yield_text = 'Chassis %s: %s, grade: %s/%s' % (chassis.id, chassis.status,chassis.grade,chassis.maxgrade)
if not chassis.status.lower() in ['active', 'standby']:
yield Result(state=State.CRIT, summary=yield_text)
elif (chassis.status != inv_chassis.status) or (chassis.grade != inv_chassis.grade) or (chassis.maxgrade != inv_chassis.maxgrade):
yield Result(State.WARNING, notice=yield_text + ' (expected: %s, grade: %s/%s)' % (inv_chassis.status, inv_chassis.grade, inv_chassis.maxgrade))
else:
yield 0, yield_text
yield Result(state=State.OK, summary=yield_text)
active_sgms = 0
for asgSgm in asgsgms:
asgSGMID, asgSGMStatus = asgSgm
if asgSGMStatus == 'ACTIVE':
for asgSgm in section.sgms:
asgSgm = CheckPointASGChassisSgms(*asgSgm)
if asgSgm.status.lower() == 'active':
active_sgms += 1
else:
yield 2, 'SGM %s state: %s' % (asgSGMID, asgSGMStatus)
yield 0, '%d/%d SGMs active' % (active_sgms, len(asgsgms))
yield state, infotext + longoutput + '\n'
check_info['checkpoint_asg_chassis'] = {
'check_function': check_checkpoint_asg_chassis,
'inventory_function': inventory_checkpoint_asg_chassis,
'service_description': "ASG Chassis",
'snmp_scan_function': scan_checkpoint,
'group': 'checkpoint_asg_chassis',
'snmp_info': [(
'.1.3.6.1.4.1.2620.1.48.28', # CHECKPOINT-MIB::asgChassisInfo
[
'1', # asgChassisMode
'2', # asgChassisHAMode
'3.1', # asgSyncToActive
'3.2', # asgSyncToStandby
]),
('.1.3.6.1.4.1.2620.1.48.28.4.1', # CHECKPOINT-MIB::asgChassisParamsEntry
[
'2', # asgChassisParamsID
'3', # asgChassisParamsStatus
'4', # asgChassisParamsGrade
'5', # asgChassisParamsMaxGrade
'6', # asgChassisParamsUniqueIP
]),
('.1.3.6.1.4.1.2620.1.48.28.5.1', # CHECKPOINT-MIB::asgSGMEntry
[
'2', # asgSGMID
'3', # asgSGMStatus
]
)
yield Result(state=State.CRIT, notice='SGM %s state: %s' % (asgSgm.id, asgSgm.status))
yield Result(state=State.OK,
summary='%d/%d SGMs active' % (active_sgms, len(section.sgms)),
details=details)
register.snmp_section(
name='checkpoint_asg_chassis',
parse_function=parse_checkpoint_asg_chassis,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.2620.1.48.28', # CHECKPOINT-MIB::asgChassisInfo
oids=[
'1', # asgChassisMode
'2', # asgChassisHAMode
'3.1', # asgSyncToActive
'3.2', # asgSyncToStandby
]
),
SNMPTree(
base='.1.3.6.1.4.1.2620.1.48.28.4.1', # CHECKPOINT-MIB::asgChassisParamsEntry
oids=[
'2', # asgChassisParamsID
'3', # asgChassisParamsStatus
'4', # asgChassisParamsGrade
'5', # asgChassisParamsMaxGrade
'6', # asgChassisParamsUniqueIP
]
),
SNMPTree(
base='.1.3.6.1.4.1.2620.1.48.28.5.1', # CHECKPOINT-MIB::asgSGMEntry
oids=[
'2', # asgSGMID
'3', # asgSGMStatus
]
),
],
'includes': ['checkpoint.include'],
}
\ No newline at end of file
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_asg_chassis',
service_name='ASG Chassis',
discovery_function=discovery_checkpoint_asg_chassis,
check_function=check_checkpoint_asg_chassis,
check_default_parameters={},
check_ruleset_name='checkpoint_asg_chassis',
)
No preview for this file type
{'author': u'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': u'Monitor Check Point Maestro SMO Chassis status (asg monitor)',
{'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Monitor Check Point Maestro SMO Chassis status (asg '
'monitor)\n',
'download_url': 'http://thl-cmk.hopto.org/',
'files': {'checks': ['checkpoint_asg_chassis']},
'files': {'agent_based': ['checkpoint_asg_chassis.py']},
'name': 'checkpoint_asg_chassis',
'num_files': 1,
'title': u'Check Point Maestro SMO ASG Chassis',
'version': '20201107.v0.1',
'version.min_required': '1.4.0p38',
'version.packaged': '1.6.0p15',
'title': 'Check Point Maestro SMO ASG Chassis',
'version': '20210225.v0.2',
'version.min_required': '2.0.0i1',
'version.packaged': '2020.11.27',
'version.usable_until': None}
\ No newline at end of file
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