From 7589294fa7c50634aae5a5af55f673b8c146e3b6 Mon Sep 17 00:00:00 2001 From: Kenneth Okoh Date: Thu, 20 Dec 2018 17:08:21 +0100 Subject: [PATCH] Refactoring: Moved last application check parameters from unsorted.py to dedicated modules (CMK-1393) Change-Id: I2dc7c4ab7e027c40fe602acca42649d0797de32f --- .../wato/check_parameters/hacmp_resources.py | 61 +++++++++ .../wato/check_parameters/oracle_logswitches.py | 96 +++++++++++++ .../wato/check_parameters/systemd_services.py | 66 +++++++++ cmk/gui/plugins/wato/check_parameters/unsorted.py | 150 --------------------- cmk/gui/plugins/wato/check_parameters/webserver.py | 75 +++++++++++ 5 files changed, 298 insertions(+), 150 deletions(-) create mode 100644 cmk/gui/plugins/wato/check_parameters/hacmp_resources.py create mode 100644 cmk/gui/plugins/wato/check_parameters/oracle_logswitches.py create mode 100644 cmk/gui/plugins/wato/check_parameters/systemd_services.py create mode 100644 cmk/gui/plugins/wato/check_parameters/webserver.py diff --git a/cmk/gui/plugins/wato/check_parameters/hacmp_resources.py b/cmk/gui/plugins/wato/check_parameters/hacmp_resources.py new file mode 100644 index 0000000000..e1fe7858ca --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/hacmp_resources.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + DropdownChoice, + TextAscii, + Transform, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "hacmp_resources", + _("AIX HACMP Resource Groups"), + Transform( + Dictionary( + elements=[ + ("expect_online_on", + DropdownChoice( + title=_(u"Expect resource to be online on"), + choices=[ + ("first", _(u"the first node")), + ("any", _(u"any node")), + ], + )), + ], + optional_keys=[], + ), + forth=lambda x: {"expect_online_on": "first"}, + ), + TextAscii(title=_(u"Resource Group")), + match_type="first", +) diff --git a/cmk/gui/plugins/wato/check_parameters/oracle_logswitches.py b/cmk/gui/plugins/wato/check_parameters/oracle_logswitches.py new file mode 100644 index 0000000000..86ed7ebd25 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/oracle_logswitches.py @@ -0,0 +1,96 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Integer, + TextAscii, + Transform, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + + +def transform_oracle_logswitches(params): + if isinstance(params, tuple): + return { + 'levels': (params[2], params[3]), + 'levels_lower': (params[1], params[0]), + } + return params + + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "oracle_logswitches", + _("Oracle Logswitches"), + Transform( + Dictionary( + help=_("This check monitors the number of log switches of an ORACLE " + "database instance in the last 60 minutes. You can set levels " + "for upper and lower bounds."), + elements=[ + ( + 'levels', + Tuple( + title=_("Set upper Levels"), + elements=[ + Integer( + title=_("Warning at or above"), + unit=_("log switches / hour"), + default_value=50), + Integer( + title=_("Critical at or above"), + unit=_("log switches / hour"), + default_value=100), + ]), + ), + ( + 'levels_lower', + Tuple( + title=_("Set lower Levels"), + elements=[ + Integer( + title=_("Warning at or below"), + unit=_("log switches / hour"), + default_value=-1), + Integer( + title=_("Critical at or below"), + unit=_("log switches / hour"), + default_value=-1), + ]), + ), + ], + ), + forth=transform_oracle_logswitches, + ), + TextAscii(title=_("Database SID"), size=12, allow_empty=False), + "first", +) diff --git a/cmk/gui/plugins/wato/check_parameters/systemd_services.py b/cmk/gui/plugins/wato/check_parameters/systemd_services.py new file mode 100644 index 0000000000..18e678fead --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/systemd_services.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + MonitoringState, + TextAscii, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "systemd_services", + _("Systemd Services"), + Dictionary( + elements=[ + ("states", + Dictionary( + elements=[ + ("active", + MonitoringState( + title=_("Monitoring state if service is active"), + default_value=0, + )), + ],)), + ("states_default", + MonitoringState( + title=_("Monitoring state for any other service state"), + default_value=2, + )), + ("else", + MonitoringState( + title=_("Monitoring state if a monitored service is not found at all."), + default_value=2, + )), + ],), + TextAscii(title=_("Name of the service")), + match_type="dict", +) diff --git a/cmk/gui/plugins/wato/check_parameters/unsorted.py b/cmk/gui/plugins/wato/check_parameters/unsorted.py index dc10c74ecc..47400088a2 100644 --- a/cmk/gui/plugins/wato/check_parameters/unsorted.py +++ b/cmk/gui/plugins/wato/check_parameters/unsorted.py @@ -1145,156 +1145,6 @@ register_rule( match='all', ) - -def transform_oracle_logswitches(params): - if isinstance(params, tuple): - return { - 'levels': (params[2], params[3]), - 'levels_lower': (params[1], params[0]), - } - return params - - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "oracle_logswitches", - _("Oracle Logswitches"), - Transform( - Dictionary( - help=_("This check monitors the number of log switches of an ORACLE " - "database instance in the last 60 minutes. You can set levels " - "for upper and lower bounds."), - elements=[ - ( - 'levels', - Tuple( - title=_("Set upper Levels"), - elements=[ - Integer( - title=_("Warning at or above"), - unit=_("log switches / hour"), - default_value=50), - Integer( - title=_("Critical at or above"), - unit=_("log switches / hour"), - default_value=100), - ]), - ), - ( - 'levels_lower', - Tuple( - title=_("Set lower Levels"), - elements=[ - Integer( - title=_("Warning at or below"), - unit=_("log switches / hour"), - default_value=-1), - Integer( - title=_("Critical at or below"), - unit=_("log switches / hour"), - default_value=-1), - ]), - ), - ], - ), - forth=transform_oracle_logswitches, - ), - TextAscii(title=_("Database SID"), size=12, allow_empty=False), - "first", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "systemd_services", - _("Systemd Services"), - Dictionary( - elements=[ - ("states", - Dictionary( - elements=[ - ("active", - MonitoringState( - title=_("Monitoring state if service is active"), - default_value=0, - )), - ],)), - ("states_default", - MonitoringState( - title=_("Monitoring state for any other service state"), - default_value=2, - )), - ("else", - MonitoringState( - title=_("Monitoring state if a monitored service is not found at all."), - default_value=2, - )), - ],), - TextAscii(title=_("Name of the service")), - match_type="dict", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "hacmp_resources", - _("AIX HACMP Resource Groups"), - Transform( - Dictionary( - elements=[ - ("expect_online_on", - DropdownChoice( - title=_(u"Expect resource to be online on"), - choices=[ - ("first", _(u"the first node")), - ("any", _(u"any node")), - ], - )), - ], - optional_keys=[], - ), - forth=lambda x: {"expect_online_on": "first"}, - ), - TextAscii(title=_(u"Resource Group")), - match_type="first", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "webserver", - _("Azure web servers (IIS)"), - Dictionary( - elements=[ - ( - "avg_response_time_levels", - Tuple( - title=_("Upper levels for average response time"), - elements=[ - Float(title=_("Warning at"), default_value=1.00, unit="s"), - Float(title=_("Critical at"), default_value=10.0, unit="s"), - ]), - ), - ( - "error_rate_levels", - Tuple( - title=_("Upper levels for rate of server errors"), - elements=[ - Float(title=_("Warning at"), default_value=0.01, unit="1/s"), - Float(title=_("Critical at"), default_value=0.04, unit="1/s"), - ]), - ), - ( - "cpu_time_percent_levels", - Tuple( - title=_("Upper levels for CPU time"), - elements=[ - Float(title=_("Warning at"), default_value=85., unit="%"), - Float(title=_("Critical at"), default_value=95., unit="%"), - ]), - ), - ],), - TextAscii(title=_("Name of the service")), - match_type="dict", -) - #. # .--Environment---------------------------------------------------------. # | _____ _ _ | diff --git a/cmk/gui/plugins/wato/check_parameters/webserver.py b/cmk/gui/plugins/wato/check_parameters/webserver.py new file mode 100644 index 0000000000..dfb70238f7 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/webserver.py @@ -0,0 +1,75 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at http://mathias-kettner.de/check_mk. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Float, + TextAscii, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "webserver", + _("Azure web servers (IIS)"), + Dictionary( + elements=[ + ( + "avg_response_time_levels", + Tuple( + title=_("Upper levels for average response time"), + elements=[ + Float(title=_("Warning at"), default_value=1.00, unit="s"), + Float(title=_("Critical at"), default_value=10.0, unit="s"), + ]), + ), + ( + "error_rate_levels", + Tuple( + title=_("Upper levels for rate of server errors"), + elements=[ + Float(title=_("Warning at"), default_value=0.01, unit="1/s"), + Float(title=_("Critical at"), default_value=0.04, unit="1/s"), + ]), + ), + ( + "cpu_time_percent_levels", + Tuple( + title=_("Upper levels for CPU time"), + elements=[ + Float(title=_("Warning at"), default_value=85., unit="%"), + Float(title=_("Critical at"), default_value=95., unit="%"), + ]), + ), + ],), + TextAscii(title=_("Name of the service")), + match_type="dict", +) -- 2.11.4.GIT