Exemplo n.º 1
0
def _valuespec_diskstat_inventory():
    return ListChoice(
        title=_("Discovery mode for Disk IO check"),
        help=_("This rule controls which and how many checks will be created "
               "for monitoring individual physical and logical disks. "
               "Note: the option <i>Create a summary for all read, one for "
               "write</i> has been removed. Some checks will still support "
               "this settings, but it will be removed there soon."),
        choices=[
            ("summary", _("Create a summary over all physical disks")),
            # This option is still supported by some checks, but is deprecated and
            # we fade it out...
            # ( "legacy",   _("Create a summary for all read, one for write") ),
            ("physical", _("Create a separate check for each physical disk")),
            ("lvm", _("Create a separate check for each LVM volume (Linux)")),
            ("vxvm",
             _("Creata a separate check for each VxVM volume (Linux)")),
            ("diskless",
             _("Creata a separate check for each partition (XEN)")),
        ],
        default_value=['summary'],
    )
Exemplo n.º 2
0
def hr_process_match_elements():
    return [
        ('match_name_or_path',
         CascadingDropdown(
             title=_('Process Match textual description or path of process'),
             choices=[
                 ('match_name', _("Match textual description"),
                  hr_process_match_name_option()),
                 ('match_path', _("Match process path"),
                  hr_process_match_path_option()),
                 ('match_all', _("Match all processes")),
             ])),
        ('match_status',
         ListChoice(title=_('Process Status Matching'),
                    choices=[
                        ('running', _('Running')),
                        ('runnable', _('Runnable (Waiting for resource)')),
                        ('not_runnable',
                         _('Not runnable (Loaded but waiting for event)')),
                        ('invalid', _('Invalid (Not loaded)')),
                    ])),
    ]
Exemplo n.º 3
0
 def valuespec(self):
     return Optional(
         valuespec=ListChoice(
             choices=[
                 ("SNMPTRAP", _("Receive SNMP traps (UDP/162)")),
                 ("SYSLOG", _("Receive Syslog messages (UDP/514)")),
                 ("SYSLOG_TCP", _("Receive Syslog messages (TCP/514)")),
             ],
             title=_("Listen for incoming messages via"),
             empty_text=_("Locally enabled"),
         ),
         title=_("Event Console"),
         help=
         _("This option enables the Event Console - The event processing and "
           "classification daemon of Check_MK. You can also configure whether "
           "or not the Event Console shal listen for incoming SNMP traps or "
           "syslog messages. Please note that only a single Check_MK site per "
           "Check_MK server can listen for such messages."),
         label=_("Event Console enabled"),
         none_label=_("Event Console disabled"),
         indent=False,
     )
Exemplo n.º 4
0
 def parameter_valuespec(self):
     return Dictionary(elements=[
         ("error_states",
          ListChoice(
              title=_("Modem States that lead to a critical state"),
              help=
              _("If one of the selected states occurs the check will repsond with a critical state "
                ),
              choices=[
                  (1, "other"),
                  (2, "notReady"),
                  (3, "notSynchronized"),
                  (4, "phySynchronized"),
                  (5, "usParametersAcquired"),
                  (6, "rangingComplete"),
                  (7, "ipComplete"),
                  (8, "todEstablished"),
                  (9, "securityEstablished"),
                  (10, "paramTransferComplete"),
                  (11, "registrationComplete"),
                  (12, "operational"),
                  (13, "accessDenied"),
              ],
              default_value=[1, 2, 13],
          )),
         ("tx_power",
          Tuple(
              title=_("Transmit Power"),
              help=_("The operational transmit power"),
              elements=[
                  Float(title=_("warning at"),
                        unit="dBmV",
                        default_value=20.0),
                  Float(title=_("critical at"),
                        unit="dBmV",
                        default_value=10.0),
              ],
          )),
     ], )
Exemplo n.º 5
0
def _valuespec_special_agents_gcp():
    return Dictionary(
        title=_("Google Cloud Platform"),
        elements=[
            ("project",
             TextInput(title=_("Project ID"), allow_empty=False, size=50)),
            (
                "credentials",
                IndividualOrStoredPassword(
                    title=_("JSON credentials for service account"),
                    allow_empty=False),
            ),
            (
                "services",
                ListChoice(
                    title=_("GCP services to monitor"),
                    choices=[
                        ("gcs", _("Google Cloud Storage (GCS)")),
                        ("cloud_run", _("Cloud Run")),
                        ("cloud_functions", _("Cloud Functions")),
                        ("cloud_sql", _("Cloud SQL")),
                        ("filestore", _("Filestore")),
                        ("redis", _("Memorystore Redis")),
                    ],
                    default_value=[
                        "gcs",
                        "cloud_run",
                        "cloud_functions",
                        "cloud_sql",
                        "filestore",
                        "redis",
                    ],
                    allow_empty=False,
                ),
            ),
        ],
        optional_keys=[],
    )
Exemplo n.º 6
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,
    )
Exemplo n.º 7
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",
Exemplo n.º 8
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,
    )
