コード例 #1
0
ファイル: datadog_monitors.py プロジェクト: gradecke/checkmk
def _valuespec_datadog_monitors_discovery() -> Dictionary:
    return Dictionary(
        [
            (
                "states_discover",
                DualListChoice(
                    title=_("Only discover monitors in the following states"),
                    choices=[
                        (
                            datadog_state,
                            datadog_state,
                        )
                        for datadog_state, _checkmk_state in _DEFAULT_DATADOG_AND_CHECKMK_STATES
                    ],
                    default_value=[
                        datadog_state
                        for datadog_state, _checkmk_state in _DEFAULT_DATADOG_AND_CHECKMK_STATES
                    ],
                    rows=len(_DEFAULT_DATADOG_AND_CHECKMK_STATES) + 2,
                    size=50,
                ),
            ),
        ],
        title=_("Discovery of Datadog monitors"),
        optional_keys=False,
    )
コード例 #2
0
 def valuespec(self):
     return DualListChoice(
         choices=defines.interface_port_types(),
         rows=4,
         enlarge_active=True,
         custom_order=True,
     )
コード例 #3
0
ファイル: groups.py プロジェクト: AllwynPradip/checkmk
 def _vs_contactgroups(self):
     if self._contactgroups is None:  # conditional caused by horrible API
         raise Exception("invalid contact groups")
     cg_choices = sorted([(cg_id, cg_attrs.get("alias", cg_id))
                          for cg_id, cg_attrs in self._contactgroups.items()],
                         key=lambda x: x[1])
     return DualListChoice(choices=cg_choices, rows=20, size=100)
コード例 #4
0
def _parameter_valuespec_mssql_blocked_sessions():
    return Dictionary(elements=[
        ("state",
         MonitoringState(
             title=_("State if at least one blocked session"),
             default_value=2,
         )),
        ("waittime",
         Tuple(
             title=_("Levels for wait"),
             help=_("The threshholds for wait_duration_ms. Will "
                    "overwrite the default state set above."),
             default_value=(0, 0),
             elements=[
                 Float(title=_("Warning at"),
                       unit=_("seconds"),
                       display_format="%.3f"),
                 Float(title=_("Critical at"),
                       unit=_("seconds"),
                       display_format="%.3f"),
             ],
         )),
        ("ignore_waittypes",
         DualListChoice(
             title=_("Ignore wait types"),
             rows=40,
             choices=[(entry, entry) for entry in mssql_waittypes],
         )),
    ], )
コード例 #5
0
def _valuespec_inv_parameters_inv_if():
    return Dictionary(
        title=_("Parameters for switch port inventory"),
        elements=[
            ("unused_duration",
             Age(
                 title=_("Port down time until considered unused"),
                 help=
                 _("After this time in the state <i>down</i> a port is considered unused."
                   ),
                 default_value=30 * 86400,
             )),
            ("usage_port_types",
             DualListChoice(
                 title=_("Port types to include in usage statistics"),
                 choices=defines.interface_port_types(),
                 autoheight=False,
                 rows=40,
                 enlarge_active=False,
                 custom_order=True,
                 default_value=[
                     '6', '32', '62', '117', '127', '128', '129', '180', '181',
                     '182', '205', '229'
                 ],
             )),
        ])
