コード例 #1
0
ファイル: inventory.py プロジェクト: gradecke/checkmk
def _valuespec_inv_parameters_lnx_sysctl():
    return Dictionary(
        title=_("Inventory of Linux kernel configuration (sysctl)"),
        help=
        _("This rule allows for defining regex-patterns for in- and excluding kernel "
          "configuration parameters in the inventory. By default, no parameters are included. "
          "Note that some kernel configuration parameters change frequently. Inventorizing "
          "one of these parameters will lead to frequent changes in the HW/SW inventory, "
          "which can quickly fill up the temporary file system."),
        elements=[
            (
                "include_patterns",
                ListOfStrings(
                    valuespec=RegExp(RegExp.prefix),
                    title=_("Inclusion patterns"),
                    help=_(
                        "Define patterns for including kernel configuration parameters in the "
                        "inventory."),
                ),
            ),
            (
                "exclude_patterns",
                ListOfStrings(
                    valuespec=RegExp(RegExp.prefix),
                    title=_("Exclusion patterns"),
                    help=_(
                        "Define patterns for excluding kernel configuration parameters from the "
                        "inventory."),
                ),
            ),
        ],
        optional_keys=False,
    )
コード例 #2
0
ファイル: unsorted.py プロジェクト: troelsarvin/checkmk
def _valuespec_sap_value_groups():
    return ListOf(
        Tuple(
            help=_("This defines one value grouping pattern"),
            show_titles=True,
            orientation="horizontal",
            elements=[
                TextInput(title=_("Name of group"), ),
                Tuple(
                    show_titles=True,
                    orientation="vertical",
                    elements=[
                        RegExp(
                            title=_("Include Pattern"),
                            mode=RegExp.prefix,
                        ),
                        RegExp(
                            title=_("Exclude Pattern"),
                            mode=RegExp.prefix,
                        ),
                    ],
                ),
            ],
        ),
        add_label=_("Add pattern group"),
        title=_("SAP value discovery"),
        help=
        _("The check <tt>sap.value</tt> normally creates one service for each SAP value. "
          "By defining grouping patterns, you can switch to the check <tt>sap.value_groups</tt>. "
          "That check monitors a list of SAP values at once."),
    )
コード例 #3
0
def _parameter_valuespec_checkmk_agent_plugins():
    return Dictionary(
        elements=[
            (
                "min_versions",
                Tuple(
                    title=_("Required minimal versions"),
                    help=_(
                        "You can configure lower thresholds for the versions of the currently "
                        "deployed agent plugins and local checks."
                    ),
                    elements=[
                        TextInput(title=_("Warning at"), validate=_validate_version),
                        TextInput(title=_("Critical at"), validate=_validate_version),
                    ],
                ),
            ),
            (
                "exclude_pattern",
                RegExp(
                    title=_("Regular expression to exclude plugins"),
                    mode=RegExp.infix,
                    help=_(
                        "Plugins or local checks matching this pattern will be excluded from the "
                        "comparison with the specified required versions."
                    ),
                ),
            ),
        ],
        help=_('This ruleset is deprecated. Please use the ruleset <i>"%s"</i> instead.')
        % _("Checkmk Agent installation auditing"),
    )
コード例 #4
0
def hr_process_match_path_option():
    return Alternative(
        title=_("Process Path Matching"),
        elements=[
            TextAscii(
                title=_("Exact name of the process path"),
                size=50,
                allow_empty=False,
            ),
            Transform(
                RegExp(
                    size=50,
                    mode=RegExp.prefix,
                    validate=forbid_re_delimiters_inside_groups,
                    allow_empty=False,
                ),
                title=_("Regular expression matching the process path"),
                help=_("This regex must match the <i>beginning</i> of the complete "
                       "path of the process including arguments.<br>"
                       "When using groups, matches will be instantiated "
                       "during process discovery. e.g. (py.*) will match python, python_dev "
                       "and python_test and discover 3 services. At check time, because "
                       "python is a substring of python_test and python_dev it will aggregate"
                       "all process that start with python. If that is not the intended behavior "
                       "please use a delimiter like '$' or '\\b' around the group, e.g. (py.*)$<br>"
                       "In manual check groups are aggregated"),
                forth=lambda x: x[1:],  # remove ~
                back=lambda x: "~" + x,  # prefix ~
            ),
        ],
        match=match_hr_alternative,
        default_value='/usr/sbin/foo')
コード例 #5
0
ファイル: host_rename.py プロジェクト: bsmr/tribe29-checkmk
 def _vs_renaming_config(self):
     return Dictionary(
         title=_("Bulk Renaming"),
         render="form",
         elements=[
             ("recurse",
              Checkbox(
                  title=_("Folder Selection"),
                  label=_("Include all subfolders"),
                  default_value=True,
              )),
             ("match_hostname",
              RegExp(
                  title=_("Hostname matching"),
                  help=
                  _("Only rename hostnames whose names <i>begin</i> with the regular expression entered here."
                    ),
                  mode=RegExp.complete,
              )),
             ("renamings",
              ListOf(
                  self._vs_host_renaming(),
                  title=_("Renaming Operations"),
                  add_label=_("Add renaming"),
                  allow_empty=False,
              )),
         ],
         optional_keys=[],
     )
コード例 #6
0
def __element():
    return Tuple(elements=[
        age_levels_dropdown(),
        ListOf(
            valuespec=RegExp(
                mode=RegExp.infix,
                title=_("Status"),
                allow_empty=False,
                size=50,
            ),
            add_label=_("Add new status"),
            allow_empty=False,
            movable=False,
            help=RegExp(mode=RegExp.infix).help(),
        ),
    ], )
コード例 #7
0
ファイル: datadog_monitors.py プロジェクト: petrows/checkmk
def _parameter_valuespec_datadog_monitors() -> Dictionary:
    return Dictionary([
        (
            "state_mapping",
            Dictionary(
                [(
                    datadog_state,
                    MonitoringState(
                        title=datadog_state,
                        default_value=checkmk_state,
                    ),
                ) for datadog_state, checkmk_state in
                 _DEFAULT_DATADOG_AND_CHECKMK_STATES],
                title=_("Map monitor states to Checkmk monitoring states"),
                optional_keys=False,
            ),
        ),
        (
            "tags_to_show",
            ListOfStrings(
                valuespec=RegExp(
                    RegExp.prefix,
                    size=30,
                    allow_empty=False,
                ),
                title=_("Datadog tags shown in service output"),
                help=
                _("This option allows you to configure which Datadog tags will be shown in "
                  "the service output. This is done by entering regular expressions matching "
                  "one or more Datadog tags. Any matching tag will be displayed in the "
                  "service output."),
            ),
        ),
    ], )
コード例 #8
0
 def _vs_ip_range(self):
     return CascadingDropdown(choices=[
         ("ip_range", _("IP-Range"),
          Tuple(
              elements=[
                  IPv4Address(title=_("From:"),),
                  IPv4Address(title=_("To:"),),
              ],
              orientation="horizontal",
          )),
         ("ip_network", _("IP Network"),
          Tuple(
              elements=[
                  IPv4Address(title=_("Network address:"),),
                  Integer(
                      title=_("Netmask"),
                      minvalue=8,
                      maxvalue=30,
                  ),
              ],
              orientation="horizontal",
          )),
         ("ip_list", _("Explicit List of IP Addresses"),
          ListOfStrings(
              valuespec=IPv4Address(),
              orientation="horizontal",
          )),
         ("ip_regex_list", _("List of patterns to exclude"),
          ListOfStrings(
              valuespec=RegExp(mode=RegExp.prefix,),
              orientation="horizontal",
              help=_("A list of regular expressions which are matched against the found "
                     "IP addresses to exclude them. The matched addresses are excluded."),
          )),
     ])