Exemplo n.º 9
0
def _parameter_valuespec_windows_printer_queues():
    return Transform(
        Dictionary(
            title=_("Windows Printer Configuration"),
            elements=[
                (
                    "levels",
                    Tuple(
                        title=_("Levels for the number of print jobs"),
                        help=_(
                            "This rule is applied to the number of print jobs "
                            "currently waiting in windows printer queue."
                        ),
                        elements=[
                            Integer(title=_("Warning at"), unit=_("jobs"), default_value=40),
                            Integer(title=_("Critical at"), unit=_("jobs"), default_value=60),
                        ],
                    ),
                ),
                (
                    "crit_states",
                    ListChoice(
                        title=_("States who should lead to critical"),
                        choices=[
                            (0, "Unkown"),
                            (1, "Other"),
                            (2, "No Error"),
                            (3, "Low Paper"),
                            (4, "No Paper"),
                            (5, "Low Toner"),
                            (6, "No Toner"),
                            (7, "Door Open"),
                            (8, "Jammed"),
                            (9, "Offline"),
                            (10, "Service Requested"),
                            (11, "Output Bin Full"),
                        ],
                        default_value=[9, 10],
                    ),
                ),
                (
                    "warn_states",
                    ListChoice(
                        title=_("States who should lead to warning"),
                        choices=[
                            (0, "Unkown"),
                            (1, "Other"),
                            (2, "No Error"),
                            (3, "Low Paper"),
                            (4, "No Paper"),
                            (5, "Low Toner"),
                            (6, "No Toner"),
                            (7, "Door Open"),
                            (8, "Jammed"),
                            (9, "Offline"),
                            (10, "Service Requested"),
                            (11, "Output Bin Full"),
                        ],
                        default_value=[8, 11],
                    ),
                ),
            ],
        ),
        forth=windows_printer_queues_forth,
    )
Exemplo n.º 10
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"),
                ),
            ),
        ])
Exemplo n.º 11
0
def _valuespec_inventory_df_rules():
    return Transform(
        valuespec=Dictionary(
            title=_("Filesystem discovery"),
            elements=[
                (
                    "mountpoint_for_block_devices",
                    DropdownChoice(
                        title=_("Mountpoint for block devices (brtfs)"),
                        choices=[
                            ("volume_name_as_mountpoint",
                             _("Use volume name as mountpoint")),
                            ("uuid_as_mountpoint",
                             _("Use UUID as mountpoint")),
                        ],
                        default_value="volume_name_as_mountpoint",
                    ),
                ),
                (
                    "item_appearance",
                    DropdownChoice(
                        title=_("Item appearance"),
                        choices=[
                            ("mountpoint", _("Use mountpoint")),
                            ("volume_name_and_mountpoint",
                             _("Use volume name and mountpoint")),
                            ("uuid_and_mountpoint",
                             _("Use UUID and mountpoint")),
                        ],
                        default_value="mountpoint",
                    ),
                ),
                (
                    "grouping_behaviour",
                    DropdownChoice(
                        title=_("Grouping applies to"),
                        choices=[
                            ("mountpoint", _("mountpoint only")),
                            ("volume_name_and_mountpoint",
                             _("volume name and mountpoint")),
                            ("uuid_and_mountpoint", _("UUID and mountpoint")),
                        ],
                        help=_(
                            "Specifies how the <a href='wato.py?mode=edit_ruleset&varname=filesystem_groups'>Filesystem grouping patterns</a>"
                            " feature processes this filesystem."),
                        default_value="mountpoint",
                    ),
                ),
                (
                    "ignore_fs_types",
                    ListChoice(
                        title=_("Filesystem types to ignore"),
                        choices=[
                            ("tmpfs", "tmpfs"),
                            ("nfs", "nfs"),
                            ("smbfs", "smbfs"),
                            ("cifs", "cifs"),
                            ("iso9660", "iso9660"),
                        ],
                        default_value=[
                            "tmpfs", "nfs", "smbfs", "cifs", "iso9660"
                        ],
                    ),
                ),
                (
                    "never_ignore_mountpoints",
                    ListOf(
                        valuespec=TextOrRegExp(),
                        title=_("Mountpoints to never ignore"),
                        help=_(
                            "Regardless of filesystem type, these mountpoints will always be discovered."
                            "Regular expressions are supported."),
                    ),
                ),
            ],
            validate=_validate_discovery_filesystem_params,
        ),
        forth=_transform_discovery_filesystem_params,
    )