コード例 #6
0
    def _vs_individual_elements(self):
        if user.may("wato.edit_all_predefined_conditions"):
            admin_element: List[ValueSpec] = [
                FixedValue(
                    value=None,
                    title=_("Administrators"),
                    totext=_(
                        "Administrators (having the permission "
                        '"Write access to all predefined conditions")'
                    ),
                )
            ]
        else:
            admin_element = []

        return [
            ("conditions", vs_conditions()),
            (
                "owned_by",
                Alternative(
                    title=_("Editable by"),
                    help=_(
                        "Each predefined condition is owned by a group of users which are able to edit, "
                        "delete and use existing predefined conditions."
                    ),
                    elements=admin_element
                    + [
                        DropdownChoice(
                            title=_("Members of the contact group:"),
                            choices=lambda: self._contact_group_choices(only_own=True),
                            invalid_choice="complain",
                            empty_text=_(
                                "You need to be member of at least one contact group to be able to "
                                "create a predefined condition."
                            ),
                            invalid_choice_title=_("Group not existant or not member"),
                            invalid_choice_error=_(
                                "The choosen group is either not existant "
                                "anymore or you are not a member of this "
                                "group. Please choose another one."
                            ),
                        ),
                    ],
                ),
            ),
            (
                "shared_with",
                DualListChoice(
                    title=_("Share with"),
                    help=_(
                        "By default only the members of the owner contact group are permitted "
                        "to use a a predefined condition. It is possible to share it with "
                        "other groups of users to make them able to use a predefined condition in rules."
                    ),
                    choices=self._contact_group_choices,
                    autoheight=False,
                ),
            ),
        ]
コード例 #7
0
ファイル: utils.py プロジェクト: troelsarvin/checkmk
    def display(self, value: FilterHTTPVariables) -> None:
        html.open_div(class_="multigroup")
        DualListChoice(choices=self._options(self.info), rows=4, enlarge_active=True).render_input(
            self.query_filter.request_vars[0], self.query_filter.selection(value)
        )

        if self.query_filter.negateable:
            checkbox_component(self.query_filter.request_vars[1], value, _("negate"))
        html.close_div()
コード例 #8
0
ファイル: inventory.py プロジェクト: tboerger/checkmk
 def valuespec(self) -> ValueSpec:
     sorted_choices = [(str(k), str(v)) for k, v in sorted(
         defines.interface_port_types().items(), key=lambda t: t[0])]
     return DualListChoice(
         choices=sorted_choices,
         rows=4,
         enlarge_active=True,
         custom_order=True,
     )
コード例 #9
0
ファイル: diagnostics.py プロジェクト: inettgmbh/checkmk
    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
ファイル: password_store.py プロジェクト: AngusWarren/checkmk
    def _vs_individual_elements(self):
        if config.user.may("wato.edit_all_passwords"):
            admin_element: List[ValueSpec] = [
                FixedValue(
                    None,
                    title=_("Administrators"),
                    totext=_("Administrators (having the permission "
                             "\"Write access to all passwords\")"),
                )
            ]
        else:
            admin_element = []

        elements: List[DictionaryEntry] = [
            ("password", PasswordSpec(
                title=_("Password"),
                allow_empty=False,
            )),
            ("owned_by",
             Alternative(
                 title=_("Editable by"),
                 help=_(
                     "Each password is owned by a group of users which are able to edit, "
                     "delete and use existing passwords."),
                 style="dropdown",
                 elements=admin_element + [
                     DropdownChoice(
                         title=_("Members of the contact group:"),
                         choices=lambda: self._contact_group_choices(only_own=
                                                                     True),
                         invalid_choice="complain",
                         empty_text=_(
                             "You need to be member of at least one contact group to be able to "
                             "create a password."),
                         invalid_choice_title=_(
                             "Group not existant or not member"),
                         invalid_choice_error=_(
                             "The choosen group is either not existant "
                             "anymore or you are not a member of this "
                             "group. Please choose another one."),
                     ),
                 ])),
            ("shared_with",
             DualListChoice(
                 title=_("Share with"),
                 help=
                 _("By default only the members of the owner contact group are permitted "
                   "to use a a configured password. It is possible to share a password with "
                   "other groups of users to make them able to use a password in checks."
                   ),
                 choices=self._contact_group_choices,
                 autoheight=False,
             )),
        ]

        return elements
