diff --git a/agent_based/checkpoint_asg_diag.py b/agent_based/checkpoint_asg_diag.py index 935b6c7d6f17347c69fe5ad0b5278a1dbe1a8dc6..e4528a06056f3c7f67bb6bf30a2e015c04bd0426 100644 --- a/agent_based/checkpoint_asg_diag.py +++ b/agent_based/checkpoint_asg_diag.py @@ -97,14 +97,6 @@ class CheckPointASGDiag(NamedTuple): tests: List -class CheckPointASGDiagTest(NamedTuple): - index: str - name: str - lastrun: str - result: str - comment: str - - def parse_checkpoint_asg_diag(string_table: List[StringTable]) -> CheckPointASGDiag: asgSummary, asgTests = string_table @@ -123,10 +115,15 @@ def discovery_checkpoint_asg_diag(section: CheckPointASGDiag) -> DiscoveryResult def check_checkpoint_asg_diag(params, section: CheckPointASGDiag): - print(section.summary) - pprint(section.tests) - - summary = section.summary + class CheckPointASGDiagTest(NamedTuple): + index: str + name: str + lastrun: str + result: str + comment: str + + summary = 'Last run ' + section.summary + print (summary) details = '\n\nTo verify this output use the "asg diag verify" command on the Check Point SMO cli,\n' state = State.OK @@ -140,19 +137,21 @@ def check_checkpoint_asg_diag(params, section: CheckPointASGDiag): if len(asg_diag_ignore) > 0: summary += ', Ignored tests: %s' % str(asg_diag_ignore).strip('[').strip(']').replace(' ', '') - for asgTestIndex, asgTestName, asgTestLastRun, asgTestResult, asgTestComment in section.tests: - if asgTestComment == '': + for test in section.tests: + test = CheckPointASGDiagTest(*test) + if test.comment == '': details += '\nIndex: %s, Name: %s, LastRun: %s, Restult: %s' % ( - asgTestIndex, asgTestName, asgTestLastRun, asgTestResult) + test.index, test.name, test.lastrun, test.result) else: details += '\nIndex: %s, Name: %s, LastRun: %s, Restult: %s, Comment: %s' % ( - asgTestIndex, asgTestName, asgTestLastRun, asgTestResult, asgTestComment) + test.index, test.name, test.result, test.result, test.comment) - asgTestIndex = int(asgTestIndex) + asgTestIndex = int(test.index) if not asgTestIndex in asg_diag_ignore: - if asgTestResult.lower() == 'failed (!)': + if test.result.lower() == 'failed (!)': if asgTestIndex in asg_diag_warning: - state = max(state, State.WARNING) + if state == State.OK: + state = State.WARN else: state = State.CRIT diff --git a/checkpoint_asg_diag.mkp b/checkpoint_asg_diag.mkp index 86f4afa62986846580f39342762ac47697d836cc..53e116f3346f6001c4b6748fd4110d040e77dcb4 100644 Binary files a/checkpoint_asg_diag.mkp and b/checkpoint_asg_diag.mkp differ diff --git a/web/plugins/wato/checkpoint_asg_diag.py b/web/plugins/wato/checkpoint_asg_diag.py index ce201fa863a39f89a84ab889c9487d393ded41bb..b65f88b8e526a61fa4e60b6854481ed59bf05438 100644 --- a/web/plugins/wato/checkpoint_asg_diag.py +++ b/web/plugins/wato/checkpoint_asg_diag.py @@ -2,33 +2,50 @@ # -*- coding: utf-8 -*- # # -register_check_parameters( - subgroup_applications, - 'checkpoint_asg_diag', - _('Check Point ASG Diag'), - Dictionary( - # help=_(''), - elements=[ - ('asg_diag_ignore', - ListOfStrings( - title=_('Index list of ASG tests to ignore'), - orientation='horizontal', - allow_empty=False, - valuespec=Integer(minvalue=1, maxvalue=99, allow_empty=False), - help=_('there will be no warning/critical if this tests are not "Passed"'), - ) - ), - ('asg_diag_warning', - ListOfStrings( - title=_('Set monitoring state to warining if ASG test state is "Failed"'), - orientation='horizontal', - allow_empty=False, - valuespec=Integer(minvalue=1, maxvalue=99, allow_empty=False), - help=_('there will be only warning if this tests are not "Passed", else there will be a critical.'), - ) - ), - ], - ), - None, - match_type='dict', +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + TextAscii, + ListOfStrings, ) + +from cmk.gui.plugins.wato import ( + CheckParameterRulespecWithItem, + rulespec_registry, + RulespecGroupCheckParametersNetworking, +) + + +def _parameter_valuespec_checkpoint_asg_diag(): + return Dictionary(elements=[ + ('asg_diag_ignore', + ListOfStrings( + title=_('Index list of ASG Diag tests to ignore'), + orientation='horizontal', + allow_empty=False, + valuespec=Integer(minvalue=1, maxvalue=99), + help=_('there will be no warning/critical if this tests are not "Passed"'), + ) + ), + ('asg_diag_warning', + ListOfStrings( + title=_('Set monitoring state to warining if ASG Diag state is "Failed" for the following tests'), + orientation='horizontal', + allow_empty=False, + valuespec=Integer(minvalue=1, maxvalue=99), + help=_('there will be only warning if this tests are not "Passed", else there will be a critical.'), + ) + ), + ]) + + +rulespec_registry.register( + CheckParameterRulespecWithItem( + check_group_name='checkpoint_asg_diag', + group=RulespecGroupCheckParametersNetworking, + item_spec=lambda: TextAscii(title=_('Check Point ASG Diag'), ), + match_type='dict', + parameter_valuespec=_parameter_valuespec_checkpoint_asg_diag, + title=lambda: _('Check Point ASG Diag'), + ))