Exemplo n.º 12
0
def _werk_table_option_entries():
    translator = cmk.utils.werks.WerkTranslator()
    return [
        (
            "classes",
            "double",
            ListChoice(
                title=_("Classes"),
                choices=sorted(translator.classes()),
            ),
            ["feature", "fix", "security"],
        ),
        (
            "levels",
            "double",
            ListChoice(
                title=_("Levels"),
                choices=sorted(translator.levels()),
            ),
            [1, 2, 3],
        ),
        ("date", "double", Timerange(title=_("Date")), ("date", (1383149313, int(time.time())))),
        (
            "id",
            "single",
            TextInput(
                title=_("Werk ID"),
                label="#",
                regex="^[0-9]{1,5}$",
                size=7,
            ),
            "",
        ),
        (
            "compatibility",
            "single",
            DropdownChoice(
                title=_("Compatibility"),
                choices=[
                    (
                        ["compat", "incomp_ack", "incomp_unack"],
                        _("Compatible and incompatible Werks"),
                    ),
                    (["compat"], _("Compatible Werks")),
                    (["incomp_ack", "incomp_unack"], _("Incompatible Werks")),
                    (["incomp_unack"], _("Unacknowledged incompatible Werks")),
                    (["incomp_ack"], _("Acknowledged incompatible Werks")),
                ],
            ),
            ["compat", "incomp_ack", "incomp_unack"],
        ),
        (
            "component",
            "single",
            DropdownChoice(
                title=_("Component"),
                choices=[
                    (None, _("All components")),
                ]
                + sorted(translator.components()),
            ),
            None,
        ),
        (
            "edition",
            "single",
            DropdownChoice(
                title=_("Edition"),
                choices=[
                    (None, _("All editions")),
                    *(
                        (e.short, _("Werks only concerning the %s") % e.title)
                        for e in (Edition.CPE, Edition.CME, Edition.CEE, Edition.CRE)
                    ),
                ],
            ),
            None,
        ),
        (
            "werk_content",
            "single",
            TextInput(
                title=_("Werk title or content"),
                size=41,
            ),
            "",
        ),
        (
            "version",
            "single",
            Tuple(
                title=_("Checkmk Version"),
                orientation="float",
                elements=[
                    TextInput(label=_("from:"), size=12),
                    TextInput(label=_("to:"), size=12),
                ],
            ),
            (Version(__version__).version_base, ""),
        ),
        (
            "grouping",
            "single",
            DropdownChoice(
                title=_("Group Werks by"),
                choices=[
                    ("version", _("Checkmk Version")),
                    ("day", _("Day of creation")),
                    ("week", _("Week of creation")),
                    (None, _("Do not group")),
                ],
            ),
            "version",
        ),
        (
            "group_limit",
            "single",
            Integer(
                title=_("Show number of groups"),
                unit=_("groups"),
                minvalue=1,
            ),
            50,
        ),
    ]
Exemplo n.º 13
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(
             CascadingDropdown(
                 title=_("Title format"),
                 orientation="vertical",
                 choices=[
                     ("plain", _("Just show graph title")),
                     ("add_title_infos", _("Add additional information"),
                      ListChoice(choices=[
                          ("add_host_name", _("Add host name")),
                          ("add_host_alias", _("Add host alias")),
                          ("add_service_description",
                           _("Add service description")),
                      ])),
                 ],
             ),
             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
Exemplo n.º 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. 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,
    )
Exemplo n.º 15
0
def _valuespec_special_agents_jenkins():
    return Transform(
        valuespec=Dictionary(
            title=_("Jenkins jobs and builds"),
            help=_("Requests data from a jenkins instance."),
            optional_keys=["port"],
            elements=[
                (
                    "instance",
                    TextInput(
                        title=_("Jenkins instance to query."),
                        help=_(
                            "Use this option to set which instance should be "
                            "checked by the special agent. Please add the "
                            "hostname here, eg. my_jenkins.com."),
                        size=32,
                        allow_empty=False,
                    ),
                ),
                (
                    "user",
                    TextInput(
                        title=_("Username"),
                        help=
                        _("The username that should be used for accessing the "
                          "jenkins API. Has to have read permissions at least."
                          ),
                        size=32,
                        allow_empty=False,
                    ),
                ),
                (
                    "password",
                    PasswordFromStore(
                        help=_("The password or API key of the user."),
                        title=_("Password of the user"),
                        allow_empty=False,
                    ),
                ),
                (
                    "protocol",
                    DropdownChoice(
                        title=_("Protocol"),
                        choices=[
                            ("http", "HTTP"),
                            ("https", "HTTPS"),
                        ],
                        default_value="https",
                    ),
                ),
                (
                    "port",
                    Integer(
                        title=_("Port"),
                        help=
                        _("Use this option to query a port which is different from standard port 8080."
                          ),
                        default_value=443,
                    ),
                ),
                (
                    "sections",
                    ListChoice(
                        title=_("Informations to query"),
                        help=
                        _("Defines what information to query. You can choose "
                          "between the instance state, job states, node states "
                          "and the job queue."),
                        choices=[
                            ("instance", _("Instance state")),
                            ("jobs", _("Job state")),
                            ("nodes", _("Node state")),
                            ("queue", _("Queue info")),
                        ],
                        default_value=["instance", "jobs", "nodes", "queue"],
                        allow_empty=False,
                    ),
                ),
            ],
        ),
        forth=_transform_jenkins_infos,
    )
Exemplo n.º 16
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"),
    )
Exemplo n.º 17
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,
    )
