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

update project

parent 56108d44
No related branches found
No related tags found
No related merge requests found
......@@ -88,9 +88,15 @@ from .agent_based_api.v1 import (
any_of,
)
class CheckPointASGDiagSummary(NamedTuple):
date: str
time: str
passed: int
maxtest: int
failed: list
class CheckPointASGDiag(NamedTuple):
summary: str
summary: CheckPointASGDiagSummary
tests: List
......@@ -100,8 +106,16 @@ def parse_checkpoint_asg_diag(string_table: List[StringTable]) -> CheckPointASGD
if len(asgSummary) == 0:
return None
asgSummary = asgSummary[0][0]
parsed = CheckPointASGDiag
parsed.summary = asgSummary[0][0]
parsed.summary = CheckPointASGDiagSummary
# todo: change date to real date string, and add warn/crit if last run to old
parsed.summary.date = asgSummary[0][0][3:13]
parsed.summary.time = asgSummary[0][0][18:26]
parsed.summary.passed = int(asgSummary[28:].split(".")[0].split(' ')[1].split('/')[0])
parsed.summary.maxtest = int(asgSummary[28:].split(".")[0].split(' ')[1].split('/')[1])
parsed.summary.failed = list(map(int, asgSummary.split(':')[-1].strip(' ').split(',')))
parsed.tests = asgTests
return parsed
......@@ -119,8 +133,23 @@ def check_checkpoint_asg_diag(params, section: CheckPointASGDiag):
result: str
comment: str
summary = 'Last run ' + section.summary
summary = ''
summary += 'Last run on: %s at: %s' % (section.summary.date, section.summary.time)
summary += ' Passed %d/%d tests' % (section.summary.passed, section.summary.maxtest)
if len(section.summary.failed) > 0:
summary += ' Failed: %s' % ','.join(map(str, section.summary.failed))
details = '\n\nTo verify this output use the "asg diag verify" command on the Check Point SMO cli,\n'
for test in section.tests:
test = CheckPointASGDiagTest(*test)
if test.comment == '':
details += '\nIndex: %s, Name: %s, LastRun: %s, Restult: %s' % (
test.index, test.name, test.lastrun, test.result)
else:
details += '\nIndex: %s, Name: %s, LastRun: %s, Restult: %s, Comment: %s' % (
test.index, test.name, test.result, test.result, test.comment)
state = State.OK
asg_diag_ignore = []
......@@ -129,9 +158,10 @@ def check_checkpoint_asg_diag(params, section: CheckPointASGDiag):
if params:
asg_diag_ignore = params.get('asg_diag_ignore', [])
asg_diag_warning = params.get('asg_diag_warning', [])
asg_diag_ignore.sort()
if len(asg_diag_ignore) > 0:
summary += ', Ignored tests: %s' % str(asg_diag_ignore).strip('[').strip(']').replace(' ', '')
summary += ', Ignored tests: %s' % ','.join(map(str, asg_diag_ignore))
for test in section.tests:
test = CheckPointASGDiagTest(*test)
......@@ -142,14 +172,13 @@ def check_checkpoint_asg_diag(params, section: CheckPointASGDiag):
details += '\nIndex: %s, Name: %s, LastRun: %s, Restult: %s, Comment: %s' % (
test.index, test.name, test.result, test.result, test.comment)
asgTestIndex = int(test.index)
if not asgTestIndex in asg_diag_ignore:
if test.result.lower() == 'failed (!)':
if asgTestIndex in asg_diag_warning:
if state == State.OK:
state = State.WARN
else:
state = State.CRIT
for test in section.summary.failed:
if not test in asg_diag_ignore:
if test in asg_diag_warning:
if state == State.OK:
state = State.WARN
else:
state = State.CRIT
yield Result(state=state, summary=summary, details=details)
......
No preview for this file type
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