Пример #1
0
 def _tls_valuespec(cls):
     return CascadingDropdown(
         title=_("Encryption"),
         choices=[
             (
                 "plain_text",
                 _("Plain text (Unencrypted)"),
                 FixedValue(
                     {}, totext=_("Use plain text, unencrypted transport")),
             ),
             ("encrypted", _("Encrypt data using TLS"),
              Dictionary(
                  elements=[
                      ("verify",
                       Checkbox(
                           title=_("Verify server certificate"),
                           label=
                           _("Verify the Livestatus server certificate using the local site CA"
                             ),
                           default_value=True,
                           help=
                           _("Either verify the server certificate using the site local CA or accept "
                             "any certificate offered by the server. It is highly recommended to "
                             "leave this enabled."),
                       )),
                  ],
                  optional_keys=None,
              )),
         ],
         help=
         _("When connecting to Check_MK versions older than 1.6 you can only use plain text "
           "transport. Starting with Check_MK 1.6 it is possible to use encrypted Livestatus "
           "communication. Sites created with 1.6 will automatically use encrypted communication "
           "by default. Sites created with previous versions need to be configured manually to "
           "enable the encryption. Have a look at <a href=\"werk.py?werk=7017\">werk #7017</a> "
           "for further information."),
     )
Пример #2
0
def _bi_host_choice_vs(title):
    def convert_to_vs(value):
        if value["type"] == "all_hosts":
            return "all_hosts"
        return value["type"], value["pattern"]

    def convert_from_vs(value):
        if isinstance(value, str):
            return {"type": "all_hosts"}
        return {"type": value[0], "pattern": value[1]}

    return Transform(
        valuespec=CascadingDropdown(
            title=title,
            choices=[
                ("all_hosts", _("All hosts")),
                (
                    "host_name_regex",
                    _("Regex for host name"),
                    TextInput(label=_("Pattern"), size=60),
                ),
                (
                    "host_alias_regex",
                    _("Regex for host alias"),
                    TextInput(label=_("Pattern"), size=60),
                ),
            ],
            help=
            _('If you choose "Regex for host name" or "Regex for host alias", '
              "you may use match groups as placeholder. The first match group can be used with the placeholder <tt>$1$</tt>. "
              "The complete set of match groups is also available with the placeholders "
              "<tt>$HOST_MG_1$</tt>, <tt>$HOST_MG_2$</tt> and so on."),
            default_value="all_hosts",
        ),
        forth=convert_to_vs,
        back=convert_from_vs,
    )
Пример #3
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."
                ),
          )),
     ])
Пример #4
0
def _parameter_valuespec_kube_pod_resources(help_text: str):
    return Dictionary(
        elements=[
            (
                "pending",
                CascadingDropdown(
                    title=_("Define levels for pending pods"),
                    choices=[
                        (
                            "no_levels",
                            _("No levels"),
                            None,
                        ),
                        (
                            "levels",
                            _("Impose levels"),
                            Tuple(elements=[
                                Age(title=_("Warning after"),
                                    default_value=300),
                                Age(title=_("Critical after"),
                                    default_value=600),
                            ], ),
                        ),
                    ],
                    default_value="no_levels",
                ),
            ),
            (
                "unknown",
                MonitoringState(
                    title=_("Set state for unknown pods"),
                    default_value=3,
                ),
            ),
        ],
        help=help_text,
    )
Пример #5
0
 def _vs_key(self):
     return Dictionary(
         title=_("Properties"),
         elements=[
             (
                 "alias",
                 TextInput(
                     title=_("Description or comment"),
                     size=64,
                     allow_empty=False,
                 ),
             ),
             (
                 "passphrase",
                 Password(
                     title=_("Passphrase"),
                     help=self._passphrase_help(),
                     allow_empty=False,
                     is_stored_plain=False,
                 ),
             ),
             (
                 "key_file",
                 CascadingDropdown(
                     title=_("Key"),
                     choices=[
                         ("upload", _("Upload CRT/PEM File"), FileUpload()),
                         ("text", _("Paste PEM Content"),
                          TextAreaUnicode()),
                     ],
                 ),
             ),
         ],
         optional_keys=False,
         render="form",
     )
Пример #6
0
def _parameter_valuespec_free_pods(title: str) -> CascadingDropdown:
    return CascadingDropdown(
        title=title,
        choices=[
            ("no_levels", _("No Levels")),
            (
                "levels_perc",
                _("Percentual levels"),
                Tuple(elements=[
                    Percentage(title=_("Warning below"), default_value=10.0),
                    Percentage(title=_("Critical below"), default_value=5.0),
                ]),
            ),
            (
                "levels_abs",
                _("Absolute levels"),
                Tuple(elements=[
                    Integer(title=_("Warning below"), default_value=10),
                    Integer(title=_("Critical below"), default_value=5),
                ]),
            ),
        ],
        default_value="levels_perc",
    )
Пример #7
0
    def valuespec(cls):
        def convert_to_vs(value):
            if value.get("rule_id") is None:
                return None
            bi_pack = get_cached_bi_packs().get_pack_of_rule(value["rule_id"])
            if bi_pack is None:
                return None
            return (
                (bi_pack.id, value["rule_id"]),
                value["params"]["arguments"],
            )

        def convert_from_vs(value):
            return {"type": cls.type(), "params": {"arguments": value[1],}, "rule_id": value[0][1]}

        return Transform(
            Tuple(
                elements=[
                    Transform(
                        CascadingDropdown(
                            title=_("Rule:"),
                            orientation="horizontal",
                            choices=cls._allowed_rule_choices(),
                            sorted=True,
                        ),),
                    ListOfStrings(
                        orientation="horizontal",
                        size=80,
                        title=_("Arguments:"),
                    ),
                ],
                validate=cls._validate_rule_call,
            ),
            forth=convert_to_vs,
            back=convert_from_vs,
        )
Пример #8
0
 def _vs_elements(cls):
     return [
         ("render_mode",
          CascadingDropdown(
              title=_("Display"),
              choices=[
                  ("bar_chart", _("Bar chart"),
                   Dictionary(
                       elements=bar_chart_vs_time_components(),
                       optional_keys=[],
                   )),
                  ("simple_number", _("Number of notifications as text"),
                   Dictionary(
                       elements=[
                           ("time_range",
                            Timerange(
                                title=_("Time range"),
                                default_value='d0',
                            )),
                       ],
                       optional_keys=[],
                   )),
              ],
          )),
         ("log_target",
          DropdownChoice(
              title=_("Host or service %ss" % cls.log_type),
              choices=[
                  ("both",
                   _("Show %ss for hosts and services" % cls.log_type)),
                  ("host", _("Show %ss for hosts" % cls.log_type)),
                  ("service", _("Show %ss for services" % cls.log_type)),
              ],
              default_value="both",
          )),
     ]
Пример #9
0
    def _get_component_specific_checkmk_files_choices(
        self,
        title: str,
        checkmk_files: List[Tuple[str, CheckmkFileInfo]],
    ) -> ValueSpec:
        high_sensitive_files = []
        sensitive_files = []
        insensitive_files = []
        for rel_filepath, file_info in checkmk_files:
            if file_info.sensitivity == CheckmkFileSensitivity.high_sensitive:
                high_sensitive_files.append((rel_filepath, file_info))
            elif file_info.sensitivity == CheckmkFileSensitivity.sensitive:
                sensitive_files.append((rel_filepath, file_info))
            else:
                insensitive_files.append((rel_filepath, file_info))

        sorted_files = sorted(high_sensitive_files + sensitive_files +
                              insensitive_files,
                              key=lambda t: t[0])
        sorted_non_high_sensitive_files = sorted(sensitive_files +
                                                 insensitive_files,
                                                 key=lambda t: t[0])
        sorted_insensitive_files = sorted(insensitive_files,
                                          key=lambda t: t[0])
        return CascadingDropdown(
            title=title,
            sorted=False,
            choices=[
                (
                    "all",
                    _("Pack all files: High, Medium, Low sensitivity"),
                    FixedValue(
                        [f for f, fi in sorted_files],
                        totext=self._list_of_files_to_text(sorted_files),
                    ),
                ),
                (
                    "non_high_sensitive",
                    _("Pack only Medium and Low sensitivity files"),
                    FixedValue(
                        [f for f, fi in sorted_non_high_sensitive_files],
                        totext=self._list_of_files_to_text(
                            sorted_non_high_sensitive_files),
                    ),
                ),
                (
                    "insensitive",
                    _("Pack only Low sensitivity files"),
                    FixedValue(
                        [f for f, fi in sorted_insensitive_files],
                        totext=self._list_of_files_to_text(
                            sorted_insensitive_files),
                    ),
                ),
                (
                    "explicit_list_of_files",
                    _("Select individual files from list"),
                    DualListChoice(
                        choices=self._list_of_files_choices(sorted_files),
                        size=80,
                        rows=10,
                    ),
                ),
            ],
            default_value="non_high_sensitive",
        )