Exemplo n.º 18
0
def _valuespec_special_agents_ibmsvc():
    return Dictionary(
        title=_("IBM SVC / V7000 storage systems"),
        help=
        _("This rule set selects the <tt>ibmsvc</tt> agent instead of the normal Check_MK Agent "
          "and allows monitoring of IBM SVC / V7000 storage systems by calling "
          "ls* commands there over SSH. "
          "Make sure you have SSH key authentication enabled for your monitoring user. "
          "That means: The user your monitoring is running under on the monitoring "
          "system must be able to ssh to the storage system as the user you gave below "
          "without password."),
        elements=[
            (
                "user",
                TextInput(
                    title=_("IBM SVC / V7000 user name"),
                    allow_empty=True,
                    help=
                    _("User name on the storage system. Read only permissions are sufficient."
                      ),
                ),
            ),
            (
                "accept-any-hostkey",
                Checkbox(
                    title=_("Accept any SSH Host Key"),
                    label=_("Accept any SSH Host Key"),
                    default_value=False,
                    help=
                    _("Accepts any SSH Host Key presented by the storage device. "
                      "Please note: This might be a security issue because man-in-the-middle "
                      "attacks are not recognized! Better solution would be to add the "
                      "SSH Host Key of the monitored storage devices to the .ssh/known_hosts "
                      "file for the user your monitoring is running under (on OMD: the site user)"
                      ),
                ),
            ),
            (
                "infos",
                Transform(
                    valuespec=ListChoice(
                        choices=[
                            ("lshost", _("Hosts Connected")),
                            ("lslicense", _("Licensing Status")),
                            ("lsmdisk", _("MDisks")),
                            ("lsmdiskgrp", _("MDisksGrps")),
                            ("lsnode", _("IO Groups")),
                            ("lsnodestats", _("Node Stats")),
                            ("lssystem", _("System Info")),
                            ("lssystemstats", _("System Stats")),
                            ("lseventlog", _("Event Log")),
                            ("lsportfc", _("FC Ports")),
                            ("lsportsas", _("SAS Ports")),
                            ("lsenclosure", _("Enclosures")),
                            ("lsenclosurestats", _("Enclosure Stats")),
                            ("lsarray", _("RAID Arrays")),
                            ("disks", _("Physical Disks")),
                        ],
                        default_value=[
                            "lshost",
                            "lslicense",
                            "lsmdisk",
                            "lsmdiskgrp",
                            "lsnode",
                            "lsnodestats",
                            "lssystem",
                            "lssystemstats",
                            "lsportfc",
                            "lsenclosure",
                            "lsenclosurestats",
                            "lsarray",
                            "disks",
                        ],
                        allow_empty=False,
                    ),
                    title=_("Retrieve information about..."),
                ),
            ),
        ],
        optional_keys=[],
    )
Exemplo n.º 19
0
def _werk_table_option_entries():
    translator = cmk.utils.werks.WerkTranslator()
    return [
        ("classes", "double",
         ListChoice(
             title=_("Classes"),
             choices=sorted(translator.classes()),
         ), ["feature", "fix", "security"]),
        ("levels", "double",
         ListChoice(
             title=_("Levels"),
             choices=sorted(translator.levels()),
         ), [1, 2, 3]),
        ("date", "double", Timerange(title=_("Date")),
         ('date', (1383149313, int(time.time())))),
        ("id", "single",
         TextAscii(
             title=_("Werk ID"),
             label="#",
             regex="^[0-9]{1,5}$",
             size=7,
         ), ""),
        ("compatibility", "single",
         DropdownChoice(title=_("Compatibility"),
                        choices=[
                            (["compat", "incomp_ack", "incomp_unack"],
                             _("Compatible and incompatible Werks")),
                            (["compat"], _("Compatible Werks")),
                            (["incomp_ack",
                              "incomp_unack"], _("Incompatible Werks")),
                            (["incomp_unack"],
                             _("Unacknowledged incompatible Werks")),
                            (["incomp_ack"],
                             _("Acknowledged incompatible Werks")),
                        ]), ["compat", "incomp_ack", "incomp_unack"]),
        ("component", "single",
         DropdownChoice(
             title=_("Component"),
             choices=[
                 (None, _("All components")),
             ] + sorted(translator.components()),
         ), None),
        ("edition", "single",
         DropdownChoice(
             title=_("Edition"),
             choices=[
                 (None, _("All editions")),
                 ("cme",
                  _("Werks only concerning the Managed Services Edition")),
                 ("cee", _("Werks only concerning the Enterprise Edition")),
                 ("cre", _("Werks also concerning the Raw Edition")),
             ],
         ), None),
        ("werk_content", "single",
         TextUnicode(
             title=_("Werk title or content"),
             size=41,
         ), ""),
        ("version", "single",
         Tuple(title=_("Checkmk Version"),
               orientation="float",
               elements=[
                   TextAscii(label=_("from:"), size=12),
                   TextAscii(label=_("to:"), size=12),
               ]), ("", "")),
        ("grouping", "single",
         DropdownChoice(
             title=_("Group Werks by"),
             choices=[
                 ("version", _("Checkmk Version")),
                 ("day", _("Day of creation")),
                 ("week", _("Week of creation")),
                 (None, _("Do not group")),
             ],
         ), "version"),
        ("group_limit", "single",
         Integer(
             title=_("Show number of groups"),
             unit=_("groups"),
             minvalue=1,
         ), 20),
    ]
