Example #1
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,
    )
Example #2
0

rulespec_registry.register(
    HostRulespec(
        group=RulespecGroupCheckParametersDiscovery,
        match_type="list",
        name="inventory_if_rules",
        valuespec=_valuespec_inventory_if_rules,
    ))

vs_elements_if_groups_matches: List[DictionaryEntry] = [
    ("iftype",
     Transform(
         DropdownChoice(
             title=_("Select interface port type"),
             choices=ListChoice.dict_choices(defines.interface_port_types()),
             help=_("Only interfaces with the given port type are put into this group. "
                    "For example 53 (propVirtual)."),
         ),
         forth=str,
         back=int,
     )),
    ("items",
     ListOfStrings(
         title=_("Restrict interface items"),
         help=_("Only interface with these item names are put into this group."),
     )),
]

vs_elements_if_groups_group = [
    ("group_name",
Example #3
0
File: if.py Project: m4c3/checkMK
                       "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.'),
        )


vs_elements_if_groups_matches = [
    ("iftype",
     Transform(
         DropdownChoice(
             title=_("Select interface port type"),
             choices=defines.interface_port_types(),
             help=_(
                 "Only interfaces with the given port type are put into this group. "
                 "For example 53 (propVirtual)."),
         ),
         forth=str,
         back=int,
     )),
    ("items",
     ListOfStrings(
         title=_("Restrict interface items"),
         help=_(
             "Only interface with these item names are put into this group."),
     )),
]
Example #4
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,
    )
Example #5
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,
    )