From 5ff6ec61331ce0bbcebd9b87a2bce14dc5366b03 Mon Sep 17 00:00:00 2001 From: Kenneth Okoh Date: Fri, 18 Jan 2019 12:45:02 +0100 Subject: [PATCH] Refactoring: Moved rules from unsorted.py to matching modules (CMK-1393) Change-Id: I2f1ad301539a82ca1dc57239dc376adc2853d405 --- cmk/gui/plugins/wato/check_parameters/diskstat.py | 26 + .../plugins/wato/check_parameters/domino_tasks.py | 94 ++ .../wato/check_parameters/fileinfo-groups.py | 58 ++ .../plugins/wato/check_parameters/filesystem.py | 72 +- .../plugins/wato/check_parameters/heartbeat_crm.py | 33 + cmk/gui/plugins/wato/check_parameters/if.py | 111 +++ .../plugins/wato/check_parameters/logwatch_ec.py | 155 ++++ .../plugins/wato/check_parameters/msx_queues.py | 32 + cmk/gui/plugins/wato/check_parameters/multipath.py | 25 + cmk/gui/plugins/wato/check_parameters/unsorted.py | 995 ++++----------------- 10 files changed, 800 insertions(+), 801 deletions(-) rewrite cmk/gui/plugins/wato/check_parameters/unsorted.py (77%) diff --git a/cmk/gui/plugins/wato/check_parameters/diskstat.py b/cmk/gui/plugins/wato/check_parameters/diskstat.py index 4314000930..374efd576e 100644 --- a/cmk/gui/plugins/wato/check_parameters/diskstat.py +++ b/cmk/gui/plugins/wato/check_parameters/diskstat.py @@ -28,14 +28,40 @@ from cmk.gui.i18n import _ from cmk.gui.valuespec import ( Age, Dictionary, + ListChoice, TextAscii, ) from cmk.gui.plugins.wato import ( Levels, RulespecGroupCheckParametersStorage, register_check_parameters, + register_rule, ) +register_rule( + RulespecGroupCheckParametersStorage, + "diskstat_inventory", + ListChoice( + title=_("Discovery mode for Disk IO check"), + help=_("This rule controls which and how many checks will be created " + "for monitoring individual physical and logical disks. " + "Note: the option Create a summary for all read, one for " + "write has been removed. Some checks will still support " + "this settings, but it will be removed there soon."), + choices=[ + ("summary", _("Create a summary over all physical disks")), + # This option is still supported by some checks, but is deprecated and + # we fade it out... + # ( "legacy", _("Create a summary for all read, one for write") ), + ("physical", _("Create a separate check for each physical disk")), + ("lvm", _("Create a separate check for each LVM volume (Linux)")), + ("vxvm", _("Creata a separate check for each VxVM volume (Linux)")), + ("diskless", _("Creata a separate check for each partition (XEN)")), + ], + default_value=['summary'], + ), + match="first") + register_check_parameters( RulespecGroupCheckParametersStorage, "diskstat", diff --git a/cmk/gui/plugins/wato/check_parameters/domino_tasks.py b/cmk/gui/plugins/wato/check_parameters/domino_tasks.py index 0601be7532..a6d55b566c 100644 --- a/cmk/gui/plugins/wato/check_parameters/domino_tasks.py +++ b/cmk/gui/plugins/wato/check_parameters/domino_tasks.py @@ -33,10 +33,104 @@ from cmk.gui.valuespec import ( RegExp, TextAscii, Transform, + Tuple, ) from cmk.gui.plugins.wato import ( RulespecGroupCheckParametersApplications, + RulespecGroupCheckParametersDiscovery, register_check_parameters, + register_rule, +) + +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="inv_domino_tasks_rules", + title=_('Lotus Domino Task Discovery'), + help=_("This rule controls the discovery of tasks on Lotus Domino systems. " + "Any changes later on require a host re-discovery"), + valuespec=Dictionary( + elements=[ + ('descr', + TextAscii( + title=_('Service Description'), + allow_empty=False, + help= + _('

The service description may contain one or more occurances of %s. In this ' + 'case, the pattern must be a regular expression prefixed with ~. For each ' + '%s in the description, the expression has to contain one "group". A group ' + 'is a subexpression enclosed in brackets, for example (.*) or ' + '([a-zA-Z]+) or (...). When the inventory finds a task ' + 'matching the pattern, it will substitute all such groups with the actual values when ' + 'creating the check. In this way one rule can create several checks on a host.

' + '

If the pattern contains more groups than occurrences of %s in the service ' + 'description, only the first matching subexpressions are used for the service ' + 'descriptions. The matched substrings corresponding to the remaining groups ' + 'are nevertheless copied into the regular expression.

' + '

As an alternative to %s you may also use %1, %2, etc. ' + 'These expressions will be replaced by the first, second, ... matching group, allowing ' + 'you to reorder things.

'), + )), + ( + 'match', + Alternative( + title=_("Task Matching"), + elements=[ + TextAscii( + title=_("Exact name of the task"), + size=50, + ), + Transform( + RegExp( + size=50, + mode=RegExp.prefix, + ), + title=_("Regular expression matching command line"), + help=_("This regex must match the beginning of the task"), + forth=lambda x: x[1:], # remove ~ + back=lambda x: "~" + x, # prefix ~ + ), + FixedValue( + None, + totext="", + title=_("Match all tasks"), + ) + ], + match=lambda x: (not x and 2) or (x[0] == '~' and 1 or 0), + default_value='foo')), + ('levels', + Tuple( + title=_('Levels'), + help= + _("Please note that if you specify and also if you modify levels here, the change is " + "activated only during an inventory. Saving this rule is not enough. This is due to " + "the nature of inventory rules."), + elements=[ + Integer( + title=_("Critical below"), + unit=_("processes"), + default_value=1, + ), + Integer( + title=_("Warning below"), + unit=_("processes"), + default_value=1, + ), + Integer( + title=_("Warning above"), + unit=_("processes"), + default_value=1, + ), + Integer( + title=_("Critical above"), + unit=_("processes"), + default_value=1, + ), + ], + )), + ], + required_keys=['match', 'levels', 'descr'], + ), + match='all', ) register_check_parameters( diff --git a/cmk/gui/plugins/wato/check_parameters/fileinfo-groups.py b/cmk/gui/plugins/wato/check_parameters/fileinfo-groups.py index c692635760..f27de26f6b 100644 --- a/cmk/gui/plugins/wato/check_parameters/fileinfo-groups.py +++ b/cmk/gui/plugins/wato/check_parameters/fileinfo-groups.py @@ -35,11 +35,69 @@ from cmk.gui.valuespec import ( ListOfTimeRanges, MonitoringState, TextAscii, + Transform, Tuple, ) from cmk.gui.plugins.wato import ( RulespecGroupCheckParametersStorage, register_check_parameters, + register_rule, +) + +register_rule( + RulespecGroupCheckParametersStorage, + varname="fileinfo_groups", + title=_('File Grouping Patterns'), + help=_('The check fileinfo monitors the age and size of ' + 'a single file. Each file information that is sent ' + 'by the agent will create one service. By defining grouping ' + 'patterns you can switch to the check fileinfo.groups. ' + 'That check monitors a list of files at once. You can set levels ' + 'not only for the total size and the age of the oldest/youngest ' + 'file but also on the count. You can define one or several ' + 'patterns for a group containing * and ?, for example ' + '/var/log/apache/*.log. Please see Python\'s fnmatch for more ' + 'information regarding globbing patterns and special characters. ' + 'If the pattern begins with a tilde then this pattern is interpreted as ' + 'a regular expression instead of as a filename globbing pattern and ' + '* and ? are treated differently. ' + 'For files contained in a group ' + 'the discovery will automatically create a group service instead ' + 'of single services for each file. This rule also applies when ' + 'you use manually configured checks instead of inventorized ones. ' + 'Furthermore, the current time/date in a configurable format ' + 'may be included in the include pattern. The syntax is as follows: ' + '$DATE:format-spec$ or $YESTERDAY:format-spec$, where format-spec ' + 'is a list of time format directives of the unix date command. ' + 'Example: $DATE:%Y%m%d$ is todays date, e.g. 20140127. A pattern ' + 'of /var/tmp/backups/$DATE:%Y%m%d$.txt would search for .txt files ' + 'with todays date as name in the directory /var/tmp/backups. ' + 'The YESTERDAY syntax simply subtracts one day from the reference time.'), + valuespec=ListOf( + Tuple( + help=_("This defines one file grouping pattern."), + show_titles=True, + orientation="horizontal", + elements=[ + TextAscii( + title=_("Name of group"), + size=10, + ), + Transform( + Tuple( + show_titles=True, + orientation="vertical", + elements=[ + TextAscii(title=_("Include Pattern"), size=40), + TextAscii(title=_("Exclude Pattern"), size=40), + ], + ), + forth=lambda params: isinstance(params, str) and (params, '') or params), + ], + ), + add_label=_("Add pattern group"), + ), + match='all', ) register_check_parameters( diff --git a/cmk/gui/plugins/wato/check_parameters/filesystem.py b/cmk/gui/plugins/wato/check_parameters/filesystem.py index 98c0e6010f..626914d51b 100644 --- a/cmk/gui/plugins/wato/check_parameters/filesystem.py +++ b/cmk/gui/plugins/wato/check_parameters/filesystem.py @@ -25,13 +25,83 @@ # Boston, MA 02110-1301 USA. from cmk.gui.i18n import _ -from cmk.gui.valuespec import TextAscii +from cmk.gui.valuespec import ( + Checkbox, + Dictionary, + ListChoice, + ListOf, + TextAscii, + TextUnicode, + Tuple, +) from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersDiscovery, RulespecGroupCheckParametersStorage, register_check_parameters, + register_rule, ) from cmk.gui.plugins.wato.check_parameters.utils import vs_filesystem +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="inventory_df_rules", + title=_("Discovery parameters for filesystem checks"), + valuespec=Dictionary( + elements=[ + ("include_volume_name", Checkbox(title=_("Include Volume name in item"))), + ("ignore_fs_types", + ListChoice( + title=_("Filesystem types to ignore"), + choices=[ + ("tmpfs", "tmpfs"), + ("nfs", "nfs"), + ("smbfs", "smbfs"), + ("cifs", "cifs"), + ("iso9660", "iso9660"), + ], + default_value=["tmpfs", "nfs", "smbfs", "cifs", "iso9660"])), + ("never_ignore_mountpoints", + ListOf( + TextUnicode(), + title=_(u"Mountpoints to never ignore"), + help=_( + u"Regardless of filesystem type, these mountpoints will always be discovered." + u"Globbing or regular expressions are currently not supported."), + )), + ],), + match="dict", +) + +register_rule( + RulespecGroupCheckParametersStorage, + varname="filesystem_groups", + title=_('Filesystem grouping patterns'), + help=_('Normally the filesystem checks (df, hr_fs and others) ' + 'will create a single service for each filesystem. ' + 'By defining grouping ' + 'patterns you can handle groups of filesystems like one filesystem. ' + 'For each group you can define one or several patterns. ' + 'The filesystems matching one of the patterns ' + 'will be monitored like one big filesystem in a single service.'), + valuespec=ListOf( + Tuple( + show_titles=True, + orientation="horizontal", + elements=[ + TextAscii(title=_("Name of group"),), + TextAscii( + title=_("Pattern for mount point (using * and ?)"), + help=_("You can specify one or several patterns containing " + "* and ?, for example /spool/tmpspace*. " + "The filesystems matching the patterns will be monitored " + "like one big filesystem in a single service."), + ), + ]), + add_label=_("Add pattern"), + ), + match='all', +) + register_check_parameters( RulespecGroupCheckParametersStorage, "filesystem", _("Filesystems (used space and growth)"), vs_filesystem(), diff --git a/cmk/gui/plugins/wato/check_parameters/heartbeat_crm.py b/cmk/gui/plugins/wato/check_parameters/heartbeat_crm.py index c0240cfd75..5b7ec8a0e2 100644 --- a/cmk/gui/plugins/wato/check_parameters/heartbeat_crm.py +++ b/cmk/gui/plugins/wato/check_parameters/heartbeat_crm.py @@ -26,14 +26,47 @@ from cmk.gui.i18n import _ from cmk.gui.valuespec import ( + Checkbox, + Dictionary, Integer, Optional, TextAscii, Tuple, ) from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersDiscovery, RulespecGroupCheckParametersStorage, register_check_parameters, + register_rule, +) + +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="inventory_heartbeat_crm_rules", + title=_("Heartbeat CRM Discovery"), + valuespec=Dictionary( + elements=[ + ("naildown_dc", + Checkbox( + title=_("Naildown the DC"), + label=_("Mark the currently distinguished controller as preferred one"), + help=_( + "Nails down the DC to the node which is the DC during discovery. The check " + "will report CRITICAL when another node becomes the DC during later checks.")) + ), + ("naildown_resources", + Checkbox( + title=_("Naildown the resources"), + label=_("Mark the nodes of the resources as preferred one"), + help=_( + "Nails down the resources to the node which is holding them during discovery. " + "The check will report CRITICAL when another holds the resource during later checks." + ))), + ], + help=_('This rule can be used to control the discovery for Heartbeat CRM checks.'), + optional_keys=[], + ), + match='dict', ) register_check_parameters( diff --git a/cmk/gui/plugins/wato/check_parameters/if.py b/cmk/gui/plugins/wato/check_parameters/if.py index f4df296e4e..cb598a4f47 100644 --- a/cmk/gui/plugins/wato/check_parameters/if.py +++ b/cmk/gui/plugins/wato/check_parameters/if.py @@ -108,6 +108,23 @@ def transform_if(v): return v +def transform_if_groups_forth(params): + for param in params: + if param.get("name"): + param["group_name"] = param["name"] + del param["name"] + if param.get("include_items"): + param["items"] = param["include_items"] + del param["include_items"] + if param.get("single") is not None: + if param["single"]: + param["group_presence"] = "instead" + else: + param["group_presence"] = "separate" + del param["single"] + return params + + register_rule( RulespecGroupCheckParametersDiscovery, varname="inventory_if_rules", @@ -230,6 +247,100 @@ register_rule( match='list', ) +vs_elements_if_groups_matches = [ + ("iftype", + Transform( + DropdownChoice( + title=_("Select interface port type"), + choices=defines.interface_port_types(), + help=_("Only interfaces with the given port type are put into this group. " + "For example 53 (propVirtual)."), + ), + forth=str, + back=int, + )), + ("items", + ListOfStrings( + title=_("Restrict interface items"), + help=_("Only interface with these item names are put into this group."), + )), +] + +vs_elements_if_groups_group = [ + ("group_name", + TextAscii( + title=_("Group name"), + help=_("Name of group in service description"), + allow_empty=False, + )), + ("group_presence", + DropdownChoice( + title=_("Group interface presence"), + help=_("Determine whether the group interface is created as an " + "separate service or not. In second case the choosen interface " + "services disapear."), + choices=[ + ("separate", _("List grouped interfaces separately")), + ("instead", _("List grouped interfaces instead")), + ], + default_value="instead", + )), +] + +register_rule( + RulespecGroupCheckParametersNetworking, + varname="if_groups", + title=_('Network interface groups'), + help=_( + 'Normally the Interface checks create a single service for interface. ' + 'By defining if-group patterns multiple interfaces can be combined together. ' + 'A single service is created for this interface group showing the total traffic amount ' + 'of its members. You can configure if interfaces which are identified as group interfaces ' + 'should not show up as single service. You can restrict grouped interfaces by iftype and the ' + 'item name of the single interface.'), + valuespec=Transform( + Alternative( + style="dropdown", + elements=[ + ListOf( + title=_("Groups on single host"), + add_label=_("Add pattern"), + valuespec=Dictionary( + elements=vs_elements_if_groups_group + vs_elements_if_groups_matches, + required_keys=["group_name", "group_presence"]), + ), + ListOf( + magic="@!!", + title=_("Groups on cluster"), + add_label=_("Add pattern"), + valuespec=Dictionary( + elements=vs_elements_if_groups_group + + [("node_patterns", + ListOf( + title=_("Patterns for each node"), + add_label=_("Add pattern"), + valuespec=Dictionary( + elements=[("node_name", TextAscii(title=_("Node name")))] + + vs_elements_if_groups_matches, + required_keys=["node_name"]), + allow_empty=False, + ))], + optional_keys=[])), + ], + ), + forth=transform_if_groups_forth), + match='all', +) + +register_rule( + RulespecGroupCheckParametersNetworking, + "if_disable_if64_hosts", + title=_("Hosts forced to use if instead of if64"), + help=_("A couple of switches with broken firmware report that they " + "support 64 bit counters but do not output any actual data " + "in those counters. Listing those hosts in this rule forces " + "them to use the interface check with 32 bit counters instead.")) + register_check_parameters( RulespecGroupCheckParametersNetworking, "if", diff --git a/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py b/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py index eaeef88020..1d3a5e9e82 100644 --- a/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py +++ b/cmk/gui/plugins/wato/check_parameters/logwatch_ec.py @@ -36,15 +36,170 @@ from cmk.gui.valuespec import ( Filesize, FixedValue, Integer, + ListOf, ListOfStrings, + RegExp, + RegExpUnicode, TextAscii, + TextUnicode, Transform, + Tuple, ) from cmk.gui.plugins.wato import ( RulespecGroupCheckParametersApplications, register_check_parameters, + register_rule, ) +register_rule( + RulespecGroupCheckParametersApplications, + varname="logwatch_rules", + title=_('Logwatch Patterns'), + valuespec=Transform( + Dictionary( + elements=[ + ("reclassify_patterns", + ListOf( + Tuple( + help=_("This defines one logfile pattern rule"), + show_titles=True, + orientation="horizontal", + elements=[ + DropdownChoice( + title=_("State"), + choices=[ + ('C', _('CRITICAL')), + ('W', _('WARNING')), + ('O', _('OK')), + ('I', _('IGNORE')), + ], + ), + RegExpUnicode( + title=_("Pattern (Regex)"), + size=40, + mode=RegExp.infix, + ), + TextUnicode( + title=_("Comment"), + size=40, + ), + ]), + title=_("Reclassify state matching regex pattern"), + help= + _('

You can define one or several patterns (regular expressions) in each logfile pattern rule. ' + 'These patterns are applied to the selected logfiles to reclassify the ' + 'matching log messages. The first pattern which matches a line will ' + 'be used for reclassifying a message. You can use the ' + 'Logfile Pattern Analyzer ' + 'to test the rules you defined here.

' + '

Select "Ignore" as state to get the matching logs deleted. Other states will keep the ' + 'log entries but reclassify the state of them.

'), + add_label=_("Add pattern"), + )), + ("reclassify_states", + Dictionary( + title=_("Reclassify complete state"), + help=_( + "This setting allows you to convert all incoming states to another state. " + "The option is applied before the state conversion via regexes. So the regex values can " + "modify the state even further."), + elements=[ + ("c_to", + DropdownChoice( + title=_("Change CRITICAL State to"), + choices=[ + ('C', _('CRITICAL')), + ('W', _('WARNING')), + ('O', _('OK')), + ('I', _('IGNORE')), + ('.', _('Context Info')), + ], + default_value="C", + )), + ("w_to", + DropdownChoice( + title=_("Change WARNING State to"), + choices=[ + ('C', _('CRITICAL')), + ('W', _('WARNING')), + ('O', _('OK')), + ('I', _('IGNORE')), + ('.', _('Context Info')), + ], + default_value="W", + )), + ("o_to", + DropdownChoice( + title=_("Change OK State to"), + choices=[ + ('C', _('CRITICAL')), + ('W', _('WARNING')), + ('O', _('OK')), + ('I', _('IGNORE')), + ('.', _('Context Info')), + ], + default_value="O", + )), + ("._to", + DropdownChoice( + title=_("Change Context Info to"), + choices=[ + ('C', _('CRITICAL')), + ('W', _('WARNING')), + ('O', _('OK')), + ('I', _('IGNORE')), + ('.', _('Context Info')), + ], + default_value=".", + )), + ], + optional_keys=False, + )), + ], + optional_keys=["reclassify_states"], + ), + forth=lambda x: isinstance(x, dict) and x or {"reclassify_patterns": x}), + itemtype='item', + itemname='Logfile', + itemhelp=_("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."), + match='all', +) + +register_rule( + RulespecGroupCheckParametersApplications, + varname="logwatch_groups", + title=_('Logfile Grouping Patterns'), + help=_('The check logwatch normally creates one service for each logfile. ' + 'By defining grouping patterns you can switch to the check logwatch.groups. ' + 'If the pattern begins with a tilde then this pattern is interpreted as a regular ' + 'expression instead of as a filename globbing pattern and * and ? ' + 'are treated differently. ' + 'That check monitors a list of logfiles at once. This is useful if you have ' + 'e.g. a folder with rotated logfiles where the name of the current logfile' + 'also changes with each rotation'), + valuespec=ListOf( + Tuple( + help=_("This defines one logfile grouping pattern"), + show_titles=True, + orientation="horizontal", + elements=[ + TextAscii(title=_("Name of group"),), + Tuple( + show_titles=True, + orientation="vertical", + elements=[ + TextAscii(title=_("Include Pattern")), + TextAscii(title=_("Exclude Pattern")) + ], + ), + ], + ), + add_label=_("Add pattern group"), + ), + match='all', +) register_check_parameters(RulespecGroupCheckParametersApplications, "logwatch_ec", diff --git a/cmk/gui/plugins/wato/check_parameters/msx_queues.py b/cmk/gui/plugins/wato/check_parameters/msx_queues.py index 5056ee0f2a..d09d13c278 100644 --- a/cmk/gui/plugins/wato/check_parameters/msx_queues.py +++ b/cmk/gui/plugins/wato/check_parameters/msx_queues.py @@ -28,13 +28,16 @@ from cmk.gui.i18n import _ from cmk.gui.valuespec import ( Dictionary, Integer, + ListOf, TextAscii, Transform, Tuple, ) from cmk.gui.plugins.wato import ( RulespecGroupCheckParametersApplications, + RulespecGroupCheckParametersDiscovery, register_check_parameters, + register_rule, ) @@ -44,6 +47,35 @@ def transform_msx_queues(params): return params +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="winperf_msx_queues_inventory", + title=_('MS Exchange Message Queues Discovery'), + help=_( + 'Per default the offsets of all Windows performance counters are preconfigured in the check. ' + 'If the format of your counters object is not compatible then you can adapt the counter ' + 'offsets manually.'), + valuespec=ListOf( + Tuple( + orientation="horizontal", + elements=[ + TextAscii( + title=_("Name of Counter"), + help=_("Name of the Counter to be monitored."), + size=50, + allow_empty=False, + ), + Integer( + title=_("Offset"), + help=_("The offset of the information relative to counter base"), + allow_empty=False, + ), + ]), + movable=False, + add_label=_("Add Counter")), + match='all', +) + register_check_parameters( RulespecGroupCheckParametersApplications, "msx_queues", _("MS Exchange Message Queues"), Transform( diff --git a/cmk/gui/plugins/wato/check_parameters/multipath.py b/cmk/gui/plugins/wato/check_parameters/multipath.py index 3ccd980996..1d83c472f5 100644 --- a/cmk/gui/plugins/wato/check_parameters/multipath.py +++ b/cmk/gui/plugins/wato/check_parameters/multipath.py @@ -27,6 +27,8 @@ from cmk.gui.i18n import _ from cmk.gui.valuespec import ( Alternative, + Checkbox, + Dictionary, Integer, Percentage, TextAscii, @@ -35,6 +37,29 @@ from cmk.gui.valuespec import ( from cmk.gui.plugins.wato import ( RulespecGroupCheckParametersStorage, register_check_parameters, + register_rule, +) + +register_rule( + RulespecGroupCheckParametersStorage, + varname="inventory_multipath_rules", + title=_("Linux Multipath Inventory"), + valuespec=Dictionary( + elements=[ + ("use_alias", + Checkbox( + title=_("Use the multipath alias as service name, if one is set"), + label=_("use alias"), + help=_( + "If a multipath device has an alias then you can use it for specifying " + "the device instead of the UUID. The alias will then be part of the service " + "description. The UUID will be displayed in the plugin output."))), + ], + help=_( + "This rule controls whether the UUID or the alias is used in the service description during " + "discovery of Multipath devices on Linux."), + ), + match='dict', ) register_check_parameters( diff --git a/cmk/gui/plugins/wato/check_parameters/unsorted.py b/cmk/gui/plugins/wato/check_parameters/unsorted.py dissimilarity index 77% index fed4f61dd0..652776c179 100644 --- a/cmk/gui/plugins/wato/check_parameters/unsorted.py +++ b/cmk/gui/plugins/wato/check_parameters/unsorted.py @@ -1,800 +1,195 @@ -#!/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.utils.defines as defines - -from cmk.gui.plugins.wato.active_checks import check_icmp_params - -from cmk.gui.i18n import _ -from cmk.gui.valuespec import ( - Dictionary, - Tuple, - Integer, - TextAscii, - DropdownChoice, - Checkbox, - RegExp, - Alternative, - ListChoice, - Transform, - ListOf, - ListOfStrings, - FixedValue, - DualListChoice, - TextUnicode, - RegExpUnicode, -) -from cmk.gui.plugins.wato import ( - RulespecGroupCheckParametersApplications, - RulespecGroupCheckParametersDiscovery, - RulespecGroupCheckParametersNetworking, - RulespecGroupCheckParametersStorage, - register_rule, -) - -# TODO: Sort all rules and check parameters into the figlet header sections. -# Beware: there are dependencies, so sometimes the order matters. All rules -# that are not yet handles are in the last section: in "Unsorted". Move rules -# from there into their appropriate sections until "Unsorted" is empty. -# Create new rules directly in the correct secions. - -# .--Networking----------------------------------------------------------. -# | _ _ _ _ _ | -# | | \ | | ___| |___ _____ _ __| | _(_)_ __ __ _ | -# | | \| |/ _ \ __\ \ /\ / / _ \| '__| |/ / | '_ \ / _` | | -# | | |\ | __/ |_ \ V V / (_) | | | <| | | | | (_| | | -# | |_| \_|\___|\__| \_/\_/ \___/|_| |_|\_\_|_| |_|\__, | | -# | |___/ | -# '----------------------------------------------------------------------' - -register_rule( - RulespecGroupCheckParametersNetworking, - "ping_levels", - Dictionary( - title=_("PING and host check parameters"), - help=_("This rule sets the parameters for the host checks (via check_icmp) " - "and also for PING checks on ping-only-hosts. For the host checks only the " - "critical state is relevant, the warning levels are ignored."), - elements=check_icmp_params, - ), - match="dict") - -#. -# .--Inventory-----------------------------------------------------------. -# | ___ _ | -# | |_ _|_ ____ _____ _ __ | |_ ___ _ __ _ _ | -# | | || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | | -# | | || | | \ V / __/ | | | || (_) | | | |_| | | -# | |___|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | | -# | |___/ | -# '----------------------------------------------------------------------' - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="inv_domino_tasks_rules", - title=_('Lotus Domino Task Discovery'), - help=_("This rule controls the discovery of tasks on Lotus Domino systems. " - "Any changes later on require a host re-discovery"), - valuespec=Dictionary( - elements=[ - ('descr', - TextAscii( - title=_('Service Description'), - allow_empty=False, - help= - _('

The service description may contain one or more occurances of %s. In this ' - 'case, the pattern must be a regular expression prefixed with ~. For each ' - '%s in the description, the expression has to contain one "group". A group ' - 'is a subexpression enclosed in brackets, for example (.*) or ' - '([a-zA-Z]+) or (...). When the inventory finds a task ' - 'matching the pattern, it will substitute all such groups with the actual values when ' - 'creating the check. In this way one rule can create several checks on a host.

' - '

If the pattern contains more groups than occurrences of %s in the service ' - 'description, only the first matching subexpressions are used for the service ' - 'descriptions. The matched substrings corresponding to the remaining groups ' - 'are nevertheless copied into the regular expression.

' - '

As an alternative to %s you may also use %1, %2, etc. ' - 'These expressions will be replaced by the first, second, ... matching group, allowing ' - 'you to reorder things.

'), - )), - ( - 'match', - Alternative( - title=_("Task Matching"), - elements=[ - TextAscii( - title=_("Exact name of the task"), - size=50, - ), - Transform( - RegExp( - size=50, - mode=RegExp.prefix, - ), - title=_("Regular expression matching command line"), - help=_("This regex must match the beginning of the task"), - forth=lambda x: x[1:], # remove ~ - back=lambda x: "~" + x, # prefix ~ - ), - FixedValue( - None, - totext="", - title=_("Match all tasks"), - ) - ], - match=lambda x: (not x and 2) or (x[0] == '~' and 1 or 0), - default_value='foo')), - ('levels', - Tuple( - title=_('Levels'), - help= - _("Please note that if you specify and also if you modify levels here, the change is " - "activated only during an inventory. Saving this rule is not enough. This is due to " - "the nature of inventory rules."), - elements=[ - Integer( - title=_("Critical below"), - unit=_("processes"), - default_value=1, - ), - Integer( - title=_("Warning below"), - unit=_("processes"), - default_value=1, - ), - Integer( - title=_("Warning above"), - unit=_("processes"), - default_value=1, - ), - Integer( - title=_("Critical above"), - unit=_("processes"), - default_value=1, - ), - ], - )), - ], - required_keys=['match', 'levels', 'descr'], - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="inventory_sap_values", - title=_('SAP R/3 Single Value Inventory'), - valuespec=Dictionary( - elements=[ - ( - 'match', - Alternative( - title=_("Node Path Matching"), - elements=[ - TextAscii( - title=_("Exact path of the node"), - size=100, - ), - Transform( - RegExp( - size=100, - mode=RegExp.prefix, - ), - title=_("Regular expression matching the path"), - help=_("This regex must match the beginning of the complete " - "path of the node as reported by the agent"), - forth=lambda x: x[1:], # remove ~ - back=lambda x: "~" + x, # prefix ~ - ), - FixedValue( - None, - totext="", - title=_("Match all nodes"), - ) - ], - match=lambda x: (not x and 2) or (x[0] == '~' and 1 or 0), - default_value= - 'SAP CCMS Monitor Templates/Dialog Overview/Dialog Response Time/ResponseTime') - ), - ('limit_item_levels', - Integer( - title=_("Limit Path Levels for Service Names"), - unit=_('path levels'), - minvalue=1, - help= - _("The service descriptions of the inventorized services are named like the paths " - "in SAP. You can use this option to let the inventory function only use the last " - "x path levels for naming."), - )) - ], - optional_keys=['limit_item_levels'], - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="sap_value_groups", - title=_('SAP Value Grouping Patterns'), - help=_('The check sap.value normally creates one service for each SAP value. ' - 'By defining grouping patterns, you can switch to the check sap.value-groups. ' - 'That check monitors a list of SAP values at once.'), - valuespec=ListOf( - Tuple( - help=_("This defines one value grouping pattern"), - show_titles=True, - orientation="horizontal", - elements=[ - TextAscii(title=_("Name of group"),), - Tuple( - show_titles=True, - orientation="vertical", - elements=[ - RegExpUnicode( - title=_("Include Pattern"), - mode=RegExp.prefix, - ), - RegExpUnicode( - title=_("Exclude Pattern"), - mode=RegExp.prefix, - ) - ], - ), - ], - ), - add_label=_("Add pattern group"), - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="inventory_heartbeat_crm_rules", - title=_("Heartbeat CRM Discovery"), - valuespec=Dictionary( - elements=[ - ("naildown_dc", - Checkbox( - title=_("Naildown the DC"), - label=_("Mark the currently distinguished controller as preferred one"), - help=_( - "Nails down the DC to the node which is the DC during discovery. The check " - "will report CRITICAL when another node becomes the DC during later checks.")) - ), - ("naildown_resources", - Checkbox( - title=_("Naildown the resources"), - label=_("Mark the nodes of the resources as preferred one"), - help=_( - "Nails down the resources to the node which is holding them during discovery. " - "The check will report CRITICAL when another holds the resource during later checks." - ))), - ], - help=_('This rule can be used to control the discovery for Heartbeat CRM checks.'), - optional_keys=[], - ), - match='dict', -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="inventory_df_rules", - title=_("Discovery parameters for filesystem checks"), - valuespec=Dictionary( - elements=[ - ("include_volume_name", Checkbox(title=_("Include Volume name in item"))), - ("ignore_fs_types", - ListChoice( - title=_("Filesystem types to ignore"), - choices=[ - ("tmpfs", "tmpfs"), - ("nfs", "nfs"), - ("smbfs", "smbfs"), - ("cifs", "cifs"), - ("iso9660", "iso9660"), - ], - default_value=["tmpfs", "nfs", "smbfs", "cifs", "iso9660"])), - ("never_ignore_mountpoints", - ListOf( - TextUnicode(), - title=_(u"Mountpoints to never ignore"), - help=_( - u"Regardless of filesystem type, these mountpoints will always be discovered." - u"Globbing or regular expressions are currently not supported."), - )), - ],), - match="dict", -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="inventory_fujitsu_ca_ports", - title=_("Discovery of Fujtsu storage CA ports"), - valuespec=Dictionary( - elements=[ - ("indices", ListOfStrings(title=_("CA port indices"))), - ("modes", - DualListChoice( - title=_("CA port modes"), - choices=[ - ("CA", _("CA")), - ("RA", _("RA")), - ("CARA", _("CARA")), - ("Initiator", _("Initiator")), - ], - row=4, - size=30, - )), - ],), - match="dict", -) - -#. -# .--Applications--------------------------------------------------------. -# | _ _ _ _ _ | -# | / \ _ __ _ __ | (_) ___ __ _| |_(_) ___ _ __ ___ | -# | / _ \ | '_ \| '_ \| | |/ __/ _` | __| |/ _ \| '_ \/ __| | -# | / ___ \| |_) | |_) | | | (_| (_| | |_| | (_) | | | \__ \ | -# | /_/ \_\ .__/| .__/|_|_|\___\__,_|\__|_|\___/|_| |_|___/ | -# | |_| |_| | -# '----------------------------------------------------------------------' - -register_rule( - RulespecGroupCheckParametersApplications, - varname="logwatch_rules", - title=_('Logwatch Patterns'), - valuespec=Transform( - Dictionary( - elements=[ - ("reclassify_patterns", - ListOf( - Tuple( - help=_("This defines one logfile pattern rule"), - show_titles=True, - orientation="horizontal", - elements=[ - DropdownChoice( - title=_("State"), - choices=[ - ('C', _('CRITICAL')), - ('W', _('WARNING')), - ('O', _('OK')), - ('I', _('IGNORE')), - ], - ), - RegExpUnicode( - title=_("Pattern (Regex)"), - size=40, - mode=RegExp.infix, - ), - TextUnicode( - title=_("Comment"), - size=40, - ), - ]), - title=_("Reclassify state matching regex pattern"), - help= - _('

You can define one or several patterns (regular expressions) in each logfile pattern rule. ' - 'These patterns are applied to the selected logfiles to reclassify the ' - 'matching log messages. The first pattern which matches a line will ' - 'be used for reclassifying a message. You can use the ' - 'Logfile Pattern Analyzer ' - 'to test the rules you defined here.

' - '

Select "Ignore" as state to get the matching logs deleted. Other states will keep the ' - 'log entries but reclassify the state of them.

'), - add_label=_("Add pattern"), - )), - ("reclassify_states", - Dictionary( - title=_("Reclassify complete state"), - help=_( - "This setting allows you to convert all incoming states to another state. " - "The option is applied before the state conversion via regexes. So the regex values can " - "modify the state even further."), - elements=[ - ("c_to", - DropdownChoice( - title=_("Change CRITICAL State to"), - choices=[ - ('C', _('CRITICAL')), - ('W', _('WARNING')), - ('O', _('OK')), - ('I', _('IGNORE')), - ('.', _('Context Info')), - ], - default_value="C", - )), - ("w_to", - DropdownChoice( - title=_("Change WARNING State to"), - choices=[ - ('C', _('CRITICAL')), - ('W', _('WARNING')), - ('O', _('OK')), - ('I', _('IGNORE')), - ('.', _('Context Info')), - ], - default_value="W", - )), - ("o_to", - DropdownChoice( - title=_("Change OK State to"), - choices=[ - ('C', _('CRITICAL')), - ('W', _('WARNING')), - ('O', _('OK')), - ('I', _('IGNORE')), - ('.', _('Context Info')), - ], - default_value="O", - )), - ("._to", - DropdownChoice( - title=_("Change Context Info to"), - choices=[ - ('C', _('CRITICAL')), - ('W', _('WARNING')), - ('O', _('OK')), - ('I', _('IGNORE')), - ('.', _('Context Info')), - ], - default_value=".", - )), - ], - optional_keys=False, - )), - ], - optional_keys=["reclassify_states"], - ), - forth=lambda x: isinstance(x, dict) and x or {"reclassify_patterns": x}), - itemtype='item', - itemname='Logfile', - itemhelp=_("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."), - match='all', -) - -#. -# .--Unsorted--(Don't create new stuff here!)----------------------------. -# | _ _ _ _ | -# | | | | |_ __ ___ ___ _ __| |_ ___ __| | | -# | | | | | '_ \/ __|/ _ \| '__| __/ _ \/ _` | | -# | | |_| | | | \__ \ (_) | | | || __/ (_| | | -# | \___/|_| |_|___/\___/|_| \__\___|\__,_| | -# | | -# +----------------------------------------------------------------------+ -# | All these rules have not been moved into their according sections. | -# | Please move them as you come along - but beware of dependecies! | -# | Remove this section as soon as it's empty. | -# '----------------------------------------------------------------------' - -register_rule( - RulespecGroupCheckParametersStorage, - varname="filesystem_groups", - title=_('Filesystem grouping patterns'), - help=_('Normally the filesystem checks (df, hr_fs and others) ' - 'will create a single service for each filesystem. ' - 'By defining grouping ' - 'patterns you can handle groups of filesystems like one filesystem. ' - 'For each group you can define one or several patterns. ' - 'The filesystems matching one of the patterns ' - 'will be monitored like one big filesystem in a single service.'), - valuespec=ListOf( - Tuple( - show_titles=True, - orientation="horizontal", - elements=[ - TextAscii(title=_("Name of group"),), - TextAscii( - title=_("Pattern for mount point (using * and ?)"), - help=_("You can specify one or several patterns containing " - "* and ?, for example /spool/tmpspace*. " - "The filesystems matching the patterns will be monitored " - "like one big filesystem in a single service."), - ), - ]), - add_label=_("Add pattern"), - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersStorage, - varname="fileinfo_groups", - title=_('File Grouping Patterns'), - help=_('The check fileinfo monitors the age and size of ' - 'a single file. Each file information that is sent ' - 'by the agent will create one service. By defining grouping ' - 'patterns you can switch to the check fileinfo.groups. ' - 'That check monitors a list of files at once. You can set levels ' - 'not only for the total size and the age of the oldest/youngest ' - 'file but also on the count. You can define one or several ' - 'patterns for a group containing * and ?, for example ' - '/var/log/apache/*.log. Please see Python\'s fnmatch for more ' - 'information regarding globbing patterns and special characters. ' - 'If the pattern begins with a tilde then this pattern is interpreted as ' - 'a regular expression instead of as a filename globbing pattern and ' - '* and ? are treated differently. ' - 'For files contained in a group ' - 'the discovery will automatically create a group service instead ' - 'of single services for each file. This rule also applies when ' - 'you use manually configured checks instead of inventorized ones. ' - 'Furthermore, the current time/date in a configurable format ' - 'may be included in the include pattern. The syntax is as follows: ' - '$DATE:format-spec$ or $YESTERDAY:format-spec$, where format-spec ' - 'is a list of time format directives of the unix date command. ' - 'Example: $DATE:%Y%m%d$ is todays date, e.g. 20140127. A pattern ' - 'of /var/tmp/backups/$DATE:%Y%m%d$.txt would search for .txt files ' - 'with todays date as name in the directory /var/tmp/backups. ' - 'The YESTERDAY syntax simply subtracts one day from the reference time.'), - valuespec=ListOf( - Tuple( - help=_("This defines one file grouping pattern."), - show_titles=True, - orientation="horizontal", - elements=[ - TextAscii( - title=_("Name of group"), - size=10, - ), - Transform( - Tuple( - show_titles=True, - orientation="vertical", - elements=[ - TextAscii(title=_("Include Pattern"), size=40), - TextAscii(title=_("Exclude Pattern"), size=40), - ], - ), - forth=lambda params: isinstance(params, str) and (params, '') or params), - ], - ), - add_label=_("Add pattern group"), - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersStorage, - "diskstat_inventory", - ListChoice( - title=_("Discovery mode for Disk IO check"), - help=_("This rule controls which and how many checks will be created " - "for monitoring individual physical and logical disks. " - "Note: the option Create a summary for all read, one for " - "write has been removed. Some checks will still support " - "this settings, but it will be removed there soon."), - choices=[ - ("summary", _("Create a summary over all physical disks")), - # This option is still supported by some checks, but is deprecated and - # we fade it out... - # ( "legacy", _("Create a summary for all read, one for write") ), - ("physical", _("Create a separate check for each physical disk")), - ("lvm", _("Create a separate check for each LVM volume (Linux)")), - ("vxvm", _("Creata a separate check for each VxVM volume (Linux)")), - ("diskless", _("Creata a separate check for each partition (XEN)")), - ], - default_value=['summary'], - ), - match="first") - - -def transform_if_groups_forth(params): - for param in params: - if param.get("name"): - param["group_name"] = param["name"] - del param["name"] - if param.get("include_items"): - param["items"] = param["include_items"] - del param["include_items"] - if param.get("single") is not None: - if param["single"]: - param["group_presence"] = "instead" - else: - param["group_presence"] = "separate" - del param["single"] - return params - - -vs_elements_if_groups_matches = [ - ("iftype", - Transform( - DropdownChoice( - title=_("Select interface port type"), - choices=defines.interface_port_types(), - help=_("Only interfaces with the given port type are put into this group. " - "For example 53 (propVirtual)."), - ), - forth=str, - back=int, - )), - ("items", - ListOfStrings( - title=_("Restrict interface items"), - help=_("Only interface with these item names are put into this group."), - )), -] - -vs_elements_if_groups_group = [ - ("group_name", - TextAscii( - title=_("Group name"), - help=_("Name of group in service description"), - allow_empty=False, - )), - ("group_presence", - DropdownChoice( - title=_("Group interface presence"), - help=_("Determine whether the group interface is created as an " - "separate service or not. In second case the choosen interface " - "services disapear."), - choices=[ - ("separate", _("List grouped interfaces separately")), - ("instead", _("List grouped interfaces instead")), - ], - default_value="instead", - )), -] - -register_rule( - RulespecGroupCheckParametersNetworking, - varname="if_groups", - title=_('Network interface groups'), - help=_( - 'Normally the Interface checks create a single service for interface. ' - 'By defining if-group patterns multiple interfaces can be combined together. ' - 'A single service is created for this interface group showing the total traffic amount ' - 'of its members. You can configure if interfaces which are identified as group interfaces ' - 'should not show up as single service. You can restrict grouped interfaces by iftype and the ' - 'item name of the single interface.'), - valuespec=Transform( - Alternative( - style="dropdown", - elements=[ - ListOf( - title=_("Groups on single host"), - add_label=_("Add pattern"), - valuespec=Dictionary( - elements=vs_elements_if_groups_group + vs_elements_if_groups_matches, - required_keys=["group_name", "group_presence"]), - ), - ListOf( - magic="@!!", - title=_("Groups on cluster"), - add_label=_("Add pattern"), - valuespec=Dictionary( - elements=vs_elements_if_groups_group + - [("node_patterns", - ListOf( - title=_("Patterns for each node"), - add_label=_("Add pattern"), - valuespec=Dictionary( - elements=[("node_name", TextAscii(title=_("Node name")))] + - vs_elements_if_groups_matches, - required_keys=["node_name"]), - allow_empty=False, - ))], - optional_keys=[])), - ], - ), - forth=transform_if_groups_forth), - match='all', -) - -register_rule( - RulespecGroupCheckParametersDiscovery, - varname="winperf_msx_queues_inventory", - title=_('MS Exchange Message Queues Discovery'), - help=_( - 'Per default the offsets of all Windows performance counters are preconfigured in the check. ' - 'If the format of your counters object is not compatible then you can adapt the counter ' - 'offsets manually.'), - valuespec=ListOf( - Tuple( - orientation="horizontal", - elements=[ - TextAscii( - title=_("Name of Counter"), - help=_("Name of the Counter to be monitored."), - size=50, - allow_empty=False, - ), - Integer( - title=_("Offset"), - help=_("The offset of the information relative to counter base"), - allow_empty=False, - ), - ]), - movable=False, - add_label=_("Add Counter")), - match='all', -) - -register_rule( - RulespecGroupCheckParametersStorage, - varname="inventory_multipath_rules", - title=_("Linux Multipath Inventory"), - valuespec=Dictionary( - elements=[ - ("use_alias", - Checkbox( - title=_("Use the multipath alias as service name, if one is set"), - label=_("use alias"), - help=_( - "If a multipath device has an alias then you can use it for specifying " - "the device instead of the UUID. The alias will then be part of the service " - "description. The UUID will be displayed in the plugin output."))), - ], - help=_( - "This rule controls whether the UUID or the alias is used in the service description during " - "discovery of Multipath devices on Linux."), - ), - match='dict', -) - -register_rule( - RulespecGroupCheckParametersApplications, - varname="logwatch_groups", - title=_('Logfile Grouping Patterns'), - help=_('The check logwatch normally creates one service for each logfile. ' - 'By defining grouping patterns you can switch to the check logwatch.groups. ' - 'If the pattern begins with a tilde then this pattern is interpreted as a regular ' - 'expression instead of as a filename globbing pattern and * and ? ' - 'are treated differently. ' - 'That check monitors a list of logfiles at once. This is useful if you have ' - 'e.g. a folder with rotated logfiles where the name of the current logfile' - 'also changes with each rotation'), - valuespec=ListOf( - Tuple( - help=_("This defines one logfile grouping pattern"), - show_titles=True, - orientation="horizontal", - elements=[ - TextAscii(title=_("Name of group"),), - Tuple( - show_titles=True, - orientation="vertical", - elements=[ - TextAscii(title=_("Include Pattern")), - TextAscii(title=_("Exclude Pattern")) - ], - ), - ], - ), - add_label=_("Add pattern group"), - ), - match='all', -) - -register_rule( - RulespecGroupCheckParametersNetworking, - "if_disable_if64_hosts", - title=_("Hosts forced to use if instead of if64"), - help=_("A couple of switches with broken firmware report that they " - "support 64 bit counters but do not output any actual data " - "in those counters. Listing those hosts in this rule forces " - "them to use the interface check with 32 bit counters instead.")) +#!/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.plugins.wato.active_checks import check_icmp_params + +from cmk.gui.i18n import _ +from cmk.gui.valuespec import ( + Dictionary, + Tuple, + Integer, + TextAscii, + RegExp, + Alternative, + Transform, + ListOf, + ListOfStrings, + FixedValue, + DualListChoice, + RegExpUnicode, +) +from cmk.gui.plugins.wato import ( + RulespecGroupCheckParametersDiscovery, + RulespecGroupCheckParametersNetworking, + register_rule, +) + +# TODO: Sort all rules and check parameters into the figlet header sections. +# Beware: there are dependencies, so sometimes the order matters. All rules +# that are not yet handles are in the last section: in "Unsorted". Move rules +# from there into their appropriate sections until "Unsorted" is empty. +# Create new rules directly in the correct secions. + +# .--Networking----------------------------------------------------------. +# | _ _ _ _ _ | +# | | \ | | ___| |___ _____ _ __| | _(_)_ __ __ _ | +# | | \| |/ _ \ __\ \ /\ / / _ \| '__| |/ / | '_ \ / _` | | +# | | |\ | __/ |_ \ V V / (_) | | | <| | | | | (_| | | +# | |_| \_|\___|\__| \_/\_/ \___/|_| |_|\_\_|_| |_|\__, | | +# | |___/ | +# '----------------------------------------------------------------------' + +register_rule( + RulespecGroupCheckParametersNetworking, + "ping_levels", + Dictionary( + title=_("PING and host check parameters"), + help=_("This rule sets the parameters for the host checks (via check_icmp) " + "and also for PING checks on ping-only-hosts. For the host checks only the " + "critical state is relevant, the warning levels are ignored."), + elements=check_icmp_params, + ), + match="dict") + +#. +# .--Inventory-----------------------------------------------------------. +# | ___ _ | +# | |_ _|_ ____ _____ _ __ | |_ ___ _ __ _ _ | +# | | || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | | +# | | || | | \ V / __/ | | | || (_) | | | |_| | | +# | |___|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | | +# | |___/ | +# '----------------------------------------------------------------------' + +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="inventory_sap_values", + title=_('SAP R/3 Single Value Inventory'), + valuespec=Dictionary( + elements=[ + ( + 'match', + Alternative( + title=_("Node Path Matching"), + elements=[ + TextAscii( + title=_("Exact path of the node"), + size=100, + ), + Transform( + RegExp( + size=100, + mode=RegExp.prefix, + ), + title=_("Regular expression matching the path"), + help=_("This regex must match the beginning of the complete " + "path of the node as reported by the agent"), + forth=lambda x: x[1:], # remove ~ + back=lambda x: "~" + x, # prefix ~ + ), + FixedValue( + None, + totext="", + title=_("Match all nodes"), + ) + ], + match=lambda x: (not x and 2) or (x[0] == '~' and 1 or 0), + default_value= + 'SAP CCMS Monitor Templates/Dialog Overview/Dialog Response Time/ResponseTime') + ), + ('limit_item_levels', + Integer( + title=_("Limit Path Levels for Service Names"), + unit=_('path levels'), + minvalue=1, + help= + _("The service descriptions of the inventorized services are named like the paths " + "in SAP. You can use this option to let the inventory function only use the last " + "x path levels for naming."), + )) + ], + optional_keys=['limit_item_levels'], + ), + match='all', +) + +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="sap_value_groups", + title=_('SAP Value Grouping Patterns'), + help=_('The check sap.value normally creates one service for each SAP value. ' + 'By defining grouping patterns, you can switch to the check sap.value-groups. ' + 'That check monitors a list of SAP values at once.'), + valuespec=ListOf( + Tuple( + help=_("This defines one value grouping pattern"), + show_titles=True, + orientation="horizontal", + elements=[ + TextAscii(title=_("Name of group"),), + Tuple( + show_titles=True, + orientation="vertical", + elements=[ + RegExpUnicode( + title=_("Include Pattern"), + mode=RegExp.prefix, + ), + RegExpUnicode( + title=_("Exclude Pattern"), + mode=RegExp.prefix, + ) + ], + ), + ], + ), + add_label=_("Add pattern group"), + ), + match='all', +) + +register_rule( + RulespecGroupCheckParametersDiscovery, + varname="inventory_fujitsu_ca_ports", + title=_("Discovery of Fujtsu storage CA ports"), + valuespec=Dictionary( + elements=[ + ("indices", ListOfStrings(title=_("CA port indices"))), + ("modes", + DualListChoice( + title=_("CA port modes"), + choices=[ + ("CA", _("CA")), + ("RA", _("RA")), + ("CARA", _("CARA")), + ("Initiator", _("Initiator")), + ], + row=4, + size=30, + )), + ],), + match="dict", +) -- 2.11.4.GIT