Exemplo n.º 20
0
def _valuespec_special_agents_vsphere():
    return Transform(
        valuespec=Dictionary(
            title=_("VMWare ESX via vSphere"),
            help=_(
                "This rule allows monitoring of VMWare ESX via the vSphere API. "
                "You can configure your connection settings here.", ),
            elements=[
                (
                    "user",
                    TextInput(
                        title=_("vSphere User name"),
                        allow_empty=False,
                    ),
                ),
                (
                    "secret",
                    IndividualOrStoredPassword(
                        title=_("vSphere secret"),
                        allow_empty=False,
                    ),
                ),
                (
                    "direct",
                    DropdownChoice(
                        title=_("Type of query"),
                        choices=[
                            (True, _("Queried host is a host system")),
                            (False, _("Queried host is the vCenter")),
                        ],
                    ),
                ),
                (
                    "tcp_port",
                    Integer(
                        title=_("TCP Port number"),
                        help=_("Port number for HTTPS connection to vSphere"),
                        default_value=443,
                        minvalue=1,
                        maxvalue=65535,
                    ),
                ),
                (
                    "ssl",
                    Alternative(
                        title=_("SSL certificate checking"),
                        elements=[
                            FixedValue(value=False,
                                       title=_("Deactivated"),
                                       totext=""),
                            FixedValue(value=True,
                                       title=_("Use hostname"),
                                       totext=""),
                            TextInput(
                                title=_("Use other hostname"),
                                help=
                                _("The IP of the other hostname needs to be the same IP as the host address"
                                  ),
                            ),
                        ],
                        default_value=True,
                    ),
                ),
                (
                    "timeout",
                    Integer(
                        title=_("Connect Timeout"),
                        help=
                        _("The network timeout in seconds when communicating with vSphere or "
                          "to the Check_MK Agent. The default is 60 seconds. Please note that this "
                          "is not a total timeout but is applied to each individual network transation."
                          ),
                        default_value=60,
                        minvalue=1,
                        unit=_("seconds"),
                    ),
                ),
                (
                    "infos",
                    Transform(
                        valuespec=ListChoice(
                            choices=[
                                ("hostsystem", _("Host Systems")),
                                ("virtualmachine", _("Virtual Machines")),
                                ("datastore", _("Datastores")),
                                ("counters", _("Performance Counters")),
                                ("licenses", _("License Usage")),
                            ],
                            default_value=[
                                "hostsystem", "virtualmachine", "datastore",
                                "counters"
                            ],
                            allow_empty=False,
                        ),
                        forth=lambda v:
                        [x.replace("storage", "datastore") for x in v],
                        title=_("Retrieve information about..."),
                    ),
                ),
                (
                    "skip_placeholder_vms",
                    Checkbox(
                        title=_("Placeholder VMs"),
                        label=_("Do not monitor placeholder VMs"),
                        default_value=True,
                        true_label=_("ignore"),
                        false_label=_("monitor"),
                        help=
                        _("Placeholder VMs are created by the Site Recovery Manager(SRM) and act as backup "
                          "virtual machines in case the default vm is unable to start. This option tells the "
                          "vsphere agent to exclude placeholder vms in its output."
                          ),
                    ),
                ),
                (
                    "host_pwr_display",
                    DropdownChoice(
                        title=_("Display ESX Host power state on"),
                        choices=[
                            (None,
                             _("The queried ESX system (vCenter / Host)")),
                            ("esxhost", _("The ESX Host")),
                            ("vm", _("The Virtual Machine")),
                        ],
                        default_value=None,
                    ),
                ),
                (
                    "vm_pwr_display",
                    DropdownChoice(
                        title=_(
                            "Display VM power state <i>additionally</i> on"),
                        help=
                        _("The power state can be displayed additionally either "
                          "on the ESX host or the VM. This will result in services "
                          "for <i>both</i> the queried system and the ESX host / VM. "
                          "By disabling the unwanted services it is then possible "
                          "to configure where the services are displayed."),
                        choices=[
                            (None,
                             _("The queried ESX system (vCenter / Host)")),
                            ("esxhost", _("The ESX Host")),
                            ("vm", _("The Virtual Machine")),
                        ],
                        default_value=None,
                    ),
                ),
                (
                    "snapshots_on_host",
                    Checkbox(
                        title=_("VM snapshot summary"),
                        label=_("Display snapshot summary on ESX hosts"),
                        default_value=False,
                        help=
                        _("By default the snapshot summary service is displayed on the vCenter. "
                          "Users who run an ESX host on its own or do not include their vCenter in the "
                          "monitoring can choose to display the snapshot summary on the ESX host itself."
                          ),
                    ),
                ),
                (
                    "vm_piggyname",
                    DropdownChoice(
                        title=_("Piggyback name of virtual machines"),
                        choices=[
                            ("alias",
                             _("Use the name specified in the ESX system")),
                            (
                                "hostname",
                                _("Use the VMs hostname if set, otherwise fall back to ESX name"
                                  ),
                            ),
                        ],
                        default_value="alias",
                    ),
                ),
                (
                    "spaces",
                    DropdownChoice(
                        title=_("Spaces in hostnames"),
                        choices=[
                            ("cut", _("Cut everything after first space")),
                            ("underscore", _("Replace with underscores")),
                        ],
                        default_value="underscore",
                    ),
                ),
            ],
            optional_keys=[
                "tcp_port",
                "timeout",
                "vm_pwr_display",
                "host_pwr_display",
                "vm_piggyname",
            ],
            ignored_keys=["use_pysphere"],
        ),
        forth=_transform_agent_vsphere,
    )
Exemplo n.º 21
0
Arquivo: if.py Projeto: 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,
     )
