From e6efb8dbdd899e8d77db221357348c85e666712c Mon Sep 17 00:00:00 2001 From: Kenneth Okoh Date: Fri, 18 Jan 2019 11:23:21 +0100 Subject: [PATCH] Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393) Change-Id: I34b669d38403851245922a74dfaac1716daef9bd --- .../wato/check_parameters/antivir_update_age.py | 45 +++ .../plugins/wato/check_parameters/db2_backup.py | 55 +++ .../wato/check_parameters/db2_connections.py | 57 ++++ .../plugins/wato/check_parameters/db2_counters.py | 71 ++++ cmk/gui/plugins/wato/check_parameters/db2_mem.py | 44 +++ .../wato/check_parameters/db2_sortoverflow.py | 60 ++++ .../plugins/wato/check_parameters/logwatch_ec.py | 227 +++++++++++++ .../wato/check_parameters/synology_update.py | 71 ++++ cmk/gui/plugins/wato/check_parameters/unsorted.py | 369 --------------------- .../wato/check_parameters/windows_updates.py | 54 +++ .../plugins/wato/check_parameters/wmic_process.py | 57 ++++ 11 files changed, 741 insertions(+), 369 deletions(-) create mode 100644 cmk/gui/plugins/wato/check_parameters/antivir_update_age.py create mode 100644 cmk/gui/plugins/wato/check_parameters/db2_backup.py create mode 100644 cmk/gui/plugins/wato/check_parameters/db2_connections.py create mode 100644 cmk/gui/plugins/wato/check_parameters/db2_counters.py create mode 100644 cmk/gui/plugins/wato/check_parameters/db2_mem.py create mode 100644 cmk/gui/plugins/wato/check_parameters/db2_sortoverflow.py create mode 100644 cmk/gui/plugins/wato/check_parameters/logwatch_ec.py create mode 100644 cmk/gui/plugins/wato/check_parameters/synology_update.py create mode 100644 cmk/gui/plugins/wato/check_parameters/windows_updates.py create mode 100644 cmk/gui/plugins/wato/check_parameters/wmic_process.py diff --git a/cmk/gui/plugins/wato/check_parameters/antivir_update_age.py b/cmk/gui/plugins/wato/check_parameters/antivir_update_age.py new file mode 100644 index 0000000000..68026166ac --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/antivir_update_age.py @@ -0,0 +1,45 @@ +#!/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 ( + Age, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "antivir_update_age", + _("Age of last AntiVirus update"), + Tuple( + title=_("Age of last AntiVirus update"), + elements=[ + Age(title=_("Warning level for time since last update")), + Age(title=_("Critical level for time since last update")), + ]), None, "first") diff --git a/cmk/gui/plugins/wato/check_parameters/db2_backup.py b/cmk/gui/plugins/wato/check_parameters/db2_backup.py new file mode 100644 index 0000000000..0a4c8a92f3 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/db2_backup.py @@ -0,0 +1,55 @@ +#!/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 ( + Age, + Optional, + TextAscii, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "db2_backup", + _("DB2 Time since last database Backup"), + Optional( + Tuple(elements=[ + Age(title=_("Warning at"), + display=["days", "hours", "minutes"], + default_value=86400 * 14), + Age(title=_("Critical at"), + display=["days", "hours", "minutes"], + default_value=86400 * 28) + ]), + title=_("Specify time since last successful backup"), + ), + TextAscii( + title=_("Instance"), + help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), "first") diff --git a/cmk/gui/plugins/wato/check_parameters/db2_connections.py b/cmk/gui/plugins/wato/check_parameters/db2_connections.py new file mode 100644 index 0000000000..8c69694530 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/db2_connections.py @@ -0,0 +1,57 @@ +#!/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, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "db2_connections", _("DB2 Connections"), + Dictionary( + help=_("This rule allows you to set limits for the maximum number of DB2 connections"), + elements=[ + ( + "levels_total", + Tuple( + title=_("Number of current connections"), + elements=[ + Integer(title=_("Warning at"), unit=_("connections"), default_value=150), + Integer(title=_("Critical at"), unit=_("connections"), default_value=200), + ], + ), + ), + ]), + TextAscii( + title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), + "dict") diff --git a/cmk/gui/plugins/wato/check_parameters/db2_counters.py b/cmk/gui/plugins/wato/check_parameters/db2_counters.py new file mode 100644 index 0000000000..cc2b166c51 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/db2_counters.py @@ -0,0 +1,71 @@ +#!/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, + "db2_counters", + _("DB2 Counters"), + Dictionary( + help=_("This rule allows you to configure limits for the deadlocks and lockwaits " + "counters of a DB2."), + elements=[ + ( + "deadlocks", + Tuple( + title=_("Deadlocks"), + elements=[ + Float(title=_("Warning at"), unit=_("deadlocks/sec")), + Float(title=_("Critical at"), unit=_("deadlocks/sec")), + ], + ), + ), + ( + "lockwaits", + Tuple( + title=_("Lockwaits"), + elements=[ + Float(title=_("Warning at"), unit=_("lockwaits/sec")), + Float(title=_("Critical at"), unit=_("lockwaits/sec")), + ], + ), + ), + ]), + TextAscii( + title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), + "dict", +) diff --git a/cmk/gui/plugins/wato/check_parameters/db2_mem.py b/cmk/gui/plugins/wato/check_parameters/db2_mem.py new file mode 100644 index 0000000000..7cdfeed45e --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/db2_mem.py @@ -0,0 +1,44 @@ +#!/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 ( + Percentage, + TextAscii, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "db2_mem", _("Memory levels for DB2 memory usage"), + Tuple( + elements=[ + Percentage(title=_("Warning if less than"), unit=_("% memory left")), + Percentage(title=_("Critical if less than"), unit=_("% memory left")), + ],), TextAscii(title=_("Instance name"), allow_empty=True), "first") diff --git a/cmk/gui/plugins/wato/check_parameters/db2_sortoverflow.py b/cmk/gui/plugins/wato/check_parameters/db2_sortoverflow.py new file mode 100644 index 0000000000..0c106b94ae --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/db2_sortoverflow.py @@ -0,0 +1,60 @@ +#!/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, + Percentage, + TextAscii, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "db2_sortoverflow", + _("DB2 Sort Overflow"), + Dictionary( + help=_("This rule allows you to set percentual limits for sort overflows."), + elements=[ + ( + "levels_perc", + Tuple( + title=_("Overflows"), + elements=[ + Percentage(title=_("Warning at"), unit=_("%"), default_value=2.0), + Percentage(title=_("Critical at"), unit=_("%"), default_value=4.0), + ], + ), + ), + ]), + TextAscii( + title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), + "dict", +) diff --git a/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py b/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py new file mode 100644 index 0000000000..eaeef88020 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py @@ -0,0 +1,227 @@ +#!/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. + +import cmk.gui.mkeventd as mkeventd +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Age, + Alternative, + CascadingDropdown, + Checkbox, + Dictionary, + DropdownChoice, + Filesize, + FixedValue, + Integer, + ListOfStrings, + TextAscii, + Transform, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + + +register_check_parameters(RulespecGroupCheckParametersApplications, + "logwatch_ec", + _('Logwatch Event Console Forwarding'), + Alternative( + title = _("Forwarding"), + help = _("Instead of using the regular logwatch check all lines received by logwatch can " + "be forwarded to a Check_MK event console daemon to be processed. The target event " + "console can be configured for each host in a separate rule."), + style = "dropdown", + elements = [ + FixedValue( + "", + totext = _("Messages are handled by logwatch."), + title = _("No forwarding"), + ), + Dictionary( + title = _('Forward Messages to Event Console'), + elements = [ + ('method', Transform( + # TODO: Clean this up to some CascadingDropdown() + Alternative( + style = "dropdown", + title = _("Forwarding Method"), + elements = [ + FixedValue( + "", + title = _("Local: Send events to local Event Console in same OMD site"), + totext = _("Directly forward to Event Console"), + ), + TextAscii( + title = _("Local: Send events to local Event Console into unix socket"), + allow_empty = False, + ), + FixedValue( + "spool:", + title = _("Local: Spooling - Send events to local event console in same OMD site"), + totext = _("Spool to Event Console"), + ), + Transform( + TextAscii(), + title = _("Local: Spooling - Send events to local Event Console into given spool directory"), + allow_empty = False, + forth = lambda x: x[6:], + # remove prefix + back = lambda x: "spool:" + x, # add prefix + ), + CascadingDropdown( + title = _("Remote: Send events to remote syslog host"), + choices = [ + ("tcp", _("Send via TCP"), Dictionary( + elements = [ + ("address", TextAscii( + title = _("Address"), + allow_empty = False, + )), + ("port", Integer( + title = _("Port"), + allow_empty = False, + default_value = 514, + minvalue = 1, + maxvalue = 65535, + size = 6, + )), + ("spool", Dictionary( + title = _("Spool messages that could not be sent"), + help = _("Messages that can not be forwarded, e.g. when the target Event Console is " + "not running, can temporarily be stored locally. Forwarding is tried again " + "on next execution. When messages are spooled, the check will go into WARNING " + "state. In case messages are dropped by the rules below, the check will shortly " + "go into CRITICAL state for this execution."), + elements = [ + ("max_age", Age( + title = _("Maximum spool duration"), + help = _("Messages that are spooled longer than this time will be thrown away."), + default_value = 60*60*24*7, # 1 week should be fine (if size is not exceeded) + )), + ("max_size", Filesize( + title = _("Maximum spool size"), + help = _("When the total size of spooled messages exceeds this number, the oldest " + "messages of the currently spooled messages is thrown away until the left " + "messages have the half of the maximum size."), + default_value = 500000, # do not save more than 500k of message + )), + ], + optional_keys = [], + )), + ], + optional_keys = [ "spool" ], + )), + ("udp", _("Send via UDP"), Dictionary( + elements = [ + ("address", TextAscii( + title = _("Address"), + allow_empty = False, + )), + ("port", Integer( + title = _("Port"), + allow_empty = False, + default_value = 514, + minvalue = 1, + maxvalue = 65535, + size = 6, + )), + ], + optional_keys = [], + )), + ], + ), + ], + match = lambda x: 4 if isinstance(x, tuple) else (0 if not x else (2 if x == 'spool:' else (3 if x.startswith('spool:') else 1))) + ), + # migrate old (tcp, address, port) tuple to new dict + forth = lambda v: (v[0], {"address": v[1], "port": v[2]}) if (isinstance(v, tuple) and not isinstance(v[1], dict)) else v, + )), + ('facility', DropdownChoice( + title = _("Syslog facility for forwarded messages"), + help = _("When forwarding messages and no facility can be extracted from the " + "message this facility is used."), + choices = mkeventd.syslog_facilities, + default_value = 17, # local1 + )), + ('restrict_logfiles', + ListOfStrings( + title = _('Restrict Logfiles (Prefix matching regular expressions)'), + help = _("Put the item names of the logfiles here. For example \"System$\" " + "to select the service \"LOG System\". You can use regular expressions " + "which must match the beginning of the logfile name."), + ), + ), + ('monitor_logfilelist', + Checkbox( + title = _("Monitoring of forwarded logfiles"), + label = _("Warn if list of forwarded logfiles changes"), + help = _("If this option is enabled, the check monitors the list of forwarded " + "logfiles and will warn you if at any time a logfile is missing or exceeding " + "when compared to the initial list that was snapshotted during service detection. " + "Reinventorize this check in order to make it OK again."), + ) + ), + ('expected_logfiles', + ListOfStrings( + title = _("List of expected logfiles"), + help = _("When the monitoring of forwarded logfiles is enabled, the check verifies that " + "all of the logfiles listed here are reported by the monitored system."), + ) + ), + ('logwatch_reclassify', + Checkbox( + title = _("Reclassify messages before forwarding them to the EC"), + label = _("Apply logwatch patterns"), + help = _("If this option is enabled, the logwatch lines are first reclassified by the logwatch " + "patterns before they are sent to the event console. If you reclassify specific lines to " + "IGNORE they are not forwarded to the event console. This takes the burden from the " + "event console to process the message itself through all of its rulesets. The reclassifcation " + "of each line takes into account from which logfile the message originates. So you can create " + "logwatch reclassification rules specifically designed for a logfile access.log, " + "which do not apply to other logfiles."), + ) + ), + ('separate_checks', + Checkbox( + title = _("Create a separate check for each logfile"), + label = _("Separate check"), + help = _("If this option is enabled, there will be one separate check for each logfile found during " + "the service discovery. This option also changes the behaviour for unknown logfiles. " + "The default logwatch check forwards all logfiles to the event console, even logfiles " + "which were not known during the service discovery. Creating one check per logfile changes " + "this behaviour so that any data from unknown logfiles is discarded."), + ) + ) + ], + optional_keys = ['restrict_logfiles', 'expected_logfiles', 'logwatch_reclassify', 'separate_checks'], + ), + ], + default_value = '', + ), + None, + 'first', + )# wmic_process does not support inventory at the moment diff --git a/cmk/gui/plugins/wato/check_parameters/synology_update.py b/cmk/gui/plugins/wato/check_parameters/synology_update.py new file mode 100644 index 0000000000..821a8a12c3 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/synology_update.py @@ -0,0 +1,71 @@ +#!/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, + ListChoice, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +synology_update_states = [ + (1, "Available"), + (2, "Unavailable"), + (4, "Disconnected"), + (5, "Others"), +] + +register_check_parameters( + RulespecGroupCheckParametersApplications, + "synology_update", + _("Synology Updates"), + Dictionary( + title=_("Update State"), + elements=[ + ("ok_states", + ListChoice( + title=_("States which result in OK"), + choices=synology_update_states, + default_value=[2])), + ("warn_states", + ListChoice( + title=_("States which result in Warning"), + choices=synology_update_states, + default_value=[5])), + ("crit_states", + ListChoice( + title=_("States which result in Critical"), + choices=synology_update_states, + default_value=[1, 4])), + ], + optional_keys=None, + ), + None, + match_type="dict", +) diff --git a/cmk/gui/plugins/wato/check_parameters/unsorted.py b/cmk/gui/plugins/wato/check_parameters/unsorted.py index e5a2944d0d..06a1080172 100644 --- a/cmk/gui/plugins/wato/check_parameters/unsorted.py +++ b/cmk/gui/plugins/wato/check_parameters/unsorted.py @@ -29,7 +29,6 @@ import cmk.utils.defines as defines from cmk.gui.plugins.wato.active_checks import check_icmp_params -import cmk.gui.mkeventd as mkeventd from cmk.gui.exceptions import MKUserError from cmk.gui.i18n import _ from cmk.gui.valuespec import ( @@ -49,7 +48,6 @@ from cmk.gui.valuespec import ( Transform, ListOf, ListOfStrings, - CascadingDropdown, FixedValue, Optional, MonitoringState, @@ -959,352 +957,6 @@ register_rule( match='dict', ) -register_check_parameters( - RulespecGroupCheckParametersApplications, - "db2_sortoverflow", - _("DB2 Sort Overflow"), - Dictionary( - help=_("This rule allows you to set percentual limits for sort overflows."), - elements=[ - ( - "levels_perc", - Tuple( - title=_("Overflows"), - elements=[ - Percentage(title=_("Warning at"), unit=_("%"), default_value=2.0), - Percentage(title=_("Critical at"), unit=_("%"), default_value=4.0), - ], - ), - ), - ]), - TextAscii( - title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), - "dict", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, "db2_connections", _("DB2 Connections"), - Dictionary( - help=_("This rule allows you to set limits for the maximum number of DB2 connections"), - elements=[ - ( - "levels_total", - Tuple( - title=_("Number of current connections"), - elements=[ - Integer(title=_("Warning at"), unit=_("connections"), default_value=150), - Integer(title=_("Critical at"), unit=_("connections"), default_value=200), - ], - ), - ), - ]), - TextAscii( - title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), - "dict") - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "db2_counters", - _("DB2 Counters"), - Dictionary( - help=_("This rule allows you to configure limits for the deadlocks and lockwaits " - "counters of a DB2."), - elements=[ - ( - "deadlocks", - Tuple( - title=_("Deadlocks"), - elements=[ - Float(title=_("Warning at"), unit=_("deadlocks/sec")), - Float(title=_("Critical at"), unit=_("deadlocks/sec")), - ], - ), - ), - ( - "lockwaits", - Tuple( - title=_("Lockwaits"), - elements=[ - Float(title=_("Warning at"), unit=_("lockwaits/sec")), - Float(title=_("Critical at"), unit=_("lockwaits/sec")), - ], - ), - ), - ]), - TextAscii( - title=_("Instance"), help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), - "dict", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, "db2_backup", - _("DB2 Time since last database Backup"), - Optional( - Tuple(elements=[ - Age(title=_("Warning at"), - display=["days", "hours", "minutes"], - default_value=86400 * 14), - Age(title=_("Critical at"), - display=["days", "hours", "minutes"], - default_value=86400 * 28) - ]), - title=_("Specify time since last successful backup"), - ), - TextAscii( - title=_("Instance"), - help=_("DB2 instance followed by database name, e.g db2taddm:CMDBS1")), "first") - -register_check_parameters( - RulespecGroupCheckParametersApplications, "db2_mem", _("Memory levels for DB2 memory usage"), - Tuple( - elements=[ - Percentage(title=_("Warning if less than"), unit=_("% memory left")), - Percentage(title=_("Critical if less than"), unit=_("% memory left")), - ],), TextAscii(title=_("Instance name"), allow_empty=True), "first") - -register_check_parameters( - RulespecGroupCheckParametersApplications, "windows_updates", _("WSUS (Windows Updates)"), - Tuple( - title=_("Parameters for the Windows Update Check with WSUS"), - help=_("Set the according numbers to 0 if you want to disable alerting."), - elements=[ - Integer(title=_("Warning if at least this number of important updates are pending")), - Integer(title=_("Critical if at least this number of important updates are pending")), - Integer(title=_("Warning if at least this number of optional updates are pending")), - Integer(title=_("Critical if at least this number of optional updates are pending")), - Age(title=_("Warning if time until forced reboot is less then"), default_value=604800), - Age(title=_("Critical if time time until forced reboot is less then"), - default_value=172800), - Checkbox(title=_("display all important updates verbosely"), default_value=True), - ], - ), None, "first") - -synology_update_states = [ - (1, "Available"), - (2, "Unavailable"), - (4, "Disconnected"), - (5, "Others"), -] - -register_check_parameters( - RulespecGroupCheckParametersApplications, - "synology_update", - _("Synology Updates"), - Dictionary( - title=_("Update State"), - elements=[ - ("ok_states", - ListChoice( - title=_("States which result in OK"), - choices=synology_update_states, - default_value=[2])), - ("warn_states", - ListChoice( - title=_("States which result in Warning"), - choices=synology_update_states, - default_value=[5])), - ("crit_states", - ListChoice( - title=_("States which result in Critical"), - choices=synology_update_states, - default_value=[1, 4])), - ], - optional_keys=None, - ), - None, - match_type="dict", -) - -register_check_parameters( - RulespecGroupCheckParametersApplications, "antivir_update_age", - _("Age of last AntiVirus update"), - Tuple( - title=_("Age of last AntiVirus update"), - elements=[ - Age(title=_("Warning level for time since last update")), - Age(title=_("Critical level for time since last update")), - ]), None, "first") - -register_check_parameters(RulespecGroupCheckParametersApplications, - "logwatch_ec", - _('Logwatch Event Console Forwarding'), - Alternative( - title = _("Forwarding"), - help = _("Instead of using the regular logwatch check all lines received by logwatch can " - "be forwarded to a Check_MK event console daemon to be processed. The target event " - "console can be configured for each host in a separate rule."), - style = "dropdown", - elements = [ - FixedValue( - "", - totext = _("Messages are handled by logwatch."), - title = _("No forwarding"), - ), - Dictionary( - title = _('Forward Messages to Event Console'), - elements = [ - ('method', Transform( - # TODO: Clean this up to some CascadingDropdown() - Alternative( - style = "dropdown", - title = _("Forwarding Method"), - elements = [ - FixedValue( - "", - title = _("Local: Send events to local Event Console in same OMD site"), - totext = _("Directly forward to Event Console"), - ), - TextAscii( - title = _("Local: Send events to local Event Console into unix socket"), - allow_empty = False, - ), - - FixedValue( - "spool:", - title = _("Local: Spooling - Send events to local event console in same OMD site"), - totext = _("Spool to Event Console"), - ), - Transform( - TextAscii(), - title = _("Local: Spooling - Send events to local Event Console into given spool directory"), - allow_empty = False, - forth = lambda x: x[6:], # remove prefix - back = lambda x: "spool:" + x, # add prefix - ), - CascadingDropdown( - title = _("Remote: Send events to remote syslog host"), - choices = [ - ("tcp", _("Send via TCP"), Dictionary( - elements = [ - ("address", TextAscii( - title = _("Address"), - allow_empty = False, - )), - ("port", Integer( - title = _("Port"), - allow_empty = False, - default_value = 514, - minvalue = 1, - maxvalue = 65535, - size = 6, - )), - ("spool", Dictionary( - title = _("Spool messages that could not be sent"), - help = _("Messages that can not be forwarded, e.g. when the target Event Console is " - "not running, can temporarily be stored locally. Forwarding is tried again " - "on next execution. When messages are spooled, the check will go into WARNING " - "state. In case messages are dropped by the rules below, the check will shortly " - "go into CRITICAL state for this execution."), - elements = [ - ("max_age", Age( - title = _("Maximum spool duration"), - help = _("Messages that are spooled longer than this time will be thrown away."), - default_value = 60*60*24*7, # 1 week should be fine (if size is not exceeded) - )), - ("max_size", Filesize( - title = _("Maximum spool size"), - help = _("When the total size of spooled messages exceeds this number, the oldest " - "messages of the currently spooled messages is thrown away until the left " - "messages have the half of the maximum size."), - default_value = 500000, # do not save more than 500k of message - )), - ], - optional_keys = [], - )), - ], - optional_keys = [ "spool" ], - )), - ("udp", _("Send via UDP"), Dictionary( - elements = [ - ("address", TextAscii( - title = _("Address"), - allow_empty = False, - )), - ("port", Integer( - title = _("Port"), - allow_empty = False, - default_value = 514, - minvalue = 1, - maxvalue = 65535, - size = 6, - )), - ], - optional_keys = [], - )), - ], - ), - ], - match = lambda x: 4 if isinstance(x, tuple) else (0 if not x else (2 if x == 'spool:' else (3 if x.startswith('spool:') else 1))) - ), - # migrate old (tcp, address, port) tuple to new dict - forth = lambda v: (v[0], {"address": v[1], "port": v[2]}) if (isinstance(v, tuple) and not isinstance(v[1], dict)) else v, - )), - ('facility', DropdownChoice( - title = _("Syslog facility for forwarded messages"), - help = _("When forwarding messages and no facility can be extracted from the " - "message this facility is used."), - choices = mkeventd.syslog_facilities, - default_value = 17, # local1 - )), - ('restrict_logfiles', - ListOfStrings( - title = _('Restrict Logfiles (Prefix matching regular expressions)'), - help = _("Put the item names of the logfiles here. For example \"System$\" " - "to select the service \"LOG System\". You can use regular expressions " - "which must match the beginning of the logfile name."), - ), - ), - ('monitor_logfilelist', - Checkbox( - title = _("Monitoring of forwarded logfiles"), - label = _("Warn if list of forwarded logfiles changes"), - help = _("If this option is enabled, the check monitors the list of forwarded " - "logfiles and will warn you if at any time a logfile is missing or exceeding " - "when compared to the initial list that was snapshotted during service detection. " - "Reinventorize this check in order to make it OK again."), - ) - ), - ('expected_logfiles', - ListOfStrings( - title = _("List of expected logfiles"), - help = _("When the monitoring of forwarded logfiles is enabled, the check verifies that " - "all of the logfiles listed here are reported by the monitored system."), - ) - ), - ('logwatch_reclassify', - Checkbox( - title = _("Reclassify messages before forwarding them to the EC"), - label = _("Apply logwatch patterns"), - help = _("If this option is enabled, the logwatch lines are first reclassified by the logwatch " - "patterns before they are sent to the event console. If you reclassify specific lines to " - "IGNORE they are not forwarded to the event console. This takes the burden from the " - "event console to process the message itself through all of its rulesets. The reclassifcation " - "of each line takes into account from which logfile the message originates. So you can create " - "logwatch reclassification rules specifically designed for a logfile access.log, " - "which do not apply to other logfiles."), - ) - ), - ('separate_checks', - Checkbox( - title = _("Create a separate check for each logfile"), - label = _("Separate check"), - help = _("If this option is enabled, there will be one separate check for each logfile found during " - "the service discovery. This option also changes the behaviour for unknown logfiles. " - "The default logwatch check forwards all logfiles to the event console, even logfiles " - "which were not known during the service discovery. Creating one check per logfile changes " - "this behaviour so that any data from unknown logfiles is discarded."), - ) - ) - ], - optional_keys = ['restrict_logfiles', 'expected_logfiles', 'logwatch_reclassify', 'separate_checks'], - ), - ], - default_value = '', - ), - None, - 'first', - ) - register_rule( RulespecGroupCheckParametersApplications, varname="logwatch_groups", @@ -1348,27 +1000,6 @@ register_rule( "in those counters. Listing those hosts in this rule forces " "them to use the interface check with 32 bit counters instead.")) -# wmic_process does not support inventory at the moment -register_check_parameters( - RulespecGroupCheckParametersApplications, "wmic_process", - _("Memory and CPU of processes on Windows"), - Tuple( - elements=[ - TextAscii( - title=_("Name of the process"), - allow_empty=False, - ), - Integer(title=_("Memory warning at"), unit="MB"), - Integer(title=_("Memory critical at"), unit="MB"), - Integer(title=_("Pagefile warning at"), unit="MB"), - Integer(title=_("Pagefile critical at"), unit="MB"), - Percentage(title=_("CPU usage warning at")), - Percentage(title=_("CPU usage critical at")), - ],), - TextAscii( - title=_("Process name for usage in the Nagios service description"), allow_empty=False), - "first", False) - register_check_parameters( RulespecGroupCheckParametersOperatingSystem, "zypper", diff --git a/cmk/gui/plugins/wato/check_parameters/windows_updates.py b/cmk/gui/plugins/wato/check_parameters/windows_updates.py new file mode 100644 index 0000000000..d79bf3c587 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/windows_updates.py @@ -0,0 +1,54 @@ +#!/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 ( + Age, + Checkbox, + Integer, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "windows_updates", _("WSUS (Windows Updates)"), + Tuple( + title=_("Parameters for the Windows Update Check with WSUS"), + help=_("Set the according numbers to 0 if you want to disable alerting."), + elements=[ + Integer(title=_("Warning if at least this number of important updates are pending")), + Integer(title=_("Critical if at least this number of important updates are pending")), + Integer(title=_("Warning if at least this number of optional updates are pending")), + Integer(title=_("Critical if at least this number of optional updates are pending")), + Age(title=_("Warning if time until forced reboot is less then"), default_value=604800), + Age(title=_("Critical if time time until forced reboot is less then"), + default_value=172800), + Checkbox(title=_("display all important updates verbosely"), default_value=True), + ], + ), None, "first") diff --git a/cmk/gui/plugins/wato/check_parameters/wmic_process.py b/cmk/gui/plugins/wato/check_parameters/wmic_process.py new file mode 100644 index 0000000000..055a21fd40 --- /dev/null +++ b/cmk/gui/plugins/wato/check_parameters/wmic_process.py @@ -0,0 +1,57 @@ +#!/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 ( + Integer, + Percentage, + TextAscii, + Tuple, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersApplications, + register_check_parameters, +) + +register_check_parameters( + RulespecGroupCheckParametersApplications, "wmic_process", + _("Memory and CPU of processes on Windows"), + Tuple( + elements=[ + TextAscii( + title=_("Name of the process"), + allow_empty=False, + ), + Integer(title=_("Memory warning at"), unit="MB"), + Integer(title=_("Memory critical at"), unit="MB"), + Integer(title=_("Pagefile warning at"), unit="MB"), + Integer(title=_("Pagefile critical at"), unit="MB"), + Percentage(title=_("CPU usage warning at")), + Percentage(title=_("CPU usage critical at")), + ],), + TextAscii( + title=_("Process name for usage in the Nagios service description"), allow_empty=False), + "first", False) -- 2.11.4.GIT