Пример #10
0
def _parameter_valuespec_logwatch_ec():
    return Alternative(
        title=_("Forwarding"),
        help=
        _("Instead of using the regular logwatch check all lines received by logwatch can "
          "be forwarded to a Check_MK event console daemon to be processed. The target event "
          "console can be configured for each host in a separate rule."),
        elements=[
            FixedValue(
                "",
                totext=_("Messages are handled by logwatch."),
                title=_("No forwarding"),
            ),
            Dictionary(
                title=_("Forward Messages to Event Console"),
                elements=[
                    (
                        "method",
                        Transform(
                            # TODO: Clean this up to some CascadingDropdown()
                            Alternative(
                                title=_("Forwarding Method"),
                                elements=[
                                    FixedValue(
                                        "",
                                        title=
                                        _("Local: Send events to local Event Console in same OMD site"
                                          ),
                                        totext=_(
                                            "Directly forward to Event Console"
                                        ),
                                    ),
                                    TextInput(
                                        title=
                                        _("Local: Send events to local Event Console into unix socket"
                                          ),
                                        allow_empty=False,
                                    ),
                                    FixedValue(
                                        "spool:",
                                        title=
                                        _("Local: Spooling - Send events to local event console in same OMD site"
                                          ),
                                        totext=_("Spool to Event Console"),
                                    ),
                                    Transform(
                                        TextInput(allow_empty=False, ),
                                        title=
                                        _("Local: Spooling - Send events to local Event Console into given spool directory"
                                          ),
                                        forth=lambda x: x[6:],
                                        # remove prefix
                                        back=lambda x: "spool:" +
                                        x,  # add prefix
                                    ),
                                    CascadingDropdown(
                                        title=
                                        _("Remote: Send events to remote syslog host"
                                          ),
                                        choices=[
                                            (
                                                "tcp",
                                                _("Send via TCP"),
                                                Dictionary(
                                                    elements=[
                                                        (
                                                            "address",
                                                            TextInput(
                                                                title=_(
                                                                    "Address"),
                                                                allow_empty=
                                                                False,
                                                            ),
                                                        ),
                                                        (
                                                            "port",
                                                            NetworkPort(
                                                                title=_(
                                                                    "Port"),
                                                                default_value=
                                                                514,
                                                            ),
                                                        ),
                                                        (
                                                            "spool",
                                                            Dictionary(
                                                                title=
                                                                _("Spool messages that could not be sent"
                                                                  ),
                                                                help=
                                                                _("Messages that can not be forwarded, e.g. when the target Event Console is "
                                                                  "not running, can temporarily be stored locally. Forwarding is tried again "
                                                                  "on next execution. When messages are spooled, the check will go into WARNING "
                                                                  "state. In case messages are dropped by the rules below, the check will shortly "
                                                                  "go into CRITICAL state for this execution."
                                                                  ),
                                                                elements=[
                                                                    (
                                                                        "max_age",
                                                                        Age(
                                                                            title
                                                                            =_(
                                                                                "Maximum spool duration"
                                                                            ),
                                                                            help
                                                                            =_(
                                                                                "Messages that are spooled longer than this time will be thrown away."
                                                                            ),
                                                                            default_value
                                                                            =60
                                                                            *
                                                                            60
                                                                            *
                                                                            24
                                                                            *
                                                                            7,  # 1 week should be fine (if size is not exceeded)
                                                                        ),
                                                                    ),
                                                                    (
                                                                        "max_size",
                                                                        Filesize(
                                                                            title
                                                                            =_(
                                                                                "Maximum spool size"
                                                                            ),
                                                                            help=
                                                                            _("When the total size of spooled messages exceeds this number, the oldest "
                                                                              "messages of the currently spooled messages is thrown away until the left "
                                                                              "messages have the half of the maximum size."
                                                                              ),
                                                                            default_value
                                                                            =
                                                                            500000,  # do not save more than 500k of message
                                                                        ),
                                                                    ),
                                                                ],
                                                                optional_keys=
                                                                [],
                                                            ),
                                                        ),
                                                    ],
                                                    optional_keys=["spool"],
                                                ),
                                            ),
                                            (
                                                "udp",
                                                _("Send via UDP"),
                                                Dictionary(
                                                    elements=[
                                                        (
                                                            "address",
                                                            TextInput(
                                                                title=_(
                                                                    "Address"),
                                                                allow_empty=
                                                                False,
                                                            ),
                                                        ),
                                                        (
                                                            "port",
                                                            NetworkPort(
                                                                title=_(
                                                                    "Port"),
                                                                default_value=
                                                                514,
                                                            ),
                                                        ),
                                                    ],
                                                    optional_keys=[],
                                                ),
                                            ),
                                        ],
                                    ),
                                ],
                                match=lambda x: 4 if isinstance(x, tuple) else
                                (0 if not x else
                                 (2 if x == "spool:" else
                                  (3 if x.startswith("spool:") else 1))),
                            ),
                            # migrate old (tcp, address, port) tuple to new dict
                            forth=lambda v: (v[0], {
                                "address": v[1],
                                "port": v[2]
                            }) if (isinstance(v, tuple) and not isinstance(
                                v[1], dict)) else v,
                        ),
                    ),
                    (
                        "facility",
                        DropdownChoice(
                            title=_("Syslog facility for forwarded messages"),
                            help=_(
                                "When forwarding messages and no facility can be extracted from the "
                                "message this facility is used."),
                            choices=mkeventd.syslog_facilities,
                            default_value=17,  # local1
                        ),
                    ),
                    (
                        "restrict_logfiles",
                        ListOfStrings(
                            title=
                            _("Restrict Logfiles (Prefix matching regular expressions)"
                              ),
                            help=
                            _('Put the item names of the logfiles here. For example "System$" '
                              'to select the service "LOG System". You can use regular expressions '
                              "which must match the beginning of the logfile name."
                              ),
                        ),
                    ),
                    (
                        "monitor_logfilelist",
                        Checkbox(
                            title=_("Monitoring of forwarded logfiles"),
                            label=_(
                                "Warn if list of forwarded logfiles changes"),
                            help=
                            _("If this option is enabled, the check monitors the list of forwarded "
                              "logfiles and will warn you if at any time a logfile is missing or exceeding "
                              "when compared to the initial list that was snapshotted during service detection. "
                              "Reinventorize this check in order to make it OK again."
                              ),
                        ),
                    ),
                    (
                        "expected_logfiles",
                        ListOf(
                            TextInput(),
                            title=_("List of expected logfiles"),
                            help=
                            _("When the monitoring of forwarded logfiles is enabled, the check verifies that "
                              "all of the logfiles listed here are reported by the monitored system."
                              ),
                        ),
                    ),
                    (
                        "logwatch_reclassify",
                        Checkbox(
                            title=
                            _("Reclassify messages before forwarding them to the EC"
                              ),
                            label=_("Apply logwatch patterns"),
                            help=
                            _("If this option is enabled, the logwatch lines are first reclassified by the logwatch "
                              "patterns before they are sent to the event console. If you reclassify specific lines to "
                              "IGNORE they are not forwarded to the event console. This takes the burden from the "
                              "event console to process the message itself through all of its rulesets. The reclassifcation "
                              "of each line takes into account from which logfile the message originates. So you can create "
                              "logwatch reclassification rules specifically designed for a logfile <i>access.log</i>, "
                              "which do not apply to other logfiles."),
                        ),
                    ),
                    (
                        "separate_checks",
                        Checkbox(
                            title=_(
                                "Create a separate check for each logfile"),
                            label=_("Separate check"),
                            help=
                            _("If this option is enabled, there will be one separate check for each logfile found during "
                              "the service discovery. This option also changes the behaviour for unknown logfiles. "
                              "The default logwatch check forwards all logfiles to the event console, even logfiles "
                              "which were not known during the service discovery. Creating one check per logfile changes "
                              "this behaviour so that any data from unknown logfiles is discarded."
                              ),
                        ),
                    ),
                ],
                optional_keys=[
                    "restrict_logfiles",
                    "expected_logfiles",
                    "logwatch_reclassify",
                    "separate_checks",
                ],
                ignored_keys=["service_level"],
            ),
        ],
        default_value="",
    )