Exemplo n.º 22
0
def _valuespec_brocade_fcport_inventory():
    return Dictionary(
        title=_("Brocade port discovery"),
        elements=[
            (
                "use_portname",
                Checkbox(
                    title=_("Use port name as service name"),
                    label=_("use port name"),
                    default_value=True,
                    help=
                    _("This option lets Check_MK use the port name as item instead of the "
                      "port number. If no description is available then the port number is "
                      "used anyway."),
                ),
            ),
            (
                "show_isl",
                Checkbox(
                    title=_(
                        'add "ISL" to service description for interswitch links'
                    ),
                    label=_("add ISL"),
                    default_value=True,
                    help=_(
                        'This option lets Check_MK add the string "ISL" to the service '
                        "description for interswitch links."),
                ),
            ),
            (
                "admstates",
                ListChoice(
                    title=_("Administrative port states to discover"),
                    help=_(
                        "When doing service discovery on brocade switches only ports with the given administrative "
                        "states will be added to the monitoring system."),
                    choices=_brocade_fcport_adm_choices,
                    columns=1,
                    toggle_all=True,
                    default_value=["1", "3", "4"],
                ),
            ),
            (
                "phystates",
                ListChoice(
                    title=_("Physical port states to discover"),
                    help=_(
                        "When doing service discovery on brocade switches only ports with the given physical "
                        "states will be added to the monitoring system."),
                    choices=_brocade_fcport_phy_choices,
                    columns=1,
                    toggle_all=True,
                    default_value=[3, 4, 5, 6, 7, 8, 9, 10],
                ),
            ),
            (
                "opstates",
                ListChoice(
                    title=_("Operational port states to discover"),
                    help=_(
                        "When doing service discovery on brocade switches only ports with the given operational "
                        "states will be added to the monitoring system."),
                    choices=_brocade_fcport_op_choices,
                    columns=1,
                    toggle_all=True,
                    default_value=[1, 2, 3, 4],
                ),
            ),
        ],
        help=_(
            "This rule can be used to control the service discovery for brocade ports. "
            "You can configure the port states for inventory "
            "and the use of the description as service name."),
    )
Exemplo n.º 23
0
def _parameter_valuespec_netapp_volumes():
    return Dictionary(elements=[
        ("levels",
         Alternative(
             title=_("Levels for volume"),
             show_alternative_title=True,
             default_value=(80.0, 90.0),
             match=match_dual_level_type,
             elements=[
                 get_free_used_dynamic_valuespec("used", "volume"),
                 Transform(
                     get_free_used_dynamic_valuespec("free",
                                                     "volume",
                                                     default_value=(20.0,
                                                                    10.0)),
                     forth=transform_filesystem_free,
                     back=transform_filesystem_free,
                 )
             ],
         )),
        ("perfdata",
         ListChoice(
             title=_("Performance data for protocols"),
             help=
             _("Specify for which protocol performance data should get recorded."
               ),
             choices=[
                 ("", _("Summarized data of all protocols")),
                 ("nfs", _("NFS")),
                 ("cifs", _("CIFS")),
                 ("san", _("SAN")),
                 ("fcp", _("FCP")),
                 ("iscsi", _("iSCSI")),
             ],
         )),
        ("magic",
         Float(title=_(
             "Magic factor (automatic level adaptation for large volumes)"),
               default_value=0.8,
               minvalue=0.1,
               maxvalue=1.0)),
        ("magic_normsize",
         Integer(title=_("Reference size for magic factor"),
                 default_value=20,
                 minvalue=1,
                 unit=_("GB"))),
        ("levels_low",
         Tuple(
             title=_("Minimum levels if using magic factor"),
             help=_(
                 "The volume levels will never fall below these values, when using "
                 "the magic factor and the volume is very small."),
             elements=[
                 Percentage(title=_("Warning if above"),
                            unit=_("% usage"),
                            allow_int=True,
                            default_value=50),
                 Percentage(title=_("Critical if above"),
                            unit=_("% usage"),
                            allow_int=True,
                            default_value=60)
             ],
         )),
        ("inodes_levels",
         Alternative(
             title=_("Levels for Inodes"),
             help=_(
                 "The number of remaining inodes on the filesystem. "
                 "Please note that this setting has no effect on some filesystem checks."
             ),
             elements=[
                 Tuple(
                     title=_("Percentage free"),
                     elements=[
                         Percentage(title=_("Warning if less than")),
                         Percentage(title=_("Critical if less than")),
                     ],
                 ),
                 Tuple(
                     title=_("Absolute free"),
                     elements=[
                         Integer(title=_("Warning if less than"),
                                 size=10,
                                 unit=_("inodes"),
                                 minvalue=0,
                                 default_value=10000),
                         Integer(title=_("Critical if less than"),
                                 size=10,
                                 unit=_("inodes"),
                                 minvalue=0,
                                 default_value=5000),
                     ],
                 )
             ],
             default_value=(10.0, 5.0),
         )),
        ("show_inodes",
         DropdownChoice(
             title=_("Display inode usage in check output..."),
             choices=[
                 ("onproblem", _("Only in case of a problem")),
                 ("onlow",
                  _("Only in case of a problem or if inodes are below 50%")),
                 ("always", _("Always")),
             ],
             default_value="onlow",
         )),
        ("trend_range",
         Optional(Integer(
             title=_("Time Range for filesystem trend computation"),
             default_value=24,
             minvalue=1,
             unit=_("hours")),
                  title=_("Trend computation"),
                  label=_("Enable trend computation"))),
        ("trend_mb",
         Tuple(
             title=_("Levels on trends in MB per time range"),
             elements=[
                 Integer(title=_("Warning at"),
                         unit=_("MB / range"),
                         default_value=100),
                 Integer(title=_("Critical at"),
                         unit=_("MB / range"),
                         default_value=200)
             ],
         )),
        ("trend_perc",
         Tuple(
             title=_("Levels for the percentual growth per time range"),
             elements=[
                 Percentage(
                     title=_("Warning at"),
                     unit=_("% / range"),
                     default_value=5,
                 ),
                 Percentage(
                     title=_("Critical at"),
                     unit=_("% / range"),
                     default_value=10,
                 ),
             ],
         )),
        ("trend_timeleft",
         Tuple(
             title=_("Levels on the time left until the filesystem gets full"),
             elements=[
                 Integer(
                     title=_("Warning if below"),
                     unit=_("hours"),
                     default_value=12,
                 ),
                 Integer(
                     title=_("Critical if below"),
                     unit=_("hours"),
                     default_value=6,
                 ),
             ],
         )),
        ("trend_showtimeleft",
         Checkbox(
             title=_("Display time left in check output"),
             label=_("Enable"),
             help=
             _("Normally, the time left until the disk is full is only displayed when "
               "the configured levels have been breached. If you set this option "
               "the check always reports this information"))),
        ("trend_perfdata",
         Checkbox(
             title=_("Trend performance data"),
             label=_("Enable generation of performance data from trends"))),
    ], )