コード例 #11
0
def _vs_notify():
    dest_choices: List[CascadingDropdownChoice] = [
        ('broadcast', _('Everybody (Broadcast)')),
        ('list', _('A list of specific users'),
         DualListChoice(
             choices=sorted([(uid, u.get('alias', uid))
                             for uid, u in config.multisite_users.items()],
                            key=lambda x: x[1].lower()),
             allow_empty=False,
         )),
        #('contactgroup', _('All members of a contact group')),
        ('online', _('All online users')),
    ]

    return Dictionary(
        elements=[
            ('text',
             TextAreaUnicode(
                 title=_('Text'),
                 help=_('Insert the text to be sent to all reciepents.'),
                 allow_empty=False,
                 empty_text=_('You need to provide a text.'),
                 cols=50,
                 rows=10)),
            ('dest',
             CascadingDropdown(
                 title=_('Send notification to'),
                 help=_(
                     'You can send the notification to a list of multiple users, which '
                     'can be choosen out of these predefined filters.'),
                 choices=dest_choices,
             )),
            ('methods',
             ListChoice(
                 title=_('How to notify'),
                 allow_empty=False,
                 choices=[(k, v['title'])
                          for k, v in _notify_methods().items()],
                 default_value=['popup'],
             )),
            ('valid_till',
             Optional(
                 AbsoluteDate(include_time=True, ),
                 title=_('Automatically invalidate notification'),
                 label=_('Enable automatic invalidation at'),
                 help=
                 _('It is possible to automatically delete messages when the '
                   'configured time is reached. This makes it possible to inform '
                   'users about a scheduled event but suppress the notification '
                   'after the event has happened.'),
             )),
        ],
        validate=_validate_msg,
        optional_keys=[],
    )
コード例 #12
0
ファイル: diagnostics.py プロジェクト: superbjorn09/checkmk
    def _get_checkmk_config_files_choices(
            self) -> List[CascadingDropdownChoice]:
        sorted_checkmk_config_files = sorted(get_checkmk_config_files_map())
        checkmk_config_files = []
        global_settings = []
        host_and_folders = []

        for rel_config_file in sorted_checkmk_config_files:
            checkmk_config_files.append(rel_config_file)

            rel_config_file_path = Path(rel_config_file)
            rel_config_file_name = rel_config_file_path.name
            rel_config_file_parts = rel_config_file_path.parts

            if (rel_config_file_name == "sites.mk" or
                (rel_config_file_name == "global.mk" and rel_config_file_parts
                 and rel_config_file_parts[0] == "conf.d")):
                global_settings.append(rel_config_file)

            if rel_config_file_name in [
                    "hosts.mk", "tags.mk", "rules.mk", ".wato"
            ]:
                host_and_folders.append(rel_config_file)

        return [
            ("all", _("Pack all files"),
             FixedValue(
                 checkmk_config_files,
                 totext=self._list_of_files_to_text(checkmk_config_files),
             )),
            ("global_settings", _("Only global settings"),
             FixedValue(
                 global_settings,
                 totext=self._list_of_files_to_text(global_settings),
             )),
            ("hosts_and_folders", _("Only hosts and folders"),
             FixedValue(
                 host_and_folders,
                 totext=self._list_of_files_to_text(host_and_folders),
             )),
            ("explicit_list_of_files", _("Explicit list of files"),
             DualListChoice(
                 choices=[(rel_filepath, rel_filepath)
                          for rel_filepath in sorted_checkmk_config_files],
                 size=80,
                 rows=20,
             )),
        ]
コード例 #13
0
ファイル: users.py プロジェクト: majma24/checkmk
 def _vs_sites(self):
     return Alternative(
         title=_("Authorized sites"),
         help=_("The sites the user is authorized to see in the GUI."),
         default_value=None,
         elements=[
             FixedValue(
                 None,
                 title=_("All sites"),
                 totext=_("May see all sites"),
             ),
             DualListChoice(
                 title=_("Specific sites"),
                 choices=config.site_choices,
             ),
         ],
     )
コード例 #14
0
def _valuespec_inventory_fujitsu_ca_ports():
    return Dictionary(
        title=_("Discovery of Fujtsu storage CA ports"),
        elements=[
            ("indices", ListOfStrings(title=_("CA port indices"))),
            ("modes",
             DualListChoice(
                 title=_("CA port modes"),
                 choices=[
                     ("CA", _("CA")),
                     ("RA", _("RA")),
                     ("CARA", _("CARA")),
                     ("Initiator", _("Initiator")),
                 ],
                 rows=4,
                 size=30,
             )),
        ],
    )