Пример #11
0
 def vs_parameters(cls):
     return [
         (
             "rows",
             ListOf(
                 valuespec=Dictionary(
                     elements=[
                         (
                             "title",
                             TextInput(
                                 title=_("Title"),
                                 allow_empty=False,
                             ),
                         ),
                         (
                             "query",
                             CascadingDropdown(
                                 orientation="horizontal",
                                 title=_("Query"),
                                 label=_("Table") + ": ",
                                 choices=[
                                     (
                                         "hosts",
                                         _("Hosts"),
                                         visuals.VisualFilterList(
                                             info_list=["host"],
                                         ),
                                     ),
                                     (
                                         "services",
                                         _("Services"),
                                         visuals.VisualFilterList(
                                             info_list=["host", "service"],
                                         ),
                                     ),
                                     (
                                         "events",
                                         _("Events"),
                                         visuals.VisualFilterList(
                                             info_list=["host", "event"],
                                         ),
                                     ),
                                 ],
                             ),
                         ),
                     ],
                     optional_keys=[],
                 ),
                 title=_("Rows"),
                 add_label=_("Add new row"),
                 del_label=_("Delete this row"),
                 allow_empty=False,
             ),
         ),
         (
             "show_stale",
             Checkbox(
                 title=_("Show stale hosts and services"),
                 default_value=True,
             ),
         ),
         (
             "show_failed_notifications",
             Checkbox(
                 title=_("Show failed notifications"),
                 default_value=True,
             ),
         ),
         (
             "show_sites_not_connected",
             Checkbox(
                 title=_("Display a message if sites are not connected"),
                 default_value=True,
             ),
         ),
     ]
Пример #12
0
Файл: if.py Проект: m4c3/checkMK
 def parameter_valuespec(self):
     # Transform old traffic related levels which used "traffic" and "traffic_minimum"
     # keys where each was configured with an Alternative valuespec
     return Transform(
         Dictionary(
             ignored_keys=[
                 "aggregate"
             ],  # Created by discovery when using interface grouping
             elements=[
                 ("errors",
                  Alternative(
                      title=_("Levels for error rates"),
                      help=
                      _("These levels make the check go warning or critical whenever the "
                        "<b>percentual error rate</b> or the <b>absolute error rate</b> of the monitored interface reaches "
                        "the given bounds. The percentual error rate is computed by dividing number of "
                        "errors by the total number of packets (successful plus errors)."
                        ),
                      elements=[
                          Tuple(
                              title=_("Percentual levels for error rates"),
                              elements=[
                                  Percentage(title=_("Warning at"),
                                             unit=_("percent errors"),
                                             default_value=0.01,
                                             display_format='%.3f'),
                                  Percentage(title=_("Critical at"),
                                             unit=_("percent errors"),
                                             default_value=0.1,
                                             display_format='%.3f')
                              ]),
                          Tuple(title=_("Absolute levels for error rates"),
                                elements=[
                                    Integer(title=_("Warning at"),
                                            unit=_("errors")),
                                    Integer(title=_("Critical at"),
                                            unit=_("errors"))
                                ])
                      ])),
                 ("speed",
                  OptionalDropdownChoice(
                      title=_("Operating speed"),
                      help=
                      _("If you use this parameter then the check goes warning if the "
                        "interface is not operating at the expected speed (e.g. it "
                        "is working with 100Mbit/s instead of 1Gbit/s.<b>Note:</b> "
                        "some interfaces do not provide speed information. In such cases "
                        "this setting is used as the assumed speed when it comes to "
                        "traffic monitoring (see below)."),
                      choices=[
                          (None, _("ignore speed")),
                          (10000000, "10 Mbit/s"),
                          (100000000, "100 Mbit/s"),
                          (1000000000, "1 Gbit/s"),
                          (10000000000, "10 Gbit/s"),
                      ],
                      otherlabel=_("specify manually ->"),
                      explicit=Integer(
                          title=_("Other speed in bits per second"),
                          label=_("Bits per second")))),
                 ("state",
                  Optional(
                      ListChoice(title=_("Allowed states:"),
                                 choices=defines.interface_oper_states()),
                      title=_("Operational state"),
                      help=
                      _("If you activate the monitoring of the operational state (<tt>ifOperStatus</tt>) "
                        "the check will get warning or critical if the current state "
                        "of the interface does not match one of the expected states. Note: the status 9 (<i>admin down</i>) "
                        "is only visible if you activate this status during switch port inventory or if you manually "
                        "use the check plugin <tt>if64adm</tt> instead of <tt>if64</tt>."
                        ),
                      label=_("Ignore the operational state"),
                      none_label=_("ignore"),
                      negate=True)),
                 ("map_operstates",
                  ListOf(
                      Tuple(
                          orientation="horizontal",
                          elements=[
                              DropdownChoice(
                                  choices=defines.interface_oper_states()),
                              MonitoringState()
                          ]),
                      title=_('Map operational states'),
                  )),
                 ("assumed_speed_in",
                  OptionalDropdownChoice(
                      title=_("Assumed input speed"),
                      help=
                      _("If the automatic detection of the link speed does not work "
                        "or the switch's capabilities are throttled because of the network setup "
                        "you can set the assumed speed here."),
                      choices=[
                          (None, _("ignore speed")),
                          (10000000, "10 Mbit/s"),
                          (100000000, "100 Mbit/s"),
                          (1000000000, "1 Gbit/s"),
                          (10000000000, "10 Gbit/s"),
                      ],
                      otherlabel=_("specify manually ->"),
                      default_value=16000000,
                      explicit=Integer(
                          title=_("Other speed in bits per second"),
                          label=_("Bits per second"),
                          size=10))),
                 ("assumed_speed_out",
                  OptionalDropdownChoice(
                      title=_("Assumed output speed"),
                      help=
                      _("If the automatic detection of the link speed does not work "
                        "or the switch's capabilities are throttled because of the network setup "
                        "you can set the assumed speed here."),
                      choices=[
                          (None, _("ignore speed")),
                          (10000000, "10 Mbit/s"),
                          (100000000, "100 Mbit/s"),
                          (1000000000, "1 Gbit/s"),
                          (10000000000, "10 Gbit/s"),
                      ],
                      otherlabel=_("specify manually ->"),
                      default_value=1500000,
                      explicit=Integer(
                          title=_("Other speed in bits per second"),
                          label=_("Bits per second"),
                          size=12))),
                 ("unit",
                  RadioChoice(
                      title=_("Measurement unit"),
                      help=
                      _("Here you can specifiy the measurement unit of the network interface"
                        ),
                      default_value="byte",
                      choices=[
                          ("bit", _("Bits")),
                          ("byte", _("Bytes")),
                      ],
                  )),
                 ("infotext_format",
                  DropdownChoice(
                      title=_("Change infotext in check output"),
                      help=
                      _("This setting allows you to modify the information text which is displayed between "
                        "the two brackets in the check output. Please note that this setting does not work for "
                        "grouped interfaces, since the additional information of grouped interfaces is different"
                        ),
                      choices=[
                          ("alias", _("Show alias")),
                          ("description", _("Show description")),
                          ("alias_and_description",
                           _("Show alias and description")),
                          ("alias_or_description",
                           _("Show alias if set, else description")),
                          ("desription_or_alias",
                           _("Show description if set, else alias")),
                          ("hide", _("Hide infotext")),
                      ])),
                 ("traffic",
                  ListOf(
                      CascadingDropdown(title=_("Direction"),
                                        orientation="horizontal",
                                        choices=[
                                            ('both', _("In / Out"),
                                             vs_interface_traffic()),
                                            ('in', _("In"),
                                             vs_interface_traffic()),
                                            ('out', _("Out"),
                                             vs_interface_traffic()),
                                        ]),
                      title=_(
                          "Used bandwidth (minimum or maximum traffic)"),
                      help=
                      _("Setting levels on the used bandwidth is optional. If you do set "
                        "levels you might also consider using averaging."),
                  )),
                 (
                     "nucasts",
                     Tuple(
                         title=_("Non-unicast packet rates"),
                         help=
                         _("Setting levels on non-unicast packet rates is optional. This may help "
                           "to detect broadcast storms and other unwanted traffic."
                           ),
                         elements=[
                             Integer(title=_("Warning at"),
                                     unit=_("pkts / sec")),
                             Integer(title=_("Critical at"),
                                     unit=_("pkts / sec")),
                         ]),
                 ),
                 ("discards",
                  Tuple(title=_("Absolute levels for discards rates"),
                        elements=[
                            Integer(title=_("Warning at"),
                                    unit=_("discards")),
                            Integer(title=_("Critical at"),
                                    unit=_("discards"))
                        ])),
                 ("average",
                  Integer(
                      title=_("Average values"),
                      help=
                      _("By activating the computation of averages, the levels on "
                        "errors and traffic are applied to the averaged value. That "
                        "way you can make the check react only on long-time changes, "
                        "not on one-minute events."),
                      unit=_("minutes"),
                      minvalue=1,
                      default_value=15,
                  )),
             ],
         ),
         forth=transform_if,
     )