Exemplo n.º 24
0
def _valuespec_special_agents_emcvnx():
    return Dictionary(
        title=_("EMC VNX storage systems"),
        help=
        _("This rule selects the EMC VNX agent instead of the normal Check_MK Agent "
          "and allows monitoring of EMC VNX storage systems by calling naviseccli "
          "commandline tool locally on the monitoring system. Make sure it is installed "
          "and working. You can configure your connection settings here."),
        elements=[
            (
                "user",
                TextInput(
                    title=_("EMC VNX admin user name"),
                    allow_empty=True,
                    help=
                    _("If you leave user name and password empty, the special agent tries to "
                      "authenticate against the EMC VNX device by Security Files. "
                      "These need to be created manually before using. Therefor run as "
                      "instance user (if using OMD) or Nagios user (if not using OMD) "
                      "a command like "
                      "<tt>naviseccli -AddUserSecurity -scope 0 -password PASSWORD -user USER</tt> "
                      "This creates <tt>SecuredCLISecurityFile.xml</tt> and "
                      "<tt>SecuredCLIXMLEncrypted.key</tt> in the home directory of the user "
                      "and these files are used then."),
                ),
            ),
            (
                "password",
                Password(
                    title=_("EMC VNX admin user password"),
                    allow_empty=True,
                ),
            ),
            (
                "infos",
                Transform(
                    valuespec=ListChoice(
                        choices=[
                            ("disks", _("Disks")),
                            ("hba", _("iSCSI HBAs")),
                            ("hwstatus", _("Hardware status")),
                            ("raidgroups", _("RAID groups")),
                            ("agent", _("Model and revsion")),
                            ("sp_util", _("Storage processor utilization")),
                            ("writecache", _("Write cache state")),
                            ("mirrorview", _("Mirror views")),
                            ("storage_pools", _("Storage pools")),
                        ],
                        default_value=[
                            "disks",
                            "hba",
                            "hwstatus",
                        ],
                        allow_empty=False,
                    ),
                    title=_("Retrieve information about..."),
                ),
            ),
        ],
        optional_keys=[],
    )
Exemplo n.º 25
0
 def parameter_valuespec(self):
     return Dictionary(elements=[
         ("bw",
          Alternative(
              title=_("Throughput levels"),
              help=
              _("Please note: in a few cases the automatic detection of the link speed "
                "does not work. In these cases you have to set the link speed manually "
                "below if you want to monitor percentage values"),
              elements=[
                  Tuple(title=_(
                      "Used bandwidth of port relative to the link speed"),
                        elements=[
                            Percentage(title=_("Warning at"),
                                       unit=_("percent")),
                            Percentage(title=_("Critical at"),
                                       unit=_("percent")),
                        ]),
                  Tuple(title=_("Used Bandwidth of port in megabyte/s"),
                        elements=[
                            Integer(title=_("Warning at"),
                                    unit=_("MByte/s")),
                            Integer(title=_("Critical at"),
                                    unit=_("MByte/s")),
                        ])
              ])),
         ("assumed_speed",
          Float(title=_("Assumed link speed"),
                help=_("If the automatic detection of the link speed does "
                       "not work you can set the link speed here."),
                unit=_("GByte/s"))),
         ("rxcrcs",
          Tuple(title=_("CRC errors rate"),
                elements=[
                    Percentage(title=_("Warning at"), unit=_("percent")),
                    Percentage(title=_("Critical at"), unit=_("percent")),
                ])),
         ("rxencoutframes",
          Tuple(title=_("Enc-Out frames rate"),
                elements=[
                    Percentage(title=_("Warning at"), unit=_("percent")),
                    Percentage(title=_("Critical at"), unit=_("percent")),
                ])),
         ("rxencinframes",
          Tuple(title=_("Enc-In frames rate"),
                elements=[
                    Percentage(title=_("Warning at"), unit=_("percent")),
                    Percentage(title=_("Critical at"), unit=_("percent")),
                ])),
         ("notxcredits",
          Tuple(title=_("No-TxCredits errors"),
                elements=[
                    Percentage(title=_("Warning at"), unit=_("percent")),
                    Percentage(title=_("Critical at"), unit=_("percent")),
                ])),
         ("c3discards",
          Tuple(title=_("C3 discards"),
                elements=[
                    Percentage(title=_("Warning at"), unit=_("percent")),
                    Percentage(title=_("Critical at"), unit=_("percent")),
                ])),
         ("average",
          Integer(
              title=_("Averaging"),
              help=
              _("If this parameter is set, all throughputs will be averaged "
                "over the specified time interval before levels are being applied. Per "
                "default, averaging is turned off. "),
              unit=_("minutes"),
              minvalue=1,
              default_value=60,
          )),
         ("phystate",
          Optional(
              ListChoice(title=_(
                  "Allowed states (otherwise check will be critical)"),
                         choices=[
                             (1, _("noCard")),
                             (2, _("noTransceiver")),
                             (3, _("laserFault")),
                             (4, _("noLight")),
                             (5, _("noSync")),
                             (6, _("inSync")),
                             (7, _("portFault")),
                             (8, _("diagFault")),
                             (9, _("lockRef")),
                         ]),
              title=_("Physical state of port"),
              negate=True,
              label=_("ignore physical state"),
          )),
         ("opstate",
          Optional(
              ListChoice(title=_(
                  "Allowed states (otherwise check will be critical)"),
                         choices=[
                             (0, _("unknown")),
                             (1, _("online")),
                             (2, _("offline")),
                             (3, _("testing")),
                             (4, _("faulty")),
                         ]),
              title=_("Operational state"),
              negate=True,
              label=_("ignore operational state"),
          )),
         ("admstate",
          Optional(
              ListChoice(title=_(
                  "Allowed states (otherwise check will be critical)"),
                         choices=[
                             (1, _("online")),
                             (2, _("offline")),
                             (3, _("testing")),
                             (4, _("faulty")),
                         ]),
              title=_("Administrative state"),
              negate=True,
              label=_("ignore administrative state"),
          )),
     ], )