コード例 #9
0
ファイル: domino_tasks.py プロジェクト: spearheadsys/checkmk
 def parameter_valuespec(self):
     return Dictionary(
         elements=[
             (
                 "process",
                 Alternative(
                     title=_("Name of the task"),
                     style="dropdown",
                     elements=[
                         TextAscii(
                             title=_("Exact name of the task"),
                             size=50,
                         ),
                         Transform(
                             RegExp(
                                 size=50,
                                 mode=RegExp.prefix,
                             ),
                             title=_("Regular expression matching tasks"),
                             help=
                             _("This regex must match the <i>beginning</i> of the complete "
                               "command line of the task including arguments"
                               ),
                             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))),
             ("warnmin",
              Integer(
                  title=_(
                      "Minimum number of matched tasks for WARNING state"),
                  default_value=1,
              )),
             ("okmin",
              Integer(
                  title=_("Minimum number of matched tasks for OK state"),
                  default_value=1,
              )),
             ("okmax",
              Integer(
                  title=_("Maximum number of matched tasks for OK state"),
                  default_value=99999,
              )),
             ("warnmax",
              Integer(
                  title=_(
                      "Maximum number of matched tasks for WARNING state"),
                  default_value=99999,
              )),
         ],
         required_keys=['warnmin', 'okmin', 'okmax', 'warnmax', 'process'],
     )
コード例 #10
0
 def _vs_ip_range(self, with_regexp=False):
     # NOTE: The `ip_regex_list` choice is only used in the `exclude_ranges` key.
     options = [
         (
             "ip_range",
             _("IP-Range"),
             Tuple(
                 elements=[
                     IPv4Address(title=_("From:"), ),
                     IPv4Address(title=_("To:"), ),
                 ],
                 orientation="horizontal",
             ),
         ),
         (
             "ip_network",
             _("IP Network"),
             Tuple(
                 elements=[
                     IPv4Address(title=_("Network address:"), ),
                     Integer(
                         title=_("Netmask"),
                         minvalue=8,
                         maxvalue=30,
                         default_value=24,
                     ),
                 ],
                 orientation="horizontal",
                 help=
                 _("Please avoid very large subnet sizes/ranges. A netmask value of /21 is "
                   "probably ok, while larger subnets (i.e. smaller netmask values) will lead "
                   "to excessive runtimes."),
             ),
         ),
         (
             "ip_list",
             _("Explicit List of IP Addresses"),
             ListOfStrings(
                 valuespec=IPv4Address(),
                 orientation="horizontal",
             ),
         ),
     ]
     regexp_exclude = (
         "ip_regex_list",
         _("List of patterns to exclude"),
         ListOfStrings(
             valuespec=RegExp(mode=RegExp.prefix, ),
             orientation="horizontal",
             help=
             _("A list of regular expressions which are matched against the found "
               "IP addresses to exclude them. The matched addresses are excluded."
               ),
         ),
     )
     if with_regexp:
         options.append(regexp_exclude)
     return CascadingDropdown(choices=options)
コード例 #11
0
ファイル: bi.py プロジェクト: m3rlinux/checkmk
 def _vs_aggregation_assignments(self):
     return Dictionary(
         title=_("Aggregation assignment"),
         elements=[
             (
                 "querying_host",
                 FixedValue(value="querying_host",
                            totext="",
                            title=_("Assign to the querying host")),
             ),
             (
                 "affected_hosts",
                 FixedValue(value="affected_hosts",
                            totext="",
                            title=_("Assign to the affected hosts")),
             ),
             (
                 "regex",
                 ListOf(
                     valuespec=Tuple(
                         orientation="horizontal",
                         elements=[
                             RegExp(
                                 title=_("Regular expression"),
                                 help=
                                 _("Must contain at least one subgroup <tt>(...)</tt>"
                                   ),
                                 mingroups=0,
                                 maxgroups=9,
                                 size=30,
                                 allow_empty=False,
                                 mode=RegExp.prefix,
                                 case_sensitive=False,
                             ),
                             TextInput(
                                 title=_("Replacement"),
                                 help=
                                 _("Use <tt>\\1</tt>, <tt>\\2</tt> etc. to replace matched subgroups"
                                   ),
                                 size=30,
                                 allow_empty=False,
                             ),
                         ],
                     ),
                     title=_("Assign via regular expressions"),
                     help=
                     _("You can add any number of expressions here which are executed succesively until the first match. "
                       "Please specify a regular expression in the first field. This expression should at "
                       "least contain one subexpression exclosed in brackets - for example <tt>vm_(.*)_prod</tt>. "
                       "In the second field you specify the translated aggregation and can refer to the first matched "
                       "group with <tt>\\1</tt>, the second with <tt>\\2</tt> and so on, for example <tt>\\1.example.org</tt>. "
                       ""),
                     add_label=_("Add expression"),
                     movable=False,
                 ),
             ),
         ],
     )
コード例 #12
0
ファイル: audit_log.py プロジェクト: maxmalysh/checkmk
    def _audit_log_options(self):
        object_types: Choices = [
            ("", _("All object types")),
            (None, _("No object type")),
        ] + [(t.name, t.name) for t in ObjectRefType]

        return [
            ("object_type",
             DropdownChoice(
                 title=_("Object type"),
                 choices=object_types,
             )),
            ("object_ident", TextAscii(title=_("Object"), )),
            (
                "user_id",
                UserSelection(
                    title=_("User"),
                    only_contacts=False,
                    none=_("All users"),
                ),
            ),
            ("filter_regex",
             RegExp(
                 title=_("Filter pattern (RegExp)"),
                 mode="infix",
             )),
            ("start",
             CascadingDropdown(
                 title=_("Start log from"),
                 default_value="now",
                 orientation="horizontal",
                 choices=[
                     ("now", _("Current date")),
                     ("time", _("Specific date"), AbsoluteDate()),
                 ],
             )),
            ("display",
             CascadingDropdown(
                 title=_("Display mode of entries"),
                 default_value="daily",
                 orientation="horizontal",
                 choices=[
                     ("daily", _("Daily paged display")),
                     ("number_of_days",
                      _("Number of days from now (single page)"),
                      Integer(
                          minvalue=1,
                          unit=_("days"),
                          default_value=1,
                      )),
                 ],
             )),
        ]
コード例 #13
0
ファイル: if.py プロジェクト: tboerger/checkmk
def _vs_regex_matching(match_obj):
    return ListOfStrings(
        title=_("Match interface %s (regex)" % match_obj),
        help=_("Apply this rule only to interfaces whose %s matches one of the configured regular "
               "expressions. The match is done on the beginning of the %s." %
               (match_obj, match_obj)),
        orientation="horizontal",
        valuespec=RegExp(
            size=32,
            mode=RegExp.prefix,
        ),
    )
コード例 #14
0
ファイル: host_rename.py プロジェクト: inettgmbh/checkmk
 def _vs_host_renaming(self):
     return CascadingDropdown(
         orientation="horizontal",
         choices=[
             ("case", _("Case translation"),
              DropdownChoice(choices=[
                  ("upper", _("Convert hostnames to upper case")),
                  ("lower", _("Convert hostnames to lower case")),
              ])),
             ("add_suffix", _("Add Suffix"), Hostname()),
             ("add_prefix", _("Add Prefix"), Hostname()),
             ("drop_domain", _("Drop Domain Suffix")),
             ("reverse_dns",
              _("Convert IP addresses of hosts into host their DNS names")),
             ("regex", _("Regular expression substitution"),
              Tuple(help=_(
                  "Please specify a regular expression in the first field. This expression should at "
                  "least contain one subexpression exclosed in brackets - for example <tt>vm_(.*)_prod</tt>. "
                  "In the second field you specify the translated host name and can refer to the first matched "
                  "group with <tt>\\1</tt>, the second with <tt>\\2</tt> and so on, for example <tt>\\1.example.org</tt>"
              ),
                    elements=[
                        RegExp(
                            title=
                            _("Regular expression for the beginning of the host name"
                              ),
                            help=
                            _("Must contain at least one subgroup <tt>(...)</tt>"
                              ),
                            mingroups=0,
                            maxgroups=9,
                            size=30,
                            allow_empty=False,
                            mode=RegExp.prefix,
                        ),
                        TextInput(
                            title=_("Replacement"),
                            help=
                            _("Use <tt>\\1</tt>, <tt>\\2</tt> etc. to replace matched subgroups, <tt>\\0</tt> to insert to original host name"
                              ),
                            size=30,
                            allow_empty=False,
                        )
                    ])),
             ("explicit", _("Explicit renaming"),
              Tuple(orientation="horizontal",
                    elements=[
                        Hostname(title=_("current host name"),
                                 allow_empty=False),
                        Hostname(title=_("new host name"),
                                 allow_empty=False),
                    ])),
         ])
コード例 #15
0
ファイル: unsorted.py プロジェクト: troelsarvin/checkmk
def _valuespec_inventory_sap_values():
    return Dictionary(
        title=_("SAP R/3 single value discovery"),
        elements=[
            (
                "match",
                Alternative(
                    title=_("Node Path Matching"),
                    elements=[
                        TextInput(
                            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 <i>beginning</i> 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"],
    )
コード例 #16
0
ファイル: domino_tasks.py プロジェクト: gradecke/checkmk
def _parameter_valuespec_domino_tasks():
    return Transform(
        Dictionary(
            elements=[
                (
                    "process",
                    Alternative(
                        title=_("Name of the task"),
                        elements=[
                            TextInput(
                                title=_("Exact name of the task"),
                                size=50,
                            ),
                            Transform(
                                RegExp(
                                    size=50,
                                    mode=RegExp.prefix,
                                ),
                                title=_("Regular expression matching tasks"),
                                help=
                                _("This regex must match the <i>beginning</i> of the complete "
                                  "command line of the task including arguments"
                                  ),
                                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),
                    ),
                ),
                (
                    "levels",
                    _vs_levels(
                        _("Specify levels on the minimum and maximum number of tasks."
                          ), ),
                ),
            ],
            optional_keys=False,
        ),
        forth=_transform_valuespec_domino_tasks,
    )
コード例 #17
0
ファイル: ps.py プロジェクト: troelsarvin/checkmk
def cgroup_match_options():
    return Tuple(
        title=_("Operating system control group information"),
        elements=[
            Alternative(
                elements=[
                    TextInput(
                        title=
                        _("Exact content of the operating system control group info"
                          ),
                        label=_("Control group:"),
                        size=50,
                    ),
                    Transform(
                        RegExp(
                            size=50,
                            mode=RegExp.prefix,
                        ),
                        title=_(
                            "Regular expression matching control group info"),
                        help=_(
                            "This regex must match the <i>beginning</i> of the complete "
                            "control group information"),
                        forth=lambda x: x[1:],  # remove ~
                        back=lambda x: "~" + x,  # prefix ~
                    ),
                    FixedValue(
                        None,
                        totext="",
                        title=_("Match all control groups"),
                    ),
                ],
                match=match_alt,
                help=
                _("<p>The control group information is currently only specified by the linux agent"
                  " (cgroup). If it is present and this rule is set, the inventory will only trigger"
                  " if the control group of the corresponding process matches."
                  " For instance: you can use this rule to exclude all processes belonging to"
                  ' a docker container by specifying the expression "%s" (without the quotes),'
                  ' and selecting "%s".</p>') %
                (r".*/docker/", _("Invert matching")),
            ),
            Checkbox(label=_("Invert matching"), default_value=False),
        ],
    )
コード例 #18
0
ファイル: common.py プロジェクト: m3rlinux/checkmk
def filter_kubernetes_namespace_element():
    return (
        "namespace_include_patterns",
        ListOf(
            valuespec=RegExp(
                mode=RegExp.complete,
                title=_("Pattern"),
                allow_empty=False,
            ),
            title=_("Monitor namespaces matching"),
            add_label=_("Add new pattern"),
            allow_empty=False,
            help=_("If your cluster has multiple namespaces, you can specify "
                   "a list of regex patterns. Only matching namespaces will "
                   "be monitored. Note that this concerns everything which "
                   "is part of the matching namespaces such as pods for "
                   "example."),
        ),
    )
コード例 #19
0
def user_match_options(extra_elements=None):
    if extra_elements is None:
        extra_elements = []

    return Alternative(
        title=_("Name of operating system user"),
        style="dropdown",
        elements=[
            TextAscii(title=_("Exact name of the operating system user"),
                      label=_("User:"******"Regular expression matching username"),
                help=_(
                    "This regex must match the <i>beginning</i> of the complete "
                    "username"),
                forth=lambda x: x[1:],  # remove ~
                back=lambda x: "~" + x,  # prefix ~
            ),
            FixedValue(
                None,
                totext="",
                title=_("Match all users"),
            )
        ] + extra_elements,
        match=match_alt,
        help=
        _('<p>The user specification is a user name (string). The '
          'inventory will then trigger only if that user matches the user the '
          'process is running as. The resulting check will require such '
          'user. If user is not '
          'selected the created check will not look for a specific user.</p> '
          '<p>Windows users are specified by the namespace followed '
          'by the actual user name. For example "\\\\NT AUTHORITY\\NETWORK '
          'SERVICE" or "\\\\CHKMKTEST\\Administrator".</p> '),
    )
コード例 #20
0
ファイル: ps.py プロジェクト: gradecke/checkmk
def process_match_options():
    return Alternative(
        title=_("Process Matching"),
        elements=[
            TextInput(
                title=_("Exact name of the process without arguments"),
                label=_("Executable:"),
                size=50,
            ),
            Transform(
                RegExp(
                    size=50,
                    label=_("Command line:"),
                    mode=RegExp.prefix,
                    validate=forbid_re_delimiters_inside_groups,
                ),
                title=_("Regular expression matching command line"),
                help=_(
                    "This regex must match the <i>beginning</i> of the complete "
                    "command line of the process including arguments.<br>"
                    "When using groups, matches will be instantiated "
                    "during process discovery. e.g. (py.*) will match python, python_dev "
                    "and python_test and discover 3 services. At check time, because "
                    "python is a substring of python_test and python_dev it will aggregate"
                    "all process that start with python. If that is not the intended behavior "
                    "please use a delimiter like '$' or '\\b' around the group, e.g. (py.*)$<br>"
                    "In manual check groups are aggregated"
                ),
                forth=lambda x: x[1:],  # remove ~
                back=lambda x: "~" + x,  # prefix ~
            ),
            FixedValue(
                None,
                totext="",
                title=_("Match all processes"),
            ),
        ],
        match=match_alt,
        default_value="/usr/sbin/foo",
    )
コード例 #21
0
 def _vs_audit_log_options(self):
     return Dictionary(
         title=_("Options"),
         elements=[
             ("filter_regex",
              RegExp(
                  title=_("Filter pattern (RegExp)"),
                  mode="infix",
              )),
             ("start",
              CascadingDropdown(
                  title=_("Start log from"),
                  default_value="now",
                  orientation="horizontal",
                  choices=[
                      ("now", _("Current date")),
                      ("time", _("Specific date"), AbsoluteDate()),
                  ],
              )),
             ("display",
              CascadingDropdown(
                  title=_("Display mode of entries"),
                  default_value="daily",
                  orientation="horizontal",
                  choices=[
                      ("daily", _("Daily paged display")),
                      ("number_of_days",
                       _("Number of days from now (single page)"),
                       Integer(
                           minvalue=1,
                           unit=_("days"),
                           default_value=1,
                       )),
                  ],
              )),
         ],
         optional_keys=[],
     )
コード例 #22
0
ファイル: logwatch_ec.py プロジェクト: troelsarvin/checkmk
def _valuespec_logwatch_rules():
    return Transform(
        Dictionary(
            title=_("Logfile patterns"),
            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")),
                                    ],
                                ),
                                RegExp(
                                    title=_("Pattern (Regex)"),
                                    size=40,
                                    mode=RegExp.infix,
                                ),
                                TextInput(
                                    title=_("Comment"),
                                    size=40,
                                ),
                            ],
                        ),
                        title=_("Reclassify state matching regex pattern"),
                        help=
                        _("<p>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 "
                          '<a href="wato.py?mode=pattern_editor">Logfile Pattern Analyzer</a> '
                          "to test the rules you defined here.</p>"
                          "<p>Note that to match a special regex character in your patterns, you need to use a "
                          "backslash to escape its special meaning. This is especially relevant for Windows file paths. "
                          'For example, to match the Windows path "C:\\Users\\amdin\\Desktop", enter '
                          '"C:\\\\Users\\\\admin\\\\Desktop".</p>'
                          '<p>Select "Ignore" as state to get the matching logs deleted. Other states will keep the '
                          "log entries but reclassify the state of them.</p>"),
                        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"],
            ignored_keys=["pre_comp_group_patterns", "group_patterns"],
        ),
        forth=lambda x: isinstance(x, dict) and x or
        {"reclassify_patterns": x},
    )
コード例 #23
0
def _parameter_valuespec_systemd_services():
    return Dictionary(
        elements=[
            (
                "states",
                Dictionary(
                    title=_("Map systemd states to monitoring states"),
                    elements=[
                        (
                            "active",
                            MonitoringState(
                                title=_(
                                    "Monitoring state if service is active"),
                                default_value=0,
                            ),
                        ),
                        (
                            "inactive",
                            MonitoringState(
                                title=_(
                                    "Monitoring state if service is inactive"),
                                default_value=0,
                            ),
                        ),
                        (
                            "failed",
                            MonitoringState(
                                title=_(
                                    "Monitoring state if service is failed"),
                                default_value=2,
                            ),
                        ),
                    ],
                ),
            ),
            (
                "states_default",
                MonitoringState(
                    title=_("Monitoring state for any other service state"),
                    default_value=2,
                ),
            ),
            (
                "ignored",
                ListOf(
                    valuespec=RegExp(
                        title=_("Pattern (Regex)"),
                        size=40,
                        mode=RegExp.infix,
                    ),
                    title=_(
                        "Exclude services matching provided regex patterns"),
                    help=
                    _("<p>You can optionally define one or multiple regular expressions "
                      "where a matching case will result in the exclusion of the concerning service(s). "
                      "This allows to ignore services which are known to fail beforehand. </p>"
                      ),
                    add_label=_("Add pattern"),
                ),
            ),
            (
                "activating_levels",
                SimpleLevels(
                    Age,
                    title=
                    _("Define a tolerating time period for activating services"
                      ),
                    help=
                    _("Choose time levels for which a service is allowed to be in an 'activating' state"
                      ),
                    default_levels=(30, 60),
                ),
            ),
            (
                "deactivating_levels",
                SimpleLevels(
                    Age,
                    title=
                    _("Define a tolerating time period for deactivating services"
                      ),
                    help=
                    _("Choose time levels (in seconds) for which a service is allowed to be in an 'deactivating' state"
                      ),
                    default_value=(30, 60),
                ),
            ),
            (
                "reloading_levels",
                SimpleLevels(
                    Age,
                    title=_(
                        "Define a tolerating time period for reloading services"
                    ),
                    help=
                    _("Choose time levels (in seconds) for which a service is allowed to be in a 'reloading' state"
                      ),
                    default_value=(30, 60),
                ),
            ),
        ],
        help=_(
            "This ruleset only applies to the Summary Systemd service and not the individual "
            "Systemd services."),
    )
コード例 #24
0
def _valuespec_active_checks_mail():
    return Transform(
        Dictionary(
            title=_("Check Email"),
            help=
            _("The basic function of this check is to log in into an IMAP or POP3 mailbox to "
              "monitor whether or not the login is possible. A extended feature is, that the "
              "check can fetch all (or just some) from the mailbox and forward them as events "
              "to the Event Console."),
            required_keys=["service_description", "fetch"],
            elements=[
                (
                    "service_description",
                    TextInput(
                        title=_("Service description"),
                        help=_("Please make sure that this is unique per host "
                               "and does not collide with other services."),
                        allow_empty=False,
                        default_value="Email",
                    ),
                ),
                _mail_receiving_params({"IMAP", "POP3"}),
                (
                    "connect_timeout",
                    Integer(
                        title=_("Connect Timeout"),
                        minvalue=1,
                        default_value=10,
                        unit=_("sec"),
                    ),
                ),
                (
                    "forward",
                    Dictionary(
                        title=_("Forward mails as events to Event Console"),
                        elements=[
                            (
                                "method",
                                Alternative(
                                    title=_("Forwarding Method"),
                                    elements=[
                                        Alternative(
                                            title=
                                            _("Send events to local event console"
                                              ),
                                            elements=[
                                                FixedValue(
                                                    value="",
                                                    totext=
                                                    _("Directly forward to event console"
                                                      ),
                                                    title=
                                                    _("Send events to local event console in same OMD site"
                                                      ),
                                                ),
                                                TextInput(
                                                    title=
                                                    _("Send events to local event console into unix socket"
                                                      ),
                                                    allow_empty=False,
                                                ),
                                                FixedValue(
                                                    value="spool:",
                                                    totext=_(
                                                        "Spool to event console"
                                                    ),
                                                    title=
                                                    _("Spooling: Send events to local event console in same OMD site"
                                                      ),
                                                ),
                                                Transform(
                                                    valuespec=TextInput(
                                                        allow_empty=False, ),
                                                    title=
                                                    _("Spooling: Send events to local event console into given spool directory"
                                                      ),
                                                    # remove prefix
                                                    forth=lambda x: x[6:],
                                                    back=lambda x: "spool:" +
                                                    x,  # add prefix
                                                ),
                                            ],
                                            match=lambda x: x and
                                            (x == "spool:" and 2 or x.
                                             startswith("spool:"
                                                        ) and 3 or 1) or 0,
                                        ),
                                        Tuple(
                                            title=
                                            _("Send events to remote syslog host"
                                              ),
                                            elements=[
                                                DropdownChoice(
                                                    choices=[
                                                        ("udp", _("UDP")),
                                                        ("tcp", _("TCP")),
                                                    ],
                                                    title=_("Protocol"),
                                                ),
                                                TextInput(
                                                    title=_("Address"),
                                                    allow_empty=False,
                                                ),
                                                Integer(
                                                    title=_("Port"),
                                                    default_value=514,
                                                    minvalue=1,
                                                    maxvalue=65535,
                                                    size=6,
                                                ),
                                            ],
                                        ),
                                    ],
                                ),
                            ),
                            (
                                "match_subject",
                                RegExp(
                                    title=
                                    _("Only process mails with matching subject"
                                      ),
                                    help=
                                    _("Use this option to not process all messages found in the inbox, "
                                      "but only the those whose subject matches the given regular expression."
                                      ),
                                    mode=RegExp.prefix,
                                ),
                            ),
                            (
                                "facility",
                                DropdownChoice(
                                    title=_("Events: Syslog facility"),
                                    help=
                                    _("Use this syslog facility for all created events"
                                      ),
                                    choices=mkeventd.syslog_facilities,
                                    default_value=2,  # mail
                                ),
                            ),
                            (
                                "application",
                                Alternative(
                                    title=_("Events: Syslog application"),
                                    help=
                                    _("Use this syslog application for all created events"
                                      ),
                                    elements=[
                                        FixedValue(
                                            value=None,
                                            title=_("Use the mail subject"),
                                            totext=
                                            _("The mail subject is used as syslog appliaction"
                                              ),
                                        ),
                                        TextInput(
                                            title=_("Specify the application"),
                                            help=
                                            _("Use this text as application. You can use macros like <tt>\\1</tt>, <tt>\\2</tt>, ... "
                                              "here when you configured <i>subject matching</i> in this rule with a regular expression "
                                              "that declares match groups (using braces)."
                                              ),
                                            allow_empty=False,
                                        ),
                                    ],
                                ),
                            ),
                            (
                                "host",
                                TextInput(
                                    title=_("Events: Hostname"),
                                    help=
                                    _("Use this hostname for all created events instead of the name of the mailserver"
                                      ),
                                ),
                            ),
                            (
                                "body_limit",
                                Integer(
                                    title=_("Limit length of mail body"),
                                    help=
                                    _("When forwarding mails from the mailbox to the event console, the "
                                      "body of the mail is limited to the given number of characters."
                                      ),
                                    default_value=1000,
                                ),
                            ),
                            (
                                "cleanup",
                                Alternative(
                                    title=_("Cleanup messages"),
                                    help=
                                    _("The handled messages (see <i>subject matching</i>) can be cleaned up by either "
                                      "deleting them or moving them to a subfolder. By default nothing is cleaned up."
                                      ),
                                    elements=[
                                        FixedValue(
                                            value=True,
                                            title=_("Delete messages"),
                                            totext=
                                            _("Delete all processed message belonging to this check"
                                              ),
                                        ),
                                        TextInput(
                                            title=_("Move to subfolder"),
                                            help=
                                            _("Specify the destination path in the format <tt>Path/To/Folder</tt>, for example"
                                              "<tt>INBOX/Processed_Mails</tt>."
                                              ),
                                            allow_empty=False,
                                        ),
                                    ],
                                ),
                            ),
                        ],
                    ),
                ),
            ],
        ),
        forth=transform_check_mail_params,
    )
コード例 #25
0
def _valuespec_inv_domino_tasks_rules():
    return Transform(
        Dictionary(
            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"),
            elements=[
                ('descr',
                 TextInput(
                     title=_('Service Description'),
                     allow_empty=False,
                     help=
                     _('<p>The service description may contain one or more occurances of <tt>%s</tt>. In this '
                       'case, the pattern must be a regular expression prefixed with ~. For each '
                       '<tt>%s</tt> in the description, the expression has to contain one "group". A group '
                       'is a subexpression enclosed in brackets, for example <tt>(.*)</tt> or '
                       '<tt>([a-zA-Z]+)</tt> or <tt>(...)</tt>. 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.</p>'
                       '<p>If the pattern contains more groups than occurrences of <tt>%s</tt> 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.</p>'
                       '<p>As an alternative to <tt>%s</tt> you may also use <tt>%1</tt>, <tt>%2</tt>, etc. '
                       'These expressions will be replaced by the first, second, ... matching group, allowing '
                       'you to reorder things.</p>'),
                 )),
                (
                    'match',
                    Alternative(
                        title=_("Task Matching"),
                        elements=[
                            TextInput(
                                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 <i>beginning</i> 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')),
                (
                    'default_params',
                    Dictionary(
                        title=_('Check parameters'),
                        elements=[
                            (
                                'levels',
                                _vs_levels(
                                    _("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.")),
                            ),
                        ],
                        optional_keys=False,
                    ),
                ),
            ],
            optional_keys=False,
        ),
        forth=_transform_inv_domino_tasks_rules,
    )
コード例 #26
0
ファイル: form_submit.py プロジェクト: LinuxHaus/checkmk
def _valuespec_active_checks_form_submit():
    return Transform(
        Tuple(
            title=_("Check HTML Form Submit"),
            help=_(
                "Check submission of HTML forms via HTTP/HTTPS using the plugin <tt>check_form_submit</tt> "
                "provided with Check_MK. This plugin provides more functionality than <tt>check_http</tt>, "
                "as it automatically follows HTTP redirect, accepts and uses cookies, parses forms "
                "from the requested pages, changes vars and submits them to check the response "
                "afterwards."
            ),
            elements=[
                TextInput(
                    title=_("Name"),
                    help=_("The name will be used in the service description"),
                    allow_empty=False,
                ),
                Dictionary(
                    title=_("Check the URL"),
                    elements=[
                        (
                            "hosts",
                            ListOfStrings(
                                title=_("Check specific host(s)"),
                                help=_(
                                    "By default, if you do not specify any host addresses here, "
                                    "the host address of the host this service is assigned to will "
                                    "be used. But by specifying one or several host addresses here, "
                                    "it is possible to let the check monitor one or multiple hosts."
                                ),
                            ),
                        ),
                        (
                            "uri",
                            TextInput(
                                title=_("URI to fetch (default is <tt>/</tt>)"),
                                allow_empty=False,
                                default_value="/",
                                regex="^/.*",
                            ),
                        ),
                        (
                            "port",
                            Integer(
                                title=_("TCP Port"),
                                minvalue=1,
                                maxvalue=65535,
                                default_value=80,
                            ),
                        ),
                        (
                            "tls_configuration",
                            DropdownChoice(
                                title=_("TLS/HTTPS configuration"),
                                help=_(
                                    "Activate or deactivate TLS for the connection. No certificate validation means that "
                                    "the server certificate will not be validated by the locally available certificate authorities."
                                ),
                                choices=[
                                    (
                                        "no_tls",
                                        _("No TLS"),
                                    ),
                                    (
                                        "tls_standard",
                                        _("TLS"),
                                    ),
                                    (
                                        "tls_no_cert_valid",
                                        _("TLS without certificate validation"),
                                    ),
                                ],
                            ),
                        ),
                        (
                            "timeout",
                            Integer(
                                title=_("Seconds before connection times out"),
                                unit=_("sec"),
                                default_value=10,
                            ),
                        ),
                        (
                            "expect_regex",
                            RegExp(
                                title=_("Regular expression to expect in content"),
                                mode=RegExp.infix,
                            ),
                        ),
                        (
                            "form_name",
                            TextInput(
                                title=_("Name of the form to populate and submit"),
                                help=_(
                                    "If there is only one form element on the requested page, you "
                                    "do not need to provide the name of that form here. But if you "
                                    "have several forms on that page, you need to provide the name "
                                    "of the form here, to enable the check to identify the correct "
                                    "form element."
                                ),
                                allow_empty=True,
                            ),
                        ),
                        (
                            "query",
                            TextInput(
                                title=_("Send HTTP POST data"),
                                help=_(
                                    "Data to send via HTTP POST method. Please make sure, that the data "
                                    'is URL-encoded (for example "key1=val1&key2=val2").'
                                ),
                                size=40,
                            ),
                        ),
                        (
                            "num_succeeded",
                            Tuple(
                                title=_("Multiple Hosts: Number of successful results"),
                                elements=[
                                    Integer(title=_("Warning if equal or below")),
                                    Integer(title=_("Critical if equal or below")),
                                ],
                            ),
                        ),
                    ],
                ),
            ],
        ),
        forth=_transform_form_submit,
    )
コード例 #27
0
def _valuespec_inventory_if_rules():
    return Transform(
        Dictionary(
            title=_("Network Interface and Switch Port Discovery"),
            elements=[
                ('item_appearance',
                 DropdownChoice(
                     title=_("Appearance of network interface"),
                     help=
                     _("This option lets Check_MK use either the interface description, alias or "
                       " port number as item. The port number is the fallback/default."
                       "used anyway."),
                     choices=[
                         ('descr', _('Use description')),
                         ('alias', _('Use alias')),
                         ('index', _('Use index')),
                     ],
                     default_value='index',
                 )),
                ("pad_portnumbers",
                 DropdownChoice(
                     choices=[
                         (True, _('Pad port numbers with zeros')),
                         (False, _('Do not pad')),
                     ],
                     title=_("Port numbers"),
                     help=
                     _("If this option is activated then Check_MK will pad port numbers of "
                       "network interfaces with zeroes so that all port descriptions from "
                       "all ports of a host or switch have the same length and thus sort "
                       "currectly in the GUI. In versions prior to 1.1.13i3 there was no "
                       "padding. You can switch back to the old behaviour by disabling this "
                       "option. This will retain the old service descriptions and the old "
                       "performance data."),
                 )),
                ("match_alias",
                 ListOfStrings(
                     title=_("Match interface alias (regex)"),
                     help=
                     _("Only discover interfaces whose alias matches one of the configured "
                       "regular expressions. The match is done on the beginning of the alias. "
                       "This allows you to select interfaces based on the alias without having "
                       "the alias be part of the service description."),
                     orientation="horizontal",
                     valuespec=RegExp(
                         size=32,
                         mode=RegExp.prefix,
                     ),
                 )),
                ("match_desc",
                 ListOfStrings(
                     title=_("Match interface description (regex)"),
                     help=
                     _("Only discover interfaces whose the description matches one of the configured "
                       "regular expressions. The match is done on the beginning of the description. "
                       "This allows you to select interfaces based on the description without having "
                       "the alias be part of the service description."),
                     orientation="horizontal",
                     valuespec=RegExp(
                         size=32,
                         mode=RegExp.prefix,
                     ),
                 )),
                ("portstates",
                 ListChoice(
                     title=_("Network interface port states to discover"),
                     help=
                     _("When doing discovery on switches or other devices with network interfaces "
                       "then only ports found in one of the configured port states will be added to the monitoring. "
                       "Note: the state <i>admin down</i> is in fact not an <tt>ifOperStatus</tt> but represents the "
                       "<tt>ifAdminStatus</tt> of <tt>down</tt> - a port administratively switched off. If you check this option "
                       "then an alternate version of the check is being used that fetches the <tt>ifAdminState</tt> in addition. "
                       "This will add about 5% of additional SNMP traffic."),
                     choices=defines.interface_oper_states(),
                     toggle_all=True,
                     default_value=['1'],
                 )),
                ("porttypes",
                 DualListChoice(
                     title=_("Network interface port types to discover"),
                     help=
                     _("When doing discovery on switches or other devices with network interfaces "
                       "then only ports of the specified types will be created services for."
                       ),
                     choices=defines.interface_port_types(),
                     rows=40,
                     default_value=[
                         '6', '32', '62', '117', '127', '128', '129', '180',
                         '181', '182', '205', '229'
                     ],
                 )),
                ("rmon",
                 DropdownChoice(
                     choices=[
                         (True,
                          _("Create extra service with RMON statistics data (if available for the device)"
                            )),
                         (False, _('Do not create extra services')),
                     ],
                     title=_("Collect RMON statistics data"),
                     help=
                     _("If you enable this option, for every RMON capable switch port an additional service will "
                       "be created which is always OK and collects RMON data. This will give you detailed information "
                       "about the distribution of packet sizes transferred over the port. Note: currently "
                       "this extra RMON check does not honor the inventory settings for switch ports. In a future "
                       "version of Check_MK RMON data may be added to the normal interface service and not add "
                       "an additional service."),
                 )),
            ],
            help=
            _('This rule can be used to control the inventory for network ports. '
              'You can configure the port types and port states for inventory '
              'and the use of alias or description as service name.'),
        ),
        forth=_transform_discovery_if_rules,
    )
コード例 #28
0
ファイル: kube.py プロジェクト: LinuxHaus/checkmk
def _valuespec_special_agents_kube():
    return Dictionary(
        elements=[
            (
                "cluster-name",
                Hostname(
                    title=_("Cluster name"),
                    allow_empty=False,
                    help=
                    _("You must specify a name for your Kubernetes cluster. The provided name"
                      " will be used to make the objects from your cluster unique in a "
                      "multi-cluster setup."),
                ),
            ),
            (
                "token",
                IndividualOrStoredPassword(
                    title=_("Token"),
                    allow_empty=False,
                ),
            ),
            (
                "kubernetes-api-server",
                Dictionary(
                    elements=[
                        (
                            "endpoint",
                            HTTPUrl(
                                title=_("Endpoint"),
                                allow_empty=False,
                                default_value="https://<control plane ip>:443",
                                help=_(
                                    "The full URL to the Kubernetes API server including the "
                                    "protocol (http or https) and the port."),
                                size=80,
                            ),
                        ),
                        ssl_verification(),
                        (
                            "proxy",
                            HTTPProxyReference(
                                {"http",
                                 "https"}),  # Kubernetes client does not
                            # support socks proxies.
                        ),
                        _tcp_timeouts(),
                    ],
                    required_keys=["endpoint", "verify-cert"],
                    title=_("API server connection"),
                ),
            ),
            (
                "cluster-collector",  # TODO: adjust help texts depending on ingress inclusion
                Dictionary(
                    elements=[
                        (
                            "endpoint",
                            HTTPUrl(
                                title=_(
                                    "Collector NodePort / Ingress endpoint"),
                                allow_empty=False,
                                default_value="https://<service url>:30035",
                                help=
                                _("The full URL to the Cluster Collector service including "
                                  "the protocol (http or https) and the port. Depending on "
                                  "the deployed configuration of the service this can "
                                  "either be the NodePort or the Ingress endpoint."
                                  ),
                                size=80,
                            ),
                        ),
                        ssl_verification(),
                        (
                            "proxy",
                            HTTPProxyReference(),
                        ),
                        _tcp_timeouts(),
                    ],
                    required_keys=["endpoint", "verify-cert"],
                    title=_(
                        "Enrich with usage data from Checkmk Cluster Collector"
                    ),
                ),
            ),
            (
                "monitored-objects",
                ListChoice(
                    choices=[
                        ("deployments", _("Deployments")),
                        ("daemonsets", _("DaemonSets")),
                        ("statefulsets", _("StatefulSets")),
                        ("namespaces", _("Namespaces")),
                        ("nodes", _("Nodes")),
                        ("pods", _("Pods")),
                        ("cronjobs_pods", _("Pods of CronJobs")),
                    ],
                    default_value=[
                        "deployments",
                        "daemonsets",
                        "statefulsets",
                        "namespaces",
                        "nodes",
                        "pods",
                    ],
                    allow_empty=False,
                    title=_("Collect information about..."),
                    help=
                    _("Select the Kubernetes objects you would like to monitor. Pods "
                      "controlled by CronJobs are treated separately as they are usually "
                      "quite short lived. Those pods will be monitored in the same "
                      "manner as regular pods. Your Dynamic host management rule should "
                      "be configured accordingly to avoid that the piggyback hosts for "
                      "terminated CronJob pods are kept for too long. This 'Pods of CronJobs' "
                      "option has no effect if Pods are not monitored"),
                ),
            ),
            (
                "namespaces",
                CascadingDropdown(
                    choices=[
                        (
                            "namespace-include-patterns",
                            _("Monitor namespaces matching"),
                            ListOf(
                                valuespec=RegExp(
                                    mode=RegExp.infix,
                                    title=_("Pattern"),
                                    allow_empty=False,
                                ),
                                add_label=_("Add new pattern"),
                                allow_empty=False,
                                help=
                                _("You can specify a list of regex patterns to monitor specific "
                                  "namespaces. Only those that do match the predefined patterns "
                                  "will be monitored."),
                            ),
                        ),
                        (
                            "namespace-exclude-patterns",
                            _("Exclude namespaces matching"),
                            ListOf(
                                valuespec=RegExp(
                                    mode=RegExp.infix,
                                    title=_("Pattern"),
                                    allow_empty=False,
                                ),
                                add_label=_("Add new pattern"),
                                allow_empty=False,
                                help=
                                _("You can specify a list of regex patterns to exclude "
                                  "namespaces. Only those that do not match the predefined "
                                  "patterns are monitored."),
                            ),
                        ),
                    ],
                    orientation="horizontal",
                    title=_("Monitor namespaces"),
                    help=
                    _("If your cluster has multiple namespaces, you can filter specific ones "
                      "to be monitored. Note that this concerns everything which is part of the "
                      "selected namespaces such as pods for example."),
                ),
            ),
            (
                "cluster-resource-aggregation",
                CascadingDropdown(
                    title=("Cluster resource aggregation"),
                    choices=[
                        (
                            "cluster-aggregation-exclude-node-roles",
                            _("Exclude Nodes based on their role"),
                            ListOf(
                                valuespec=RegExp(
                                    mode=RegExp.infix,
                                    allow_empty=False,
                                    size=50,
                                ),
                                add_label=_("Add new role"),
                                allow_empty=True,
                                movable=False,
                                default_value=["control-plane", "infra"],
                            ),
                        ),
                        ("cluster-aggregation-include-all-nodes",
                         _("Include all Nodes")),
                    ],
                    orientation="horizontal",
                    help=_(
                        "You may find that some Nodes don't add resources to the overall "
                        "workload your Cluster can handle. This option allows you to remove "
                        "Nodes from aggregations on the Cluster host based on their role. A "
                        "node will be omitted, if any of the listed {role}s matches a label "
                        "with name 'node-role.kubernetes.io/{role}'.  This affects the "
                        "following services: Memory resources, CPU resources, Pod resources. "
                        "Only Services on the Cluster host are affected. By default, Nodes "
                        "with role control-plane and infra are omitted.", ),
                ),
            ),
            (
                "import-annotations",
                CascadingDropdown(
                    title=("Import annotations as host labels"),
                    choices=[
                        (
                            "include-matching-annotations-as-host-labels",
                            _("Filter valid annotations by key pattern"),
                            RegExp(
                                mode=RegExp.infix,
                                allow_empty=False,
                                default_value="checkmk-monitoring$",
                                size=50,
                            ),
                        ),
                        (
                            "include-annotations-as-host-labels",
                            _("Import all valid annotations"),
                            None,
                        ),
                    ],
                    orientation="horizontal",
                    help=
                    _("By default, Checkmk does not import annotations. If "
                      "this option is enabled, Checkmk will import any "
                      "annotation that is a valid Kubernetes label. These "
                      "imported annotations are added as host labels to their "
                      "respective piggyback host using the syntax "
                      "'cmk/kubernetes/annotation/{key}:{value}'. You can "
                      "further restrict the imported annotations by specifying "
                      "a pattern which Checkmk searches for in the key of the "
                      "annotation."),
                ),
            ),
        ],
        optional_keys=[
            "namespaces",
            "cluster-collector",
            "cluster-resource-aggregation",
            "import-annotations",
        ],
        default_keys=["cluster-collector"],
        title=_("Kubernetes"),
    )
コード例 #29
0
def _parameter_valuespec_filestats():
    return Dictionary(
        elements=file_size_age_elements + [
            (
                "mincount",
                Tuple(
                    title=_("Minimal file count"),
                    elements=[
                        Integer(title=_("Warning below")),
                        Integer(title=_("Critical below")),
                    ],
                ),
            ),
            (
                "maxcount",
                Tuple(
                    title=_("Maximal file count"),
                    elements=[
                        Integer(title=_("Warning at or above")),
                        Integer(title=_("Critical at or above")),
                    ],
                ),
            ),
            (
                "show_all_files",
                Checkbox(
                    title=_("Show files in service details"),
                    label=("Show files"),
                    help=
                    _("Display all files that have reached a WARN or a CRIT status in the "
                      "service details. Note: displaying the files leads to a performance loss "
                      "for large numbers of files within the file group. Please enable this feature "
                      "only if it is needed."),
                ),
            ),
            (
                "additional_rules",
                ListOf(
                    valuespec=Tuple(elements=[
                        TextInput(
                            title=_("Display name"),
                            help=_(
                                "Specify a user-friendly name that will be displayed in the service "
                                "details, along with the pattern to match."),
                        ),
                        RegExp(
                            title=_("Filename/- expression"),
                            mode="case_sensitive",
                            size=70,
                        ),
                        Dictionary(elements=file_size_age_elements),
                    ], ),
                    title=_("Additional rules for outliers"),
                    help=
                    _("This feature is to apply different rules to files that are "
                      "inconsistent with the files expected in this file group. "
                      "This means that the rules set for the file group are overwritten. "
                      "You can specify a filename or a regular expresion, and additional "
                      "rules that are applied to the matching files. In case of multiple "
                      "matching rules, the first matching rule is applied. "
                      "Note: this feature is intended for outliers, and is therefore not "
                      "suitable to configure subgroups. "),
                ),
            ),
        ],
        help=
        _("Here you can impose various levels on the results reported by the"
          " mk_filstats plugin. Note that some levels only apply to a matching"
          " output format (e.g. max/min count levels are not applied if only the"
          " smallest, largest, oldest and newest file is reported). In order to"
          " receive the required data, you must configure the plugin mk_filestats."
          ),
    )
コード例 #30
0
def get_vs_flexible_notifications():
    # Make sure, that list is not trivially false
    def validate_only_services(value, varprefix):
        for s in value:
            if s and s[0] != '!':
                return
        raise MKUserError(varprefix + "_0",
                          _("The list of services will never match"))

    return CascadingDropdown(
        title=_("Notification Method"),
        choices=[
            ("email", _("Plain Text Email (using configured templates)")),
            (
                "flexible",
                _("Flexible Custom Notifications"),
                ListOf(
                    Foldable(
                        Dictionary(
                            optional_keys=[
                                "service_blacklist", "only_hosts",
                                "only_services", "escalation", "match_sl"
                            ],
                            columns=1,
                            elements=[
                                (
                                    "plugin",
                                    DropdownChoice(
                                        title=_("Notification Plugin"),
                                        choices=notification_script_choices,
                                        default_value="mail",
                                    ),
                                ),
                                ("parameters",
                                 ListOfStrings(
                                     title=_("Plugin Arguments"),
                                     help=
                                     _("You can specify arguments to the notification plugin here. "
                                       "Please refer to the documentation about the plugin for what "
                                       "parameters are allowed or required here."
                                       ),
                                 )),
                                ("disabled",
                                 Checkbox(
                                     title=_("Disabled"),
                                     label=_(
                                         "Currently disable this notification"
                                     ),
                                     default_value=False,
                                 )),
                                ("timeperiod",
                                 cmk.gui.watolib.timeperiods.
                                 TimeperiodSelection(
                                     title=_("Timeperiod"),
                                     help=
                                     _("Do only notifiy alerts within this time period"
                                       ),
                                 )),
                                (
                                    "escalation",
                                    Tuple(
                                        title=
                                        _("Restrict to n<sup>th</sup> to m<sup>th</sup> notification (escalation)"
                                          ),
                                        orientation="float",
                                        elements=[
                                            Integer(
                                                label=_("from"),
                                                help=
                                                _("Let through notifications counting from this number"
                                                  ),
                                                default_value=1,
                                                minvalue=1,
                                                maxvalue=999999,
                                            ),
                                            Integer(
                                                label=_("to"),
                                                help=
                                                _("Let through notifications counting upto this number"
                                                  ),
                                                default_value=999999,
                                                minvalue=1,
                                                maxvalue=999999,
                                            ),
                                        ],
                                    ),
                                ),
                                (
                                    "match_sl",
                                    Tuple(
                                        title=_("Match service level"),
                                        help=
                                        _("Host or Service must be in the following service level to get notification"
                                          ),
                                        orientation="horizontal",
                                        show_titles=False,
                                        elements=[
                                            DropdownChoice(
                                                label=_("from:"),
                                                choices=cmk.gui.mkeventd.
                                                service_levels,
                                                prefix_values=True),
                                            DropdownChoice(
                                                label=_(" to:"),
                                                choices=cmk.gui.mkeventd.
                                                service_levels,
                                                prefix_values=True),
                                        ],
                                    ),
                                ),
                                ("host_events",
                                 ListChoice(
                                     title=_("Host Events"),
                                     choices=[
                                         ('d', _("Host goes down")),
                                         ('u', _("Host gets unreachble")),
                                         ('r', _("Host goes up again")),
                                         ('f',
                                          _("Start or end of flapping state")),
                                         ('s',
                                          _("Start or end of a scheduled downtime "
                                            )),
                                         ('x',
                                          _("Acknowledgement of host problem")
                                          ),
                                     ],
                                     default_value=[
                                         'd', 'u', 'r', 'f', 's', 'x'
                                     ],
                                 )),
                                ("service_events",
                                 ListChoice(
                                     title=_("Service Events"),
                                     choices=[
                                         ('w',
                                          _("Service goes into warning state")
                                          ),
                                         ('u',
                                          _("Service goes into unknown state")
                                          ),
                                         ('c',
                                          _("Service goes into critical state")
                                          ),
                                         ('r', _("Service recovers to OK")),
                                         ('f',
                                          _("Start or end of flapping state")),
                                         ('s',
                                          _("Start or end of a scheduled downtime"
                                            )),
                                         ('x',
                                          _("Acknowledgement of service problem"
                                            )),
                                     ],
                                     default_value=[
                                         'w', 'c', 'u', 'r', 'f', 's', 'x'
                                     ],
                                 )),
                                (
                                    "only_hosts",
                                    ListOfStrings(
                                        title=_(
                                            "Limit to the following hosts"),
                                        help=
                                        _("Configure the hosts for this notification. Without prefix, only exact, case sensitive matches, "
                                          "<tt>!</tt> for negation and <tt>~</tt> for regex matches."
                                          ),
                                        orientation="horizontal",
                                        # TODO: Clean this up to use an alternative between TextAscii() and RegExp(). Also handle the negation in a different way
                                        valuespec=TextAscii(size=20, ),
                                    ),
                                ),
                                (
                                    "only_services",
                                    ListOfStrings(
                                        title=_(
                                            "Limit to the following services"),
                                        help=
                                        _("Configure regular expressions that match the beginning of the service names here. Prefix an "
                                          "entry with <tt>!</tt> in order to <i>exclude</i> that service."
                                          ),
                                        orientation="horizontal",
                                        # TODO: Clean this up to use an alternative between TextAscii() and RegExp(). Also handle the negation in a different way
                                        valuespec=TextAscii(size=20, ),
                                        validate=validate_only_services,
                                    ),
                                ),
                                (
                                    "service_blacklist",
                                    ListOfStrings(
                                        title=_(
                                            "Blacklist the following services"
                                        ),
                                        help=
                                        _("Configure regular expressions that match the beginning of the service names here."
                                          ),
                                        orientation="horizontal",
                                        valuespec=RegExp(
                                            size=20,
                                            mode=RegExp.prefix,
                                        ),
                                        validate=validate_only_services,
                                    ),
                                ),
                            ]),
                        title_function=lambda v: _("Notify by: ") +
                        notification_script_title(v["plugin"]),
                    ),
                    title=_("Flexible Custom Notifications"),
                    add_label=_("Add notification"),
                ),
            ),
        ])