Пример #13
0
def _parameter_valuespec_oracle_performance():
    def levels_tuple(Type, unit):
        return Tuple(orientation="float",
                     show_titles=False,
                     elements=[
                         Type(label=_("Warning at"), unit=unit),
                         Type(label=_("Critical at"), unit=unit),
                     ])

    # memory
    memory_choices: list = []
    for ga in oracle_sga_fields + oracle_pga_fields:
        memory_choices.append((
            ga.metric,
            ga.name,
            levels_tuple(Integer, "bytes"),
        ))

    # iostat_bytes + iostat_ios
    iostat_bytes_choices: list = []
    iostat_ios_choices: list = []
    for iofile_name, iofile_id in oracle_iofiles:
        for size_code, size_text in oracle_io_sizes:
            for io_code, io_text, io_unit in oracle_io_types:
                target_array = iostat_bytes_choices if io_unit == "bytes/s" else iostat_ios_choices
                target_array.append((
                    "oracle_ios_f_%s_%s_%s" % (iofile_id, size_code, io_code),
                    " %s %s %s" % (iofile_name, size_text, io_text),
                    levels_tuple(Integer, io_unit),
                ))

    # waitclasses
    waitclasses_choices: list = [
        (
            "oracle_wait_class_total",
            "Total waited",
            levels_tuple(Float, "1/s"),
        ),
        (
            "oracle_wait_class_total_fg",
            "Total waited (FG)",
            levels_tuple(Float, "1/s"),
        ),
    ]
    for waitclass in oracle_waitclasses:
        waitclasses_choices.append(
            (waitclass.metric, "%s wait class" % waitclass.name, levels_tuple(Float, "1/s")))
        waitclasses_choices.append(
            (waitclass.metric_fg, "%s wait class (FG)" % waitclass.name, levels_tuple(Float,
                                                                                      "1/s")))

    return Dictionary(
        help=_("Here you can set levels for the ORACLE Performance metrics."),
        elements=[
            (
                'dbtime',
                ListOf(
                    CascadingDropdown(
                        title=_("Field"),
                        orientation="horizontal",
                        choices=[
                            ("oracle_db_cpu", "DB CPU", levels_tuple(Float, "1/s")),
                            ("oracle_db_time", "DB Time", levels_tuple(Float, "1/s")),
                            ("oracle_db_wait_time", "DB Non-Idle Wait", levels_tuple(Float, "1/s")),
                        ],
                    ),
                    title=_("Levels for DB Time"),
                ),
            ),
            (
                'memory',
                ListOf(
                    CascadingDropdown(
                        title=_("Field"),
                        orientation="horizontal",
                        choices=memory_choices,
                    ),
                    title=_("Levels for Memory"),
                ),
            ),
            (
                'iostat_bytes',
                ListOf(
                    CascadingDropdown(
                        title=_("Field"),
                        orientation="horizontal",
                        choices=iostat_bytes_choices,
                    ),
                    title=_("Levels for IO Stats Bytes"),
                ),
            ),
            (
                'iostat_ios',
                ListOf(
                    CascadingDropdown(
                        title=_("Field"),
                        orientation="horizontal",
                        choices=iostat_ios_choices,
                    ),
                    title=_("Levels for IO Stats Requests"),
                ),
            ),
            (
                'waitclasses',
                ListOf(
                    CascadingDropdown(
                        title=_("Field"),
                        orientation="horizontal",
                        choices=waitclasses_choices,
                    ),
                    title=_("Levels for System Wait"),
                ),
            ),
        ],
    )
Пример #14
0
def _vs_matching_conditions():
    return CascadingDropdown(
        title=_("Conditions for this rule to apply"),
        help=_(
            "Here, you can define conditions for applying this rule. These conditions are evaluated "
            "on a per-interface basis. When discovering an interface, checkmk will first find all "
            "rules whose conditions match this interface. Then, these rules are merged together, "
            "whereby rules from subfolders overwrite rules from the main directory. Within a "
            "directory, the order of the rules matters, i.e., rules further below in the list are "
            "overwritten by rules further up."),
        choices=[
            (
                True,
                _("Match all interfaces"),
                FixedValue(
                    {},
                    totext="",
                ),
            ),
            (
                False,
                _("Specify matching conditions"),
                Dictionary(elements=[
                    (
                        "porttypes",
                        DualListChoice(
                            title=_("Match port types"),
                            help=_("Apply this rule only to interfaces whose port type is listed "
                                   "below."),
                            choices=defines.interface_port_types(),
                            rows=40,
                            default_value=[
                                '6', '32', '62', '117', '127', '128', '129', '180', '181', '182',
                                '205', '229'
                            ],
                        ),
                    ),
                    (
                        "portstates",
                        ListChoice(
                            title=_("Match port states"),
                            help=_("Apply this rule only to interfaces whose port state is listed "
                                   "below."),
                            choices=defines.interface_oper_states(),
                            toggle_all=True,
                            default_value=['1'],
                        ),
                    ),
                    (
                        "admin_states",
                        ListChoice(
                            title=_("Match admin states (SNMP with 64-bit counters only)"),
                            help=_("Apply this rule only to interfaces whose admin state "
                                   "(<tt>ifAdminStatus</tt>) is listed below. " +
                                   _note_for_admin_state_options()),
                            choices=_admin_states(),
                            toggle_all=True,
                            default_value=['1', '2', '3'],
                        ),
                    ),
                    (
                        "match_index",
                        _vs_regex_matching("index"),
                    ),
                    (
                        "match_alias",
                        _vs_regex_matching("alias"),
                    ),
                    (
                        "match_desc",
                        _vs_regex_matching("description"),
                    ),
                ],),
            ),
        ],
        sorted=False,
    )
Пример #15
0
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"),
    )
Пример #16
0
    def _connection_elements(self):
        connection_elements = [
            (
                "directory_type",
                CascadingDropdown(
                    title=_("Directory type"),
                    help=
                    _("Select the software the LDAP directory is based on. Depending on "
                      "the selection e.g. the attribute names used in LDAP queries will "
                      "be altered."),
                    choices=[
                        ("ad", _("Active Directory"),
                         self._vs_directory_options("ad")),
                        ("openldap", _("OpenLDAP"),
                         self._vs_directory_options("openldap")),
                        (
                            "389directoryserver",
                            _("389 Directory Server"),
                            self._vs_directory_options("389directoryserver"),
                        ),
                    ],
                ),
            ),
            (
                "bind",
                Tuple(
                    title=_("Bind credentials"),
                    help=
                    _("Set the credentials to be used to connect to the LDAP server. The "
                      "used account must not be allowed to do any changes in the directory "
                      "the whole connection is read only. "
                      "In some environment an anonymous connect/bind is allowed, in this "
                      "case you don't have to configure anything here."
                      "It must be possible to list all needed user and group objects from the "
                      "directory."),
                    elements=[
                        LDAPDistinguishedName(
                            title=_("Bind DN"),
                            help=
                            _("Specify the distinguished name to be used to bind to "
                              "the LDAP directory, e. g. <tt>CN=ldap,OU=users,DC=example,DC=com</tt>"
                              ),
                            size=63,
                        ),
                        IndividualOrStoredPassword(
                            title=_("Bind password"),
                            help=_(
                                "Specify the password to be used to bind to "
                                "the LDAP directory."),
                        ),
                    ],
                ),
            ),
            (
                "port",
                Integer(
                    title=_("TCP port"),
                    help=_("This variable allows to specify the TCP port to "
                           "be used to connect to the LDAP server. "),
                    minvalue=1,
                    maxvalue=65535,
                    default_value=389,
                ),
            ),
            (
                "use_ssl",
                FixedValue(
                    title=_("Use SSL"),
                    help=
                    _("Connect to the LDAP server with a SSL encrypted connection. The "
                      '<a href="wato.py?mode=edit_configvar&site=&varname=trusted_certificate_authorities">trusted '
                      "certificates authorities</a> configured in Check_MK will be used to validate the "
                      "certificate provided by the LDAP server."),
                    value=True,
                    totext=_("Encrypt the network connection using SSL."),
                ),
            ),
            (
                "connect_timeout",
                Float(
                    title=_("Connect timeout"),
                    help=
                    _("Timeout for the initial connection to the LDAP server in seconds."
                      ),
                    unit=_("Seconds"),
                    minvalue=1.0,
                    default_value=2.0,
                ),
            ),
            (
                "version",
                DropdownChoice(
                    title=_("LDAP version"),
                    help=_(
                        "Select the LDAP version the LDAP server is serving. Most modern "
                        "servers use LDAP version 3."),
                    choices=[(2, "2"), (3, "3")],
                    default_value=3,
                ),
            ),
            (
                "page_size",
                Integer(
                    title=_("Page size"),
                    help=
                    _("LDAP searches can be performed in paginated mode, for example to improve "
                      "the performance. This enables pagination and configures the size of the pages."
                      ),
                    minvalue=1,
                    default_value=1000,
                ),
            ),
            (
                "response_timeout",
                Integer(
                    title=_("Response timeout"),
                    unit=_("Seconds"),
                    help=_("Timeout for LDAP query responses."),
                    minvalue=0,
                    default_value=5,
                ),
            ),
            (
                "suffix",
                TextInput(
                    allow_empty=False,
                    title=_("LDAP connection suffix"),
                    help=
                    _("The LDAP connection suffix can be used to distinguish equal named objects "
                      "(name conflicts), for example user accounts, from different LDAP connections.<br>"
                      "It is used in the following situations:<br><br>"
                      "During LDAP synchronization, the LDAP sync might discover that a user to be "
                      "synchronized from from the current LDAP is already being synchronized from "
                      "another LDAP connection. Without the suffix configured this results in a name "
                      "conflict and the later user not being synchronized. If the connection has a "
                      "suffix configured, this suffix is added to the later username in case of the name "
                      "conflict to resolve it. The user will then be named <tt>[username]@[suffix]</tt> "
                      "instead of just <tt>[username]</tt>.<br><br>"
                      "In the case a user which users name is existing in multiple LDAP directories, "
                      "but associated to different persons, your user can insert <tt>[username]@[suffix]</tt>"
                      " during login instead of just the plain <tt>[username]</tt> to tell which LDAP "
                      "directory he is assigned to. Users without name conflict just need to provide their "
                      "regular username as usual."),
                    regex=re.compile(r"^[A-Z0-9.-]+(?:\.[A-Z]{2,24})?$", re.I),
                    validate=self._validate_ldap_connection_suffix,
                ),
            ),
        ]

        return connection_elements