Exemplo n.º 26
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=[],
    )
Exemplo n.º 27
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,
    )
Exemplo n.º 28
0
def _valuespec_special_agents_rabbitmq():
    return Dictionary(
        title=_("RabbitMQ"),
        help=_("Requests data from a RabbitMQ instance."),
        elements=[
            (
                "instance",
                TextInput(
                    title=_("RabbitMQ instance to query"),
                    help=_(
                        "Use this option to set which instance should be "
                        "checked by the special agent. Please add the "
                        "hostname here, eg. my_rabbitmq.com. If not set, the "
                        "assigned host is used as instance."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            (
                "user",
                TextInput(
                    title=_("Username"),
                    help=_(
                        "The username that should be used for accessing the "
                        "RabbitMQ API."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            (
                "password",
                PasswordFromStore(
                    title=_("Password of the user"),
                    allow_empty=False,
                ),
            ),
            (
                "protocol",
                DropdownChoice(
                    title=_("Protocol"),
                    choices=[
                        ("http", "HTTP"),
                        ("https", "HTTPS"),
                    ],
                    default_value="https",
                ),
            ),
            (
                "port",
                Integer(
                    title=_("Port"),
                    default_value=15672,
                    help=_("The port that is used for the api call."),
                ),
            ),
            (
                "sections",
                ListChoice(
                    title=_("Informations to query"),
                    help=_("Defines what information to query. You can choose "
                           "between the cluster, nodes, vhosts and queues."),
                    choices=[
                        ("cluster", _("Clusterwide")),
                        ("nodes", _("Nodes")),
                        ("vhosts", _("Vhosts")),
                        ("queues", _("Queues")),
                    ],
                    default_value=["cluster", "nodes", "vhosts", "queues"],
                    allow_empty=False,
                ),
            ),
        ],
        optional_keys=[
            "instance",
            "port",
        ],
    )
Exemplo n.º 29
0
 def _vs_nagvis_maps(self) -> ListChoice:
     return ListChoice(
         title=_("NagVis Maps"),
         choices=self._get_nagvis_maps,
         toggle_all=True,
     )
Exemplo n.º 30
0
def _valuespec_special_agents_splunk():
    return Dictionary(
        title=_("Splunk"),
        help=_("Requests data from a Splunk instance."),
        optional_keys=["instance", "port"],
        elements=[
            (
                "instance",
                TextInput(
                    title=_("Splunk instance to query."),
                    help=_(
                        "Use this option to set which host should be checked "
                        "by the special agent."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            ("user", TextInput(title=_("Username"), size=32,
                               allow_empty=False)),
            (
                "password",
                PasswordFromStore(
                    title=_("Password of the user"),
                    allow_empty=False,
                ),
            ),
            (
                "protocol",
                DropdownChoice(
                    title=_("Protocol"),
                    choices=[
                        ("http", "HTTP"),
                        ("https", "HTTPS"),
                    ],
                    default_value="https",
                ),
            ),
            (
                "port",
                Integer(
                    title=_("Port"),
                    help=
                    _("Use this option to query a port which is different from standard port 8089."
                      ),
                    default_value=8089,
                ),
            ),
            (
                "infos",
                ListChoice(
                    title=_("Informations to query"),
                    help=_("Defines what information to query. You can "
                           "choose to query license state and usage, Splunk "
                           "system messages, Splunk jobs, shown in the job "
                           "menu within Splunk. You can also query for "
                           "component health and fired alerts."),
                    choices=[
                        ("license_state", _("Licence state")),
                        ("license_usage", _("Licence usage")),
                        ("system_msg", _("System messages")),
                        ("jobs", _("Jobs")),
                        ("health", _("Health")),
                        ("alerts", _("Alerts")),
                    ],
                    default_value=[
                        "license_state",
                        "license_usage",
                        "system_msg",
                        "jobs",
                        "health",
                        "alerts",
                    ],
                    allow_empty=False,
                ),
            ),
        ],
    )