コード例 #15
0
ファイル: groups.py プロジェクト: n00rm/checkmk
 def _vs_contactgroups(self):
     cg_choices = sorted(
         [(cg_id, cg_attrs.get("alias", cg_id))
          for cg_id, cg_attrs in self._contactgroups.items()],
         key=lambda x: x[1])
     return DualListChoice(choices=cg_choices, rows=20, size=100)
コード例 #16
0
ファイル: if.py プロジェクト: tboerger/checkmk
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,
    )
コード例 #17
0
def _valuespec_inventory_if_rules():
    return Transform(
        Dictionary(
            title=_("Network Interface and Switch Port Discovery"),
            elements=[
                ('item_appearance',
                 DropdownChoice(
                     title=_("Appearance of network interface"),
                     help=
                     _("This option lets Check_MK use either the interface description, alias or "
                       " port number as item. The port number is the fallback/default."
                       "used anyway."),
                     choices=[
                         ('descr', _('Use description')),
                         ('alias', _('Use alias')),
                         ('index', _('Use index')),
                     ],
                     default_value='index',
                 )),
                ("pad_portnumbers",
                 DropdownChoice(
                     choices=[
                         (True, _('Pad port numbers with zeros')),
                         (False, _('Do not pad')),
                     ],
                     title=_("Port numbers"),
                     help=
                     _("If this option is activated then Check_MK will pad port numbers of "
                       "network interfaces with zeroes so that all port descriptions from "
                       "all ports of a host or switch have the same length and thus sort "
                       "currectly in the GUI. In versions prior to 1.1.13i3 there was no "
                       "padding. You can switch back to the old behaviour by disabling this "
                       "option. This will retain the old service descriptions and the old "
                       "performance data."),
                 )),
                ("match_alias",
                 ListOfStrings(
                     title=_("Match interface alias (regex)"),
                     help=
                     _("Only discover interfaces whose alias matches one of the configured "
                       "regular expressions. The match is done on the beginning of the alias. "
                       "This allows you to select interfaces based on the alias without having "
                       "the alias be part of the service description."),
                     orientation="horizontal",
                     valuespec=RegExp(
                         size=32,
                         mode=RegExp.prefix,
                     ),
                 )),
                ("match_desc",
                 ListOfStrings(
                     title=_("Match interface description (regex)"),
                     help=
                     _("Only discover interfaces whose the description matches one of the configured "
                       "regular expressions. The match is done on the beginning of the description. "
                       "This allows you to select interfaces based on the description without having "
                       "the alias be part of the service description."),
                     orientation="horizontal",
                     valuespec=RegExp(
                         size=32,
                         mode=RegExp.prefix,
                     ),
                 )),
                ("portstates",
                 ListChoice(
                     title=_("Network interface port states to discover"),
                     help=
                     _("When doing discovery on switches or other devices with network interfaces "
                       "then only ports found in one of the configured port states will be added to the monitoring. "
                       "Note: the state <i>admin down</i> is in fact not an <tt>ifOperStatus</tt> but represents the "
                       "<tt>ifAdminStatus</tt> of <tt>down</tt> - a port administratively switched off. If you check this option "
                       "then an alternate version of the check is being used that fetches the <tt>ifAdminState</tt> in addition. "
                       "This will add about 5% of additional SNMP traffic."),
                     choices=defines.interface_oper_states(),
                     toggle_all=True,
                     default_value=['1'],
                 )),
                ("porttypes",
                 DualListChoice(
                     title=_("Network interface port types to discover"),
                     help=
                     _("When doing discovery on switches or other devices with network interfaces "
                       "then only ports of the specified types will be created services for."
                       ),
                     choices=defines.interface_port_types(),
                     rows=40,
                     default_value=[
                         '6', '32', '62', '117', '127', '128', '129', '180',
                         '181', '182', '205', '229'
                     ],
                 )),
                ("rmon",
                 DropdownChoice(
                     choices=[
                         (True,
                          _("Create extra service with RMON statistics data (if available for the device)"
                            )),
                         (False, _('Do not create extra services')),
                     ],
                     title=_("Collect RMON statistics data"),
                     help=
                     _("If you enable this option, for every RMON capable switch port an additional service will "
                       "be created which is always OK and collects RMON data. This will give you detailed information "
                       "about the distribution of packet sizes transferred over the port. Note: currently "
                       "this extra RMON check does not honor the inventory settings for switch ports. In a future "
                       "version of Check_MK RMON data may be added to the normal interface service and not add "
                       "an additional service."),
                 )),
            ],
            help=
            _('This rule can be used to control the inventory for network ports. '
              'You can configure the port types and port states for inventory '
              'and the use of alias or description as service name.'),
        ),
        forth=_transform_discovery_if_rules,
    )