Пример #17
0
def get_bi_rule_node_choices_vs():
    return Transform(
        CascadingDropdown(choices=_get_rule_choices(), sorted=False),
        forth=_convert_bi_rule_to_vs,
        back=_convert_bi_rule_from_vs,
    )
Пример #18
0
def _parameter_valuespec_rabbitmq_nodes_filedesc():
    return Dictionary(elements=[
        (
            "levels",
            CascadingDropdown(
                title=_("Levels for file descriptor usage"),
                choices=[
                    (
                        "fd_perc",
                        _("Percentual levels for used file descriptors"),
                        Tuple(elements=[
                            Percentage(
                                title=_("Warning at usage of"),
                                default_value=80.0,
                                maxvalue=None,
                            ),
                            Percentage(
                                title=_("Critical at usage of"),
                                default_value=90.0,
                                maxvalue=None,
                            ),
                        ], ),
                    ),
                    (
                        "fd_abs",
                        _("Absolut level for total number of used file descriptors"
                          ),
                        Tuple(elements=[
                            Integer(title=_("Warning at"), unit="descriptors"),
                            Integer(title=_("Critical at"),
                                    unit="descriptors"),
                        ], ),
                    ),
                ],
            ),
        ),
        (
            "fd_open_upper",
            Tuple(
                title=_("Upper level for file descriptor open attempts"),
                elements=[
                    Integer(title=_("Warning at"), unit="open attempts"),
                    Integer(title=_("Critical at"), unit="open attempts"),
                ],
            ),
        ),
        (
            "fd_open_rate_upper",
            Tuple(
                title=_("Upper level for file descriptor open attempts rate"),
                elements=[
                    Float(title=_("Warning at"), unit="1/s"),
                    Float(title=_("Critical at"), unit="1/s"),
                ],
            ),
        ),
        (
            "fd_open_rate_lower",
            Tuple(
                title=_("Lower level for file descriptor open attempts rate"),
                elements=[
                    Float(title=_("Warning below"), unit="1/s"),
                    Float(title=_("Critical below"), unit="1/s"),
                ],
            ),
        ),
    ], )
Пример #19
0
    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",
                TextInput(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,
                            ),
                        ),
                    ],
                ),
            ),
        ]
Пример #20
0
 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),
                     ],
                 ),
             ),
         ],
     )
Пример #21
0
def _valuespec_special_agents_kubernetes():
    return Transform(
        valuespec=Dictionary(
            elements=[
                (
                    "api-server-endpoint",
                    CascadingDropdown(
                        choices=[
                            (
                                "hostname",
                                _("Hostname"),
                                Dictionary(
                                    elements=_kubernetes_connection_elements(
                                    )),
                            ),
                            (
                                "ipaddress",
                                _("IP address"),
                                Dictionary(
                                    elements=_kubernetes_connection_elements(
                                    )),
                            ),
                            (
                                "url_custom",
                                _("Custom URL"),
                                TextInput(
                                    allow_empty=False,
                                    size=80,
                                ),
                            ),
                        ],
                        orientation="horizontal",
                        title=_("API server endpoint"),
                        help=
                        _('The URL that will be contacted for Kubernetes API calls. If the "Hostname" '
                          'or the "IP Address" options are selected, the DNS hostname or IP address and '
                          "a secure protocol (HTTPS) are used."),
                    ),
                ),
                (
                    "token",
                    IndividualOrStoredPassword(
                        title=_("Token"),
                        allow_empty=False,
                    ),
                ),
                (
                    "no-cert-check",
                    Alternative(
                        title=_("SSL certificate verification"),
                        elements=[
                            FixedValue(value=False,
                                       title=_("Verify the certificate"),
                                       totext=""),
                            FixedValue(
                                value=True,
                                title=_(
                                    "Ignore certificate errors (unsecure)"),
                                totext="",
                            ),
                        ],
                        default_value=False,
                    ),
                ),
                (
                    "namespaces",
                    Alternative(
                        title=_("Namespace prefix for hosts"),
                        elements=[
                            FixedValue(value=False,
                                       title=_("Don't use a namespace prefix"),
                                       totext=""),
                            FixedValue(value=True,
                                       title=_("Use a namespace prefix"),
                                       totext=""),
                        ],
                        help=
                        _("If a cluster uses multiple namespaces you need to activate this option. "
                          "Hosts for namespaced Kubernetes objects will then be prefixed with the "
                          "name of their namespace. This makes Kubernetes resources in different "
                          "namespaces that have the same name distinguishable, but results in "
                          "longer hostnames."),
                        default_value=False,
                    ),
                ),
                (
                    "infos",
                    ListChoice(
                        choices=[
                            ("nodes", _("Nodes")),
                            ("services", _("Services")),
                            ("ingresses", _("Ingresses")),
                            ("deployments", _("Deployments")),
                            ("pods", _("Pods")),
                            ("endpoints", _("Endpoints")),
                            ("daemon_sets", _("Daemon sets")),
                            ("stateful_sets", _("Stateful sets")),
                            ("jobs", _("Job")),
                        ],
                        default_value=[
                            "nodes",
                            "endpoints",
                            "ingresses",
                        ],
                        allow_empty=False,
                        title=_("Retrieve information about..."),
                    ),
                ),
                filter_kubernetes_namespace_element(),
            ],
            optional_keys=[
                "port", "url-prefix", "path-prefix",
                "namespace_include_patterns"
            ],
            title=_("Kubernetes (deprecated)"),
            help=_(
                "This special agent is deprecated and will be removed in "
                'Checkmk version 2.2.0. Please use the "Kubernetes" ruleset to '
                "configure the new special agent for Kubernetes."),
        ),
        forth=special_agents_kubernetes_transform,
    )
Пример #22
0
def _parameter_valuespec_memory_simple():
    return Transform(
        valuespec=Dictionary(
            help=_(
                "Memory levels for simple devices not running more complex OSs"
            ),
            elements=[
                (
                    "levels",
                    CascadingDropdown(
                        title=_("Levels for RAM usage"),
                        choices=[
                            (
                                "perc_used",
                                _("Percentual levels for used RAM"),
                                Tuple(elements=[
                                    Percentage(
                                        title=_("Warning at a RAM usage of"),
                                        default_value=80.0,
                                        maxvalue=None,
                                    ),
                                    Percentage(
                                        title=_("Critical at a RAM usage of"),
                                        default_value=90.0,
                                        maxvalue=None,
                                    ),
                                ], ),
                            ),
                            (
                                "abs_free",
                                _("Absolute levels for free RAM"),
                                Tuple(elements=[
                                    Filesize(title=_("Warning below")),
                                    Filesize(title=_("Critical below")),
                                ], ),
                            ),
                        ],
                    ),
                ),
                (
                    "levels_swap",
                    CascadingDropdown(
                        title=_("Levels for swap usage"),
                        choices=[
                            (
                                "perc_used",
                                _("Percentual levels for used swap"),
                                Tuple(elements=[
                                    Percentage(
                                        title=_("Warning at a swap usage of"),
                                        maxvalue=None),
                                    Percentage(
                                        title=_("Critical at a swap usage of"),
                                        maxvalue=None),
                                ], ),
                            ),
                            (
                                "abs_free",
                                _("Absolute levels for free swap"),
                                Tuple(elements=[
                                    Filesize(title=_("Warning below")),
                                    Filesize(title=_("Critical below")),
                                ], ),
                            ),
                        ],
                    ),
                ),
                (
                    "swap_errors",
                    MonitoringState(
                        title=_("Monitoring state in case of swap errors"),
                        default_value=0,
                    ),
                ),
            ],
            optional_keys=True,
        ),
        # Convert default levels from discovered checks
        forth=lambda v: not isinstance(v, dict) and
        {"levels": ("perc_used", v)} or v,
    )
Пример #23
0
def get_fileinfo_groups_param_elements():
    return [
        (
            "minage_oldest",
            Tuple(
                title=_("Minimal age of oldest file"),
                elements=[
                    Age(title=_("Warning below")),
                    Age(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxage_oldest",
            Tuple(
                title=_("Maximal age of oldest file"),
                elements=[
                    Age(title=_("Warning at or above")),
                    Age(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minage_newest",
            Tuple(
                title=_("Minimal age of newest file"),
                elements=[
                    Age(title=_("Warning below")),
                    Age(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxage_newest",
            Tuple(
                title=_("Maximal age of newest file"),
                elements=[
                    Age(title=_("Warning at or above")),
                    Age(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize_smallest",
            Tuple(
                title=_("Minimal size of smallest file"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize_smallest",
            Tuple(
                title=_("Maximal size of smallest file"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize_largest",
            Tuple(
                title=_("Minimal size of largest file"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize_largest",
            Tuple(
                title=_("Maximal size of largest file"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize",
            Tuple(
                title=_("Minimal size"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize",
            Tuple(
                title=_("Maximal size"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "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")),
                ],
            ),
        ),
        (
            "timeofday",
            ListOfTimeRanges(
                title=_("Only check during the following times of the day"),
                help=_("Outside these ranges the check will always be OK"),
            ),
        ),
        (
            "conjunctions",
            ListOf(
                Tuple(elements=[
                    MonitoringState(title=_("Monitoring state"),
                                    default_value=2),
                    ListOf(
                        CascadingDropdown(
                            orientation="horizontal",
                            choices=[
                                ("count", _("File count at"), Integer()),
                                ("count_lower", _("File count below"),
                                 Integer()),
                                ("size", _("File size at"), Filesize()),
                                ("size_lower", _("File size below"),
                                 Filesize()),
                                ("size_largest", _("Largest file size at"),
                                 Filesize()),
                                (
                                    "size_largest_lower",
                                    _("Largest file size below"),
                                    Filesize(),
                                ),
                                ("size_smallest", _("Smallest file size at"),
                                 Filesize()),
                                (
                                    "size_smallest_lower",
                                    _("Smallest file size below"),
                                    Filesize(),
                                ),
                                ("age_oldest", _("Oldest file age at"), Age()),
                                ("age_oldest_lower",
                                 _("Oldest file age below"), Age()),
                                ("age_newest", _("Newest file age at"), Age()),
                                ("age_newest_lower",
                                 _("Newest file age below"), Age()),
                            ],
                        ),
                        magic="@#@#",
                    ),
                ], ),
                title=_("Level conjunctions"),
                help=
                _("In order to check dependent file group statistics you can configure "
                  "conjunctions of single levels now. A conjunction consists of a monitoring state "
                  "and any number of upper or lower levels. If all of the configured levels within "
                  "a conjunction are reached then the related state is reported."
                  ),
            ),
        ),
    ]
Пример #24
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"),
                ),
            ),
        ])
Пример #25
0
def vs_graph_render_option_elements(default_values=None, exclude=None):
    # Allow custom default values to be specified by the caller. This is, for example,
    # needed by the dashlets which should add the host/service by default.
    if default_values is None:
        default_values = artwork.get_default_graph_render_options()
    else:
        default_values = default_values.copy()
        for k, v in artwork.get_default_graph_render_options().items():
            default_values.setdefault(k, v)

    elements = [
        ("font_size", Fontsize(default_value=default_values["font_size"], )),
        ("show_title",
         DropdownChoice(
             title=_("Title"),
             choices=[
                 (False, _("Don't show graph title")),
                 (True, _("Show graph title")),
                 ("inline", _("Show graph title on graph area")),
             ],
             default_value=default_values["show_title"],
         )),
        ("title_format",
         Transform(
             vs_title_infos(),
             forth=transform_graph_render_options_title_format,
         )),
        ("show_graph_time",
         Checkbox(
             title=_("Show graph time range"),
             label=_("Show the graph time range on top of the graph"),
             default_value=default_values["show_graph_time"],
         )),
        ("show_margin",
         Checkbox(
             title=_("Show margin round the graph"),
             label=_("Show a margin round the graph"),
             default_value=default_values["show_margin"],
         )),
        ("show_legend",
         Checkbox(
             title=_("Show legend"),
             label=_("Show the graph legend"),
             default_value=default_values["show_legend"],
         )),
        ("show_vertical_axis",
         Checkbox(
             title=_("Show vertical axis"),
             label=_("Show the graph vertical axis"),
             default_value=default_values["show_vertical_axis"],
         )),
        ("vertical_axis_width",
         CascadingDropdown(
             title=_("Vertical axis width"),
             orientation="horizontal",
             choices=[
                 ("fixed", _("Use fixed width (relative to font size)")),
                 ("explicit", _("Use absolute width:"),
                  Float(title="", default_value=40.0, unit=_("pt"))),
             ],
         )),
        ("show_time_axis",
         Checkbox(
             title=_("Show time axis"),
             label=_("Show the graph time axis"),
             default_value=default_values["show_time_axis"],
         )),
        ("show_controls",
         Checkbox(
             title=_("Show controls"),
             label=_("Show the graph controls"),
             default_value=default_values["show_controls"],
         )),
        ("show_pin",
         Checkbox(
             title=_("Show pin"),
             label=_("Show the pin"),
             default_value=default_values["show_pin"],
         )),
        ("show_time_range_previews",
         Checkbox(
             title=_("Show time range previews"),
             label="Show previews",
             default_value=default_values["show_time_range_previews"],
         )),
        ("foreground_color",
         GraphColor(
             title=_("Foreground color"),
             default_value=default_values["foreground_color"],
         )),
        ("background_color",
         GraphColor(
             title=_("Background color"),
             default_value=default_values["background_color"],
         )),
        ("canvas_color",
         GraphColor(
             title=_("Canvas color"),
             default_value=default_values["canvas_color"],
         )),
    ]

    if exclude:
        elements = [x for x in elements if x[0] not in exclude]

    return elements
Пример #26
0
 def spec(self):
     return Dictionary(
         title=_("Create notification with the following parameters"),
         optional_keys=["url_prefix", "proxy_url", "priority", "sound"],
         elements=[
             ("api_key",
              TextAscii(
                  title=_("API Key"),
                  help=
                  _("You need to provide a valid API key to be able to send push notifications "
                    "using Pushover. Register and login to <a href=\"https://www.pushover.net\" "
                    "target=\"_blank\">Pushover</a>, thn create your Check_MK installation as "
                    "application and obtain your API key."),
                  size=40,
                  allow_empty=False,
                  regex="[a-zA-Z0-9]{30}",
              )),
             ("recipient_key",
              TextAscii(
                  title=_("User / Group Key"),
                  help=
                  _("Configure the user or group to receive the notifications by providing "
                    "the user or group key here. The key can be obtained from the Pushover "
                    "website."),
                  size=40,
                  allow_empty=False,
                  regex="[a-zA-Z0-9]{30}",
              )),
             ("url_prefix",
              TextAscii(
                  title=_("URL prefix for links to Check_MK"),
                  help=
                  _("If you specify an URL prefix here, then several parts of the "
                    "email body are armed with hyperlinks to your Check_MK GUI, so "
                    "that the recipient of the email can directly visit the host or "
                    "service in question in Check_MK. Specify an absolute URL including "
                    "the <tt>.../check_mk/</tt>"),
                  regex="^(http|https)://.*/check_mk/$",
                  regex_error=_(
                      "The URL must begin with <tt>http</tt> or "
                      "<tt>https</tt> and end with <tt>/check_mk/</tt>."),
                  size=64,
                  default_value=local_site_url,
              )),
             (
                 "proxy_url",
                 Transform(
                     HTTPProxyReference(),
                     # Transform legacy explicit TextAscii() proxy URL
                     forth=lambda v: ("url", v)
                     if isinstance(v, str) else v,
                 )),
             ("priority",
              Transform(
                  CascadingDropdown(
                      title=_("Priority"),
                      choices=[
                          ("2",
                           _("Emergency: Repeat push notification in intervalls till expire time."
                             ),
                           Tuple(elements=[
                               Age(title=_("Retry time")),
                               Age(title=_("Expire time")),
                               TextAscii(
                                   title=_("Receipt"),
                                   help=
                                   _("The receipt can be used to periodically poll receipts API to get "
                                     "the status of the notification. "
                                     "See <a href=\"https://pushover.net/api#receipt\" target=\"_blank\">"
                                     "Pushover receipts and callbacks</a> for more information."
                                     ),
                                   size=40,
                                   regex="[a-zA-Z0-9]{0,30}"),
                           ])),
                          ("1",
                           _("High: Push notification alerts bypass quiet hours"
                             )),
                          ("0",
                           _("Normal: Regular push notification (default)")
                           ),
                          ("-1",
                           _("Low: No sound/vibration but show popup")),
                          ("-2",
                           _("Lowest: No notification, update badge number")
                           ),
                      ],
                      default_value="0",
                  ),
                  forth=self._transform_forth_pushover_priority,
                  back=self._transform_back_pushover_priority,
              )),
             ("sound",
              DropdownChoice(
                  title=_("Select sound"),
                  help=
                  _("See <a href=\"https://pushover.net/api#sounds\" target=\"_blank\">"
                    "Pushover sounds</a> for more information and trying out available sounds."
                    ),
                  choices=[
                      ("none", _("None (silent)")),
                      ("alien", _("Alien Alarm (long)")),
                      ("bike", _("Bike")),
                      ("bugle", _("Bugle")),
                      ("cashregister", _("Cash Register")),
                      ("classical", _("Classical")),
                      ("climb", _("Climb (long)")),
                      ("cosmic", _("Cosmic")),
                      ("echo", _("Pushover Echo (long)")),
                      ("falling", _("Falling")),
                      ("gamelan", _("Gamelan")),
                      ("incoming", _("Incoming")),
                      ("intermission", _("Intermission")),
                      ("magic", _("Magic")),
                      ("mechanical", _("Mechanical")),
                      ("persistent", _("Persistent (long)")),
                      ("pianobar", _("Piano Bar")),
                      ("pushover", _("Pushover")),
                      ("siren", _("Siren")),
                      ("spacealarm", _("Space Alarm")),
                      ("tugboat", _("Tug Boat")),
                      ("updown", _("Up Down (long)")),
                  ],
                  default_value="none")),
         ],
     )
Пример #27
0
def _parameter_valuespec_if():
    # Transform old traffic related levels which used "traffic" and "traffic_minimum"
    # keys where each was configured with an Alternative valuespec
    return Transform(
        Dictionary(
            ignored_keys=[
                "aggregate",
                "discovered_oper_status",
                "discovered_admin_status",
                "discovered_speed",
            ],  # Created by discovery
            elements=[
                ("errors_in", _vs_if_errors("IN")),
                ("errors_out", _vs_if_errors("OUT")),
                ("speed",
                 OptionalDropdownChoice(
                     title=_("Operating speed"),
                     help=_("If you use this parameter then the check goes warning if the "
                            "interface is not operating at the expected speed (e.g. it "
                            "is working with 100Mbit/s instead of 1Gbit/s.<b>Note:</b> "
                            "some interfaces do not provide speed information. In such cases "
                            "this setting is used as the assumed speed when it comes to "
                            "traffic monitoring (see below)."),
                     choices=[
                         (None, _("ignore speed")),
                         (10000000, "10 Mbit/s"),
                         (100000000, "100 Mbit/s"),
                         (1000000000, "1 Gbit/s"),
                         (10000000000, "10 Gbit/s"),
                     ],
                     otherlabel=_("specify manually ->"),
                     explicit=Integer(title=_("Other speed in bits per second"),
                                      label=_("Bits per second")))),
                ("state",
                 Optional(ListChoice(
                     title=_("Allowed operational states:"),
                     choices=defines.interface_oper_states(),
                     allow_empty=False,
                 ),
                          title=_("Operational state"),
                          help=_(
                              "If you activate the monitoring of the operational state "
                              "(<tt>ifOperStatus</tt>), the check will go critical if the current "
                              "state of the interface does not match one of the expected states."),
                          label=_("Ignore the operational state"),
                          none_label=_("ignore"),
                          negate=True)),
                ("map_operstates",
                 ListOf(
                     Tuple(orientation="horizontal",
                           elements=[
                               ListChoice(
                                   choices=defines.interface_oper_states(),
                                   allow_empty=False,
                               ),
                               MonitoringState()
                           ]),
                     title=_('Map operational states'),
                     help=_(
                         'Map the operational state (<tt>ifOperStatus</tt>) to a monitoring state.')
                 )),
                ("admin_state",
                 Optional(
                     ListChoice(
                         title=_("Allowed admin states:"),
                         choices=_admin_states(),
                         allow_empty=False,
                     ),
                     title=_("Admin state (SNMP with 64-bit counters only)"),
                     help=_("If you activate the monitoring of the admin state "
                            "(<tt>ifAdminStatus</tt>), the check will go critical if the "
                            "current state of the interface does not match one of the expected "
                            "states. " + _note_for_admin_state_options()),
                     label=_("Ignore the admin state"),
                     none_label=_("ignore"),
                     negate=True)),
                ("map_admin_states",
                 ListOf(
                     Tuple(orientation="horizontal",
                           elements=[
                               ListChoice(
                                   choices=_admin_states(),
                                   allow_empty=False,
                               ),
                               MonitoringState(),
                           ]),
                     title=_('Map admin states (SNMP with 64-bit counters only)'),
                     help=_("Map the admin state (<tt>ifAdminStatus</tt>) to a monitoring state. " +
                            _note_for_admin_state_options()),
                 )),
                ("assumed_speed_in",
                 OptionalDropdownChoice(
                     title=_("Assumed input speed"),
                     help=_(
                         "If the automatic detection of the link speed does not work "
                         "or the switch's capabilities are throttled because of the network setup "
                         "you can set the assumed speed here."),
                     choices=[
                         (None, _("ignore speed")),
                         (10000000, "10 Mbit/s"),
                         (100000000, "100 Mbit/s"),
                         (1000000000, "1 Gbit/s"),
                         (10000000000, "10 Gbit/s"),
                     ],
                     otherlabel=_("specify manually ->"),
                     default_value=16000000,
                     explicit=Integer(title=_("Other speed in bits per second"),
                                      label=_("Bits per second"),
                                      size=10))),
                ("assumed_speed_out",
                 OptionalDropdownChoice(
                     title=_("Assumed output speed"),
                     help=_(
                         "If the automatic detection of the link speed does not work "
                         "or the switch's capabilities are throttled because of the network setup "
                         "you can set the assumed speed here."),
                     choices=[
                         (None, _("ignore speed")),
                         (10000000, "10 Mbit/s"),
                         (100000000, "100 Mbit/s"),
                         (1000000000, "1 Gbit/s"),
                         (10000000000, "10 Gbit/s"),
                     ],
                     otherlabel=_("specify manually ->"),
                     default_value=1500000,
                     explicit=Integer(title=_("Other speed in bits per second"),
                                      label=_("Bits per second"),
                                      size=12))),
                ("unit",
                 DropdownChoice(
                     title=_("Measurement unit"),
                     help=_("Here you can specifiy the measurement unit of the network interface"),
                     default_value="byte",
                     choices=[
                         ("bit", _("Bits")),
                         ("byte", _("Bytes")),
                     ],
                 )),
                ("infotext_format",
                 DropdownChoice(
                     title=_("Change infotext in check output"),
                     help=
                     _("This setting allows you to modify the information text which is displayed between "
                       "the two brackets in the check output. Please note that this setting does not work for "
                       "grouped interfaces, since the additional information of grouped interfaces is different"
                      ),
                     choices=[
                         ("alias", _("Show alias")),
                         ("description", _("Show description")),
                         ("alias_and_description", _("Show alias and description")),
                         ("alias_or_description", _("Show alias if set, else description")),
                         ("desription_or_alias", _("Show description if set, else alias")),
                         ("hide", _("Hide infotext")),
                     ])),
                ("traffic",
                 ListOf(
                     CascadingDropdown(title=_("Direction"),
                                       orientation="horizontal",
                                       choices=[
                                           ('both', _("In / Out"), vs_interface_traffic()),
                                           ('in', _("In"), vs_interface_traffic()),
                                           ('out', _("Out"), vs_interface_traffic()),
                                       ]),
                     title=_("Used bandwidth (minimum or maximum traffic)"),
                     help=_("Setting levels on the used bandwidth is optional. If you do set "
                            "levels you might also consider using averaging."),
                 )),
                ("total_traffic",
                 ListOf(
                     CascadingDropdown(title=_("Direction"),
                                       orientation="horizontal",
                                       choices=[
                                           ('total', _("Total traffic"), vs_interface_traffic()),
                                       ]),
                     title=_("Used total bandwidth (in + out) (minimum or maximum traffic)"),
                     help=
                     _("By activating this item, the sum of incoming and outgoing traffic will "
                       "be monitored via a seperate metric. Setting levels on the used total bandwidth "
                       "is optional. If you do set levels you might also consider using averaging."
                      ),
                 )),
                ("average",
                 Integer(
                     title=_("Average values for used bandwidth"),
                     help=_("By activating the computation of averages, the levels on "
                            "traffic and speed are applied to the averaged value. That "
                            "way you can make the check react only on long-time changes, "
                            "not on one-minute events."),
                     unit=_("minutes"),
                     minvalue=1,
                     default_value=15,
                 )),
                (
                    "nucasts",
                    Tuple(
                        title=_("Non-unicast packet rates"),
                        help=_(
                            "Setting levels on non-unicast packet rates is optional. This may help "
                            "to detect broadcast storms and other unwanted traffic."),
                        elements=[
                            Integer(title=_("Warning at"), unit=_("pkts / sec")),
                            Integer(title=_("Critical at"), unit=_("pkts / sec")),
                        ]),
                ),
                ("multicast",
                 Alternative(title=_("Multicast packet rates"),
                             help=_(
                                 "These levels make the check go warning or critical whenever the "
                                 "<b>percentual packet rate</b> or the <b>absolute packet "
                                 "rate</b> of the monitored interface reaches the given "
                                 "bounds. The percentual packet rate is computed by "
                                 "dividing the number of multicast packets by the number "
                                 "of unicast packets."),
                             elements=[
                                 Tuple(title=_("Percentual levels for multicast packets"),
                                       elements=[
                                           Percentage(title=_("Warning at"),
                                                      unit=_("percent packets"),
                                                      default_value=10.0,
                                                      display_format='%.3f'),
                                           Percentage(title=_("Critical at"),
                                                      unit=_("percent packets"),
                                                      default_value=20.0,
                                                      display_format='%.3f')
                                       ]),
                                 Tuple(title=_("Absolute levels for multicast packets"),
                                       elements=[
                                           Integer(title=_("Warning at"), unit=_("pkts / sec")),
                                           Integer(title=_("Critical at"), unit=_("pkts / sec"))
                                       ])
                             ])),
                ("broadcast",
                 Alternative(title=_("Broadcast packet rates"),
                             help=_(
                                 "These levels make the check go warning or critical whenever the "
                                 "<b>percentual packet rate</b> or the <b>absolute packet "
                                 "rate</b> of the monitored interface reaches the given "
                                 "bounds. The percentual packet rate is computed by "
                                 "dividing the number of broadcast packets by the number "
                                 "of unicast packets."),
                             elements=[
                                 Tuple(title=_("Percentual levels for broadcast packets"),
                                       elements=[
                                           Percentage(title=_("Warning at"),
                                                      unit=_("percent packets"),
                                                      default_value=10.0,
                                                      display_format='%.3f'),
                                           Percentage(title=_("Critical at"),
                                                      unit=_("percent packets"),
                                                      default_value=20.0,
                                                      display_format='%.3f')
                                       ]),
                                 Tuple(title=_("Absolute levels for broadcast packets"),
                                       elements=[
                                           Integer(title=_("Warning at"), unit=_("pkts / sec")),
                                           Integer(title=_("Critical at"), unit=_("pkts / sec"))
                                       ])
                             ])),
                ("average_bm",
                 Integer(
                     title=_("Average values for broad- and multicast packet rates"),
                     help=_(
                         "By activating the computation of averages, the levels on "
                         "broad- and multicast packet rates are applied to "
                         "the averaged value. That way you can make the check react only on long-time "
                         "changes, not on one-minute events."),
                     unit=_("minutes"),
                     minvalue=1,
                     default_value=15,
                 )),
                ("discards",
                 Tuple(title=_("Absolute levels for discards rates"),
                       elements=[
                           Integer(title=_("Warning at"), unit=_("discards")),
                           Integer(title=_("Critical at"), unit=_("discards"))
                       ])),
                ("match_same_speed",
                 DropdownChoice(title=_("Speed of interface groups (Netapp only)"),
                                help=_("Choose the behaviour for different interface speeds in "
                                       "interface groups. The default is \"Check and WARN\". This "
                                       "feature is currently only supported by the check "
                                       "netapp_api_if."),
                                choices=[
                                    ("check_and_warn", _("Check and WARN")),
                                    ("check_and_crit", _("Check and CRIT")),
                                    ("check_and_display", _("Check and display only")),
                                    ("dont_show_and_check", _("Don't show and check")),
                                ])),
                ("home_port",
                 DropdownChoice(title=_("Is-Home state (Netapp only)"),
                                help=_("Choose the behaviour when the current port is not the "
                                       "home port of the respective interface. The default is "
                                       "\"Check and Display\". This feature is currently only "
                                       "supported by the check netapp_api_if."),
                                choices=[
                                    ("check_and_warn", _("Check and WARN")),
                                    ("check_and_crit", _("Check and CRIT")),
                                    ("check_and_display", _("Check and display only")),
                                    ("dont_show_and_check", _("Don't show home port info")),
                                ])),
            ],
        ),
        forth=transform_if,
    )
Пример #28
0
    def _vs_directory_options(self, ty: str) -> Dictionary:
        connect_to_choices: List[CascadingDropdownChoice] = [
            (
                "fixed_list",
                _("Manually specify list of LDAP servers"),
                Dictionary(
                    elements=[
                        (
                            "server",
                            TextInput(
                                title=_("LDAP Server"),
                                help=_(
                                    "Set the host address of the LDAP server. Might be an IP address or "
                                    "resolvable hostname."),
                                allow_empty=False,
                            ),
                        ),
                        (
                            "failover_servers",
                            ListOfStrings(
                                title=_("Failover Servers"),
                                help=
                                _("When the connection to the first server fails with connect specific errors "
                                  "like timeouts or some other network related problems, the connect mechanism "
                                  "will try to use this server instead of the server configured above. If you "
                                  "use persistent connections (default), the connection is being used until the "
                                  "LDAP is not reachable or the local webserver is restarted."
                                  ),
                                allow_empty=False,
                            ),
                        ),
                    ],
                    optional_keys=["failover_servers"],
                ),
            ),
        ]

        if ty == "ad":
            connect_to_choices.append((
                "discover",
                _("Automatically discover LDAP server"),
                Dictionary(
                    elements=[
                        (
                            "domain",
                            TextInput(
                                title=
                                _("DNS domain name to discover LDAP servers of"
                                  ),
                                help=
                                _("Configure the DNS domain name of your Active directory domain here, Check_MK "
                                  "will then query this domain for it's closest domain controller to communicate "
                                  "with."),
                                allow_empty=False,
                            ),
                        ),
                    ],
                    optional_keys=[],
                ),
            ), )

        return Dictionary(
            elements=[
                (
                    "connect_to",
                    CascadingDropdown(
                        title=_("Connect to"),
                        choices=connect_to_choices,
                    ),
                ),
            ],
            optional_keys=[],
        )
Пример #29
0
 def _render_options(cls):
     return [
         (
             "metric_render_options",
             Transform(
                 Dictionary(
                     elements=[
                         ("font_size",
                          CascadingDropdown(
                              title=_("Metric value font size"),
                              orientation="horizontal",
                              choices=[
                                  ("fix", _("Set the metric value font size to:"),
                                   Fontsize(default_value="22.5")),
                                  ("dynamic",
                                   _("Dynamically adapt the metric font size to the dashlet size"
                                    ))
                              ],
                              default_value="dynamic")),
                         ("link_to_svc_detail",
                          DropdownChoice(
                              title=_("Link to service detail page"),
                              choices=[
                                  ("true",
                                   _("Open service detail page when clicking on the metric value"
                                    )), ("false", _("Do not add a link to the metric value"))
                              ],
                              default_value="true")),
                         ("show_site",
                          CascadingDropdown(
                              title=_("Show the site name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the site name"))],
                              default_value="false")),
                         ("show_host",
                          CascadingDropdown(
                              title=_("Show the host name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the host name"))],
                              default_value="false")),
                         ("show_service",
                          CascadingDropdown(
                              title=_("Show the service name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the service name"))],
                              default_value="tooltip")),
                         ("show_metric",
                          CascadingDropdown(
                              title=_("Show the metric name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the metric name"))],
                              default_value="above")),
                         ("show_state_color",
                          DropdownChoice(title=_("Show the service state color"),
                                         choices=[
                                             ("background", _("... as background color")),
                                             ("font", _("... as font color")),
                                             ("false", _("Do not show the service state color")),
                                         ],
                                         default_value="background")),
                         ("show_unit",
                          DropdownChoice(title=_("Show the metric's unit"),
                                         choices=[
                                             ("true", _("Show the metric's unit")),
                                             ("false", _("Do not show the metric's unit")),
                                         ],
                                         default_value="true")),
                     ],
                     optional_keys=[],
                     title=_("Metric rendering options"),
                 ),),
         ),
     ]
Пример #30
0
def get_bi_aggregation_node_choices():
    return Transform(
        CascadingDropdown(choices=_get_aggregation_choices()),
        forth=_convert_bi_aggr_to_vs,
        back=_convert_bi_aggr_from_vs,
    )