コード例 #18
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. Note: the state <i>admin down</i> is in fact not a port "
                              "state but represents an <tt>ifAdminStatus</tt> (SNMP only) of "
                              "<tt>down</tt> - a port administratively switched off. If you check "
                              "this option, <tt>ifAdminState</tt> will be fetched in addition, "
                              "adding approximately 5% of additional SNMP traffic."
                              ),
                            choices=defines.interface_oper_states(),
                            toggle_all=True,
                            default_value=['1'],
                        ),
                    ),
                    (
                        "match_index",
                        _vs_regex_matching("index"),
                    ),
                    (
                        "match_alias",
                        _vs_regex_matching("alias"),
                    ),
                    (
                        "match_desc",
                        _vs_regex_matching("description"),
                    ),
                ], ),
            ),
        ],
        sorted=False,
    )
コード例 #19
0
ファイル: notify.py プロジェクト: PLUTEX/checkmk
def _vs_notify():
    dest_choices: List[CascadingDropdownChoice] = [
        ("broadcast", _("Everybody (Broadcast)")),
        (
            "list",
            _("A list of specific users"),
            DualListChoice(
                choices=sorted(
                    [(uid, u.get("alias", uid)) for uid, u in config.multisite_users.items()],
                    key=lambda x: x[1].lower(),
                ),
                allow_empty=False,
            ),
        ),
        # ('contactgroup', _('All members of a contact group')),
        ("online", _("All online users")),
    ]

    return Dictionary(
        elements=[
            (
                "text",
                TextAreaUnicode(
                    title=_("Text"),
                    help=_("Insert the text to be sent to all reciepents."),
                    allow_empty=False,
                    empty_text=_("You need to provide a text."),
                    cols=50,
                    rows=10,
                ),
            ),
            (
                "dest",
                CascadingDropdown(
                    title=_("Send notification to"),
                    help=_(
                        "You can send the notification to a list of multiple users, which "
                        "can be choosen out of these predefined filters."
                    ),
                    choices=dest_choices,
                ),
            ),
            (
                "methods",
                ListChoice(
                    title=_("How to notify"),
                    allow_empty=False,
                    choices=[(k, v["title"]) for k, v in _notify_methods().items()],
                    default_value=["popup"],
                ),
            ),
            (
                "valid_till",
                Optional(
                    AbsoluteDate(
                        include_time=True,
                    ),
                    title=_("Automatically invalidate notification"),
                    label=_("Enable automatic invalidation at"),
                    help=_(
                        "It is possible to automatically delete messages when the "
                        "configured time is reached. This makes it possible to inform "
                        "users about a scheduled event but suppress the notification "
                        "after the event has happened."
                    ),
                ),
            ),
        ],
        validate=_validate_msg,
        optional_keys=[],
    )
コード例 #20
0
ファイル: wato.py プロジェクト: m3rlinux/checkmk
 def valuespec(self):
     # Drop Main directory represented by empty string, because it means
     # don't filter after any folder due to recursive folder filtering.
     choices = [(name, folder) for name, folder in self.choices() if name]
     return DualListChoice(choices=choices, rows=4, enlarge_active=True)