예제 #1
0
def get_bi_aggregation_node_choices():
    return Transform(
        CascadingDropdown(choices=_get_aggregation_choices()),
        forth=_convert_bi_aggr_to_vs,
        back=_convert_bi_aggr_from_vs,
    )
예제 #2
0
def vs_conditions():
    return Transform(
        VSExplicitConditions(rulespec=dummy_rulespec(), render="form_part"),
        forth=lambda c: RuleConditions(**c),
        back=lambda c: dict(c._asdict()),
    )
예제 #3
0
def _valuespec_active_checks_tcp():
    return Tuple(
        title=_("Check TCP port connection"),
        help=_("This check tests the connection to a TCP port. It uses "
               "<tt>check_tcp</tt> from the standard Nagios plugins."),
        elements=[
            Integer(title=_("TCP Port"), minvalue=1, maxvalue=65535),
            Dictionary(
                title=_("Optional parameters"),
                elements=[
                    (
                        "svc_description",
                        TextInput(
                            title=_("Service description"),
                            allow_empty=False,
                            help=_(
                                "Here you can specify a service description. "
                                "If this parameter is not set, the service is named <tt>TCP Port [PORT NUMBER]</tt>"
                            ),
                        ),
                    ),
                    (
                        "hostname",
                        TextInput(
                            title=_("DNS Hostname"),
                            allow_empty=False,
                            help=
                            _("If you specify a hostname here, then a dynamic DNS lookup "
                              "will be done instead of using the IP address of the host "
                              "as configured in your host properties."),
                        ),
                    ),
                    (
                        "response_time",
                        Tuple(
                            title=_("Expected response time"),
                            elements=[
                                Float(title=_("Warning if above"),
                                      unit="ms",
                                      default_value=100.0),
                                Float(title=_("Critical if above"),
                                      unit="ms",
                                      default_value=200.0),
                            ],
                        ),
                    ),
                    (
                        "timeout",
                        Integer(
                            title=_("Seconds before connection times out"),
                            unit=_("sec"),
                            default_value=10,
                        ),
                    ),
                    (
                        "refuse_state",
                        DropdownChoice(
                            title=_("State for connection refusal"),
                            choices=[
                                ("crit", _("CRITICAL")),
                                ("warn", _("WARNING")),
                                ("ok", _("OK")),
                            ],
                        ),
                    ),
                    ("send_string",
                     TextInput(title=_("String to send"), size=30)),
                    (
                        "escape_send_string",
                        FixedValue(
                            value=True,
                            title=
                            _("Expand <tt>\\n</tt>, <tt>\\r</tt> and <tt>\\t</tt> in the sent string"
                              ),
                            totext=_("expand escapes"),
                        ),
                    ),
                    (
                        "expect",
                        ListOfStrings(
                            title=_("Strings to expect in response"),
                            orientation="horizontal",
                            valuespec=TextInput(size=30),
                        ),
                    ),
                    (
                        "expect_all",
                        FixedValue(
                            value=True,
                            totext=_("expect all"),
                            title=
                            _("Expect <b>all</b> of those strings in the response"
                              ),
                        ),
                    ),
                    (
                        "jail",
                        FixedValue(
                            value=True,
                            title=_("Hide response from socket"),
                            help=
                            _("As soon as you configure expected strings in "
                              "the response the check will output the response - "
                              "as long as you do not hide it with this option"
                              ),
                            totext=_("hide response"),
                        ),
                    ),
                    (
                        "mismatch_state",
                        DropdownChoice(
                            title=_("State for expected string mismatch"),
                            choices=[
                                ("crit", _("CRITICAL")),
                                ("warn", _("WARNING")),
                                ("ok", _("OK")),
                            ],
                        ),
                    ),
                    (
                        "delay",
                        Integer(
                            title=_("Seconds to wait before polling"),
                            help=
                            _("Seconds to wait between sending string and polling for response"
                              ),
                            unit=_("sec"),
                            default_value=0,
                        ),
                    ),
                    (
                        "maxbytes",
                        Integer(
                            title=_("Maximum number of bytes to receive"),
                            help=
                            _("Close connection once more than this number of "
                              "bytes are received. Per default the number of "
                              "read bytes is not limited. This setting is only "
                              "used if you expect strings in the response."),
                            default_value=1024,
                        ),
                    ),
                    (
                        "ssl",
                        FixedValue(value=True,
                                   totext=_("use SSL"),
                                   title=_("Use SSL for the connection.")),
                    ),
                    (
                        "cert_days",
                        Transform(
                            valuespec=Tuple(
                                title=_("SSL certificate validation"),
                                help=
                                _("Minimum number of days a certificate has to be valid"
                                  ),
                                elements=[
                                    Integer(title=_("Warning at or below"),
                                            minvalue=0,
                                            unit=_("days")),
                                    Integer(title=_("Critical at or below"),
                                            minvalue=0,
                                            unit=_("days")),
                                ],
                            ),
                            forth=transform_cert_days,
                        ),
                    ),
                    (
                        "quit_string",
                        TextInput(
                            title=_("Final string to send"),
                            help=_(
                                "String to send server to initiate a clean close of "
                                "the connection"),
                            size=30,
                        ),
                    ),
                ],
            ),
        ],
    )
예제 #4
0
 def parameter_valuespec(self):
     return Dictionary(
         title=_("Configure levels for used space"),
         elements=[
             ("ignore_levels",
              FixedValue(
                  title=
                  _("Ignore used space (this option disables any other options)"
                    ),
                  help=
                  _("Some luns, e.g. jfs formatted, tend to report incorrect used space values"
                    ),
                  label=_("Ignore used space"),
                  value=True,
                  totext="",
              )),
             ("levels",
              Alternative(
                  title=_("Levels for LUN"),
                  show_alternative_title=True,
                  default_value=(80.0, 90.0),
                  match=match_dual_level_type,
                  elements=[
                      get_free_used_dynamic_valuespec("used", "LUN"),
                      Transform(
                          get_free_used_dynamic_valuespec(
                              "free", "LUN", default_value=(20.0, 10.0)),
                          allow_empty=False,
                          forth=transform_filesystem_free,
                          back=transform_filesystem_free,
                      )
                  ],
              )),
             ("trend_range",
              Optional(Integer(title=_(
                  "Time Range for lun 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 lun 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 lun filesystem 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"))
              ),
             ("read_only",
              Checkbox(
                  title=_("LUN is read-only"),
                  help=_(
                      "Display a warning if a LUN is not read-only. Without "
                      "this setting a warning will be displayed if a LUN is "
                      "read-only."),
                  label=_("Enable"))),
         ],
     )
예제 #5
0
    def _network_scan_elements(self):
        elements = [
            ("ip_ranges",
             ListOf(
                 self._vs_ip_range(),
                 title=_("IP ranges to scan"),
                 add_label=_("Add new IP range"),
                 text_if_empty=_("No IP range configured"),
             )),
            ("exclude_ranges",
             ListOf(
                 self._vs_ip_range(),
                 title=_("IP ranges to exclude"),
                 add_label=_("Add new IP range"),
                 text_if_empty=_("No exclude range configured"),
             )),
            (
                "scan_interval",
                Age(
                    title=_("Scan interval"),
                    display=["days", "hours"],
                    default_value=60 * 60 * 24,
                    minvalue=3600,  # 1 hour
                )),
            ("time_allowed",
             Transform(
                 ListOf(
                     TimeofdayRange(allow_empty=False, ),
                     title=_("Time allowed"),
                     help=_(
                         "Limit the execution of the scan to this time range."
                     ),
                     allow_empty=False,
                     style=ListOf.Style.FLOATING,
                     movable=False,
                     default_value=[((0, 0), (24, 0))],
                 ),
                 forth=lambda x: [x] if isinstance(x, tuple) else x,
                 back=sorted,
             )),
            ("set_ipaddress",
             Checkbox(
                 title=_("Set IPv4 address"),
                 help=_(
                     "Whether or not to configure the found IP address as the IPv4 "
                     "address of the found hosts."),
                 default_value=True,
             )),
        ]

        elements += self._optional_tag_criticality_element()
        elements += [
            ("max_parallel_pings",
             Integer(
                 title=_("Parallel pings to send"),
                 help=_(
                     "Set the maximum number of concurrent pings sent to target IP "
                     "addresses."),
                 minvalue=1,
                 maxvalue=200,
                 default_value=100,
             )),
            ("run_as",
             DropdownChoice(
                 title=_("Run as"),
                 help=
                 _("Execute the network scan in the Check_MK user context of the "
                   "choosen user. This user needs the permission to add new hosts "
                   "to this folder."),
                 choices=self._get_all_user_ids,
                 default_value=lambda: config.user.id,
             )),
            ("translate_names",
             HostnameTranslation(title=_("Translate Hostnames"), )),
        ]

        return elements
예제 #6
0
def _parameter_valuespec_mail_queue_length():
    return Transform(
        mailqueue_params,
        forth=lambda old: not isinstance(old, dict) and {"deferred": old} or old,
    )
예제 #7
0
def _valuespec_inventory_df_rules():
    return Transform(
        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(
                        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,
    )
예제 #8
0
def _valuespec_active_checks_form_submit():
    return Transform(
        Tuple(
            title=_("Check HTML Form Submit"),
            help=_(
                "Check submission of HTML forms via HTTP/HTTPS using the plugin <tt>check_form_submit</tt> "
                "provided with Check_MK. This plugin provides more functionality than <tt>check_http</tt>, "
                "as it automatically follows HTTP redirect, accepts and uses cookies, parses forms "
                "from the requested pages, changes vars and submits them to check the response "
                "afterwards."
            ),
            elements=[
                TextInput(
                    title=_("Name"),
                    help=_("The name will be used in the service description"),
                    allow_empty=False,
                ),
                Dictionary(
                    title=_("Check the URL"),
                    elements=[
                        (
                            "hosts",
                            ListOfStrings(
                                title=_("Check specific host(s)"),
                                help=_(
                                    "By default, if you do not specify any host addresses here, "
                                    "the host address of the host this service is assigned to will "
                                    "be used. But by specifying one or several host addresses here, "
                                    "it is possible to let the check monitor one or multiple hosts."
                                ),
                            ),
                        ),
                        (
                            "uri",
                            TextInput(
                                title=_("URI to fetch (default is <tt>/</tt>)"),
                                allow_empty=False,
                                default_value="/",
                                regex="^/.*",
                            ),
                        ),
                        (
                            "port",
                            Integer(
                                title=_("TCP Port"),
                                minvalue=1,
                                maxvalue=65535,
                                default_value=80,
                            ),
                        ),
                        (
                            "tls_configuration",
                            DropdownChoice(
                                title=_("TLS/HTTPS configuration"),
                                help=_(
                                    "Activate or deactivate TLS for the connection. No certificate validation means that "
                                    "the server certificate will not be validated by the locally available certificate authorities."
                                ),
                                choices=[
                                    (
                                        "no_tls",
                                        _("No TLS"),
                                    ),
                                    (
                                        "tls_standard",
                                        _("TLS"),
                                    ),
                                    (
                                        "tls_no_cert_valid",
                                        _("TLS without certificate validation"),
                                    ),
                                ],
                            ),
                        ),
                        (
                            "timeout",
                            Integer(
                                title=_("Seconds before connection times out"),
                                unit=_("sec"),
                                default_value=10,
                            ),
                        ),
                        (
                            "expect_regex",
                            RegExp(
                                title=_("Regular expression to expect in content"),
                                mode=RegExp.infix,
                            ),
                        ),
                        (
                            "form_name",
                            TextInput(
                                title=_("Name of the form to populate and submit"),
                                help=_(
                                    "If there is only one form element on the requested page, you "
                                    "do not need to provide the name of that form here. But if you "
                                    "have several forms on that page, you need to provide the name "
                                    "of the form here, to enable the check to identify the correct "
                                    "form element."
                                ),
                                allow_empty=True,
                            ),
                        ),
                        (
                            "query",
                            TextInput(
                                title=_("Send HTTP POST data"),
                                help=_(
                                    "Data to send via HTTP POST method. Please make sure, that the data "
                                    'is URL-encoded (for example "key1=val1&key2=val2").'
                                ),
                                size=40,
                            ),
                        ),
                        (
                            "num_succeeded",
                            Tuple(
                                title=_("Multiple Hosts: Number of successful results"),
                                elements=[
                                    Integer(title=_("Warning if equal or below")),
                                    Integer(title=_("Critical if equal or below")),
                                ],
                            ),
                        ),
                    ],
                ),
            ],
        ),
        forth=_transform_form_submit,
    )
예제 #9
0
 def livestatus_proxy_valuespec(cls):
     return Alternative(
         title=_("Use Livestatus Proxy Daemon"),
         elements=[
             FixedValue(
                 None,
                 title=_("Connect directly, without Livestatus Proxy"),
                 totext="",
             ),
             Transform(
                 Dictionary(
                     title=_("Use Livestatus Proxy Daemon"),
                     optional_keys=["tcp"],
                     columns=1,
                     elements=[
                         (
                             "params",
                             Alternative(
                                 title=_("Parameters"),
                                 elements=[
                                     FixedValue(
                                         None,
                                         title=
                                         _("Use global connection parameters"
                                           ),
                                         totext=
                                         _('Use the <a href="%s">global parameters</a> for this connection'
                                           ) %
                                         "wato.py?mode=edit_configvar&site=&varname=liveproxyd_default_connection_params",
                                     ),
                                     Dictionary(
                                         title=
                                         _("Use custom connection parameters"
                                           ),
                                         elements=cls.
                                         liveproxyd_connection_params_elements(
                                         ),
                                     ),
                                 ],
                             ),
                         ),
                         (
                             "tcp",
                             LivestatusViaTCP(
                                 title=_("Allow access via TCP"),
                                 help=
                                 _("This option can be useful to build a cascading distributed setup. "
                                   "The Livestatus Proxy of this site connects to the site configured "
                                   "here via Livestatus and opens up a TCP port for clients. The "
                                   "requests of the clients are forwarded to the destination site. "
                                   "You need to configure a TCP port here that is not used on the "
                                   "local system yet."),
                                 tcp_port=6560,
                             ),
                         ),
                     ],
                 ),
                 forth=cls.transform_old_connection_params,
             ),
         ],
     )
예제 #10
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,
    )
예제 #11
0
 def _render_options(cls):
     return [
         (
             "metric_render_options",
             Transform(
                 Dictionary(
                     elements=[
                         ("font_size",
                          CascadingDropdown(
                              title=_("Metric value font size"),
                              orientation="horizontal",
                              choices=[
                                  ("fix", _("Set the metric value font size to:"),
                                   Fontsize(default_value="22.5")),
                                  ("dynamic",
                                   _("Dynamically adapt the metric font size to the dashlet size"
                                    ))
                              ],
                              default_value="dynamic")),
                         ("link_to_svc_detail",
                          DropdownChoice(
                              title=_("Link to service detail page"),
                              choices=[
                                  ("true",
                                   _("Open service detail page when clicking on the metric value"
                                    )), ("false", _("Do not add a link to the metric value"))
                              ],
                              default_value="true")),
                         ("show_site",
                          CascadingDropdown(
                              title=_("Show the site name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the site name"))],
                              default_value="false")),
                         ("show_host",
                          CascadingDropdown(
                              title=_("Show the host name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the host name"))],
                              default_value="false")),
                         ("show_service",
                          CascadingDropdown(
                              title=_("Show the service name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the service name"))],
                              default_value="tooltip")),
                         ("show_metric",
                          CascadingDropdown(
                              title=_("Show the metric name"),
                              orientation="horizontal",
                              sorted=False,
                              choices=[("above", _("... above the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("below", _("... below the metric value with font size:"),
                                        Fontsize(default_value="12.0")),
                                       ("tooltip",
                                        _("... in a tooltip when hovering the metric value")),
                                       ("false", _("Do not show the metric name"))],
                              default_value="above")),
                         ("show_state_color",
                          DropdownChoice(title=_("Show the service state color"),
                                         choices=[
                                             ("background", _("... as background color")),
                                             ("font", _("... as font color")),
                                             ("false", _("Do not show the service state color")),
                                         ],
                                         default_value="background")),
                         ("show_unit",
                          DropdownChoice(title=_("Show the metric's unit"),
                                         choices=[
                                             ("true", _("Show the metric's unit")),
                                             ("false", _("Do not show the metric's unit")),
                                         ],
                                         default_value="true")),
                     ],
                     optional_keys=[],
                     title=_("Metric rendering options"),
                 ),),
         ),
     ]
예제 #12
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=[],
    )
예제 #13
0
def _parameter_valuespec_ibm_svc_host():
    return Transform(
        Dictionary(
            elements=[
                (
                    "active_hosts",
                    Tuple(
                        title=_("Count of active hosts"),
                        elements=[
                            Integer(
                                title=_("Warning at or below"), minvalue=0, unit=_("active hosts")
                            ),
                            Integer(
                                title=_("Critical at or below"), minvalue=0, unit=_("active hosts")
                            ),
                        ],
                    ),
                ),
                (
                    "inactive_hosts",
                    Tuple(
                        title=_("Count of inactive hosts"),
                        elements=[
                            Integer(
                                title=_("Warning at or above"), minvalue=0, unit=_("inactive hosts")
                            ),
                            Integer(
                                title=_("Critical at or above"),
                                minvalue=0,
                                unit=_("inactive hosts"),
                            ),
                        ],
                    ),
                ),
                (
                    "degraded_hosts",
                    Tuple(
                        title=_("Count of degraded hosts"),
                        elements=[
                            Integer(
                                title=_("Warning at or above"), minvalue=0, unit=_("degraded hosts")
                            ),
                            Integer(
                                title=_("Critical at or above"),
                                minvalue=0,
                                unit=_("degraded hosts"),
                            ),
                        ],
                    ),
                ),
                (
                    "offline_hosts",
                    Tuple(
                        title=_("Count of offline hosts"),
                        elements=[
                            Integer(
                                title=_("Warning at or above"), minvalue=0, unit=_("offline hosts")
                            ),
                            Integer(
                                title=_("Critical at or above"), minvalue=0, unit=_("offline hosts")
                            ),
                        ],
                    ),
                ),
                (
                    "other_hosts",
                    Tuple(
                        title=_("Count of other hosts"),
                        elements=[
                            Integer(
                                title=_("Warning at or above"), minvalue=0, unit=_("other hosts")
                            ),
                            Integer(
                                title=_("Critical at or above"), minvalue=0, unit=_("other hosts")
                            ),
                        ],
                    ),
                ),
            ],
        ),
        forth=transform_ibm_svc_host,
    )
예제 #14
0
def get_bi_rule_node_choices_vs():
    return Transform(
        CascadingDropdown(choices=_get_rule_choices(), sorted=False),
        forth=_convert_bi_rule_to_vs,
        back=_convert_bi_rule_from_vs,
    )
예제 #15
0
파일: ps.py 프로젝트: gradecke/checkmk
def _valuespec_inventory_processes_rules():
    return Transform(
        Dictionary(
            title=_("Process discovery"),
            help=_(
                "This ruleset defines criteria for automatically creating checks for running "
                "processes based upon what is running when the service discovery is "
                "done. These services will be created with default parameters. They will get "
                "critical when no process is running and OK otherwise. You can parameterize "
                "the check with the ruleset <i>State and count of processes</i>."
            ),
            elements=[
                ("descr", process_discovery_descr_option()),
                ("match", process_match_options()),
                (
                    "user",
                    user_match_options(
                        [
                            FixedValue(
                                False,
                                title=_("Grab user from found processess"),
                                totext="",
                                help=_(
                                    'Specifying "grab user" makes the created check expect the process to '
                                    "run as the same user as during inventory: the user name will be "
                                    "hardcoded into the check. In that case if you put %u into the service "
                                    "description, that will be replaced by the actual user name during "
                                    "inventory. You need that if your rule might match for more than one "
                                    "user - your would create duplicate services with the same description "
                                    "otherwise."
                                ),
                            )
                        ]
                    ),
                ),
                ("cgroup", cgroup_match_options()),
                (
                    "label",
                    Labels(
                        Labels.World.CONFIG,
                        title=_("Host Label"),
                        help=_(
                            "Here you can set host labels that automatically get created when discovering the services."
                        ),
                    ),
                ),
                (
                    "default_params",
                    Dictionary(
                        title=_("Default parameters for detected services"),
                        help=_(
                            "Here you can select default parameters that are being set "
                            "for detected services. Note: the preferred way for setting parameters is to use "
                            'the rule set <a href="wato.py?varname=checkgroup_parameters:ps&mode=edit_ruleset"> '
                            "State and Count of Processes</a> instead. "
                            "A change there will immediately be active, while a change in this rule "
                            "requires a re-discovery of the services."
                        ),
                        elements=process_level_elements(),
                        ignored_keys=["match_groups"],
                        required_keys=["cpu_rescale_max"],
                    ),
                ),
            ],
            required_keys=["descr", "default_params"],
        ),
        forth=convert_inventory_processes,
    )
예제 #16
0
 def cascading_dropdown_choice_element(cls):
     return (cls.type(), _("No search"),
             Transform(FixedValue(""),
                       forth=lambda x: "",
                       back=lambda x: {"type": cls.type()}))
예제 #17
0
파일: utils.py 프로젝트: petrows/checkmk
        result.append((item[0], tuple_convert(item[1])))
    return result


fs_levels_elements = [
    ("levels",
     Alternative(
         title=_("Levels for filesystem"),
         show_alternative_title=True,
         default_value=(80.0, 90.0),
         match=match_dual_level_type,
         elements=[
             get_free_used_dynamic_valuespec("used", "filesystem"),
             Transform(
                 get_free_used_dynamic_valuespec("free", "filesystem", default_value=(20.0, 10.0)),
                 title=_("Levels for filesystem free space"),
                 forth=transform_filesystem_free,
                 back=transform_filesystem_free,
             )
         ],
     )),
    ("show_levels",
     DropdownChoice(
         title=_("Display warn/crit levels in check output..."),
         choices=[
             ("onproblem", _("Only if the status is non-OK")),
             ("onmagic", _("If the status is non-OK or a magic factor is set")),
             ("always", _("Always")),
         ],
         default_value="onmagic",
     )),
]
예제 #18
0
파일: memory.py 프로젝트: m4c3/checkMK
 def parameter_valuespec(self):
     return Transform(
         Dictionary(
             elements=[
                 (
                     "levels",
                     Alternative(
                         title=_("Levels for memory"),
                         show_alternative_title=True,
                         default_value=(150.0, 200.0),
                         match=match_dual_level_type,
                         help=
                         _("The used and free levels for the memory on UNIX systems take into account the "
                           "currently used memory (RAM or SWAP) by all processes and sets this in relation "
                           "to the total RAM of the system. This means that the memory usage can exceed 100%. "
                           "A usage of 200% means that the total size of all processes is twice as large as "
                           "the main memory, so <b>at least</b> half of it is currently swapped out. For systems "
                           "without Swap space you should choose levels below 100%."
                           ),
                         elements=[
                             Alternative(
                                 title=_("Levels for used memory"),
                                 style="dropdown",
                                 elements=[
                                     Tuple(
                                         title=
                                         _("Specify levels in percentage of total RAM"
                                           ),
                                         elements=[
                                             Percentage(title=_(
                                                 "Warning at a usage of"),
                                                        maxvalue=None),
                                             Percentage(title=_(
                                                 "Critical at a usage of"),
                                                        maxvalue=None)
                                         ],
                                     ),
                                     Tuple(
                                         title=
                                         _("Specify levels in absolute values"
                                           ),
                                         elements=[
                                             Integer(title=_("Warning at"),
                                                     unit=_("MB")),
                                             Integer(title=_("Critical at"),
                                                     unit=_("MB"))
                                         ],
                                     ),
                                 ],
                             ),
                             Transform(Alternative(
                                 style="dropdown",
                                 elements=[
                                     Tuple(
                                         title=
                                         _("Specify levels in percentage of total RAM"
                                           ),
                                         elements=[
                                             Percentage(title=_(
                                                 "Warning if less than"),
                                                        maxvalue=None),
                                             Percentage(title=_(
                                                 "Critical if less than"),
                                                        maxvalue=None)
                                         ],
                                     ),
                                     Tuple(
                                         title=
                                         _("Specify levels in absolute values"
                                           ),
                                         elements=[
                                             Integer(title=_(
                                                 "Warning if below"),
                                                     unit=_("MB")),
                                             Integer(title=_(
                                                 "Critical if below"),
                                                     unit=_("MB"))
                                         ],
                                     ),
                                 ],
                             ),
                                       title=_("Levels for free memory"),
                                       help=
                                       _("Keep in mind that if you have 1GB RAM and 1GB SWAP you need to "
                                         "specify 120% or 1200MB to get an alert if there is only 20% free RAM available. "
                                         "The free memory levels do not work with the fortigate check, because it does "
                                         "not provide total memory data."),
                                       allow_empty=False,
                                       forth=lambda val: tuple(
                                           -x for x in val),
                                       back=lambda val: tuple(-x
                                                              for x in val))
                         ],
                     ),
                 ),
                 ("average",
                  Integer(
                      title=_("Averaging"),
                      help=
                      _("If this parameter is set, all measured values 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,
                  )),
             ],
             optional_keys=["average"],
         ),
         forth=lambda t: isinstance(t, tuple) and {"levels": t} or t,
     )
예제 #19
0
def _valuespec_filesystem_groups():
    return Transform(
        Dictionary(
            title=_("Filesystem grouping patterns"),
            optional_keys=False,
            elements=[(
                FILESYSTEM_GROUPS_WRAPPER_KEY,
                ListOf(
                    Dictionary(
                        optional_keys=False,
                        elements=[
                            (
                                "group_name",
                                TextInput(title=_("Group name"), ),
                            ),
                            (
                                "patterns_include",
                                ListOfStrings(
                                    title=_("Inclusion patterns"),
                                    orientation="horizontal",
                                    help=
                                    _("You can specify one or several globbing patterns containing "
                                      "<tt>*</tt>, <tt>?</tt> and <tt>[...]</tt>, for example "
                                      "<tt>/spool/tmpspace*</tt>. The filesystems matching the "
                                      "patterns will be grouped together and monitored as one big "
                                      "filesystem in a single service. Note that specifically for "
                                      "the check <tt>df</tt>, the pattern matches either the mount "
                                      "point or the combination of volume and mount point, "
                                      "depending on the configuration in "
                                      "<a href='wato.py?mode=edit_ruleset&varname=inventory_df_rules'>"
                                      "Filesystem discovery</a>."),
                                ),
                            ),
                            (
                                "patterns_exclude",
                                ListOfStrings(
                                    title=_("Exclusion patterns"),
                                    orientation="horizontal",
                                    help=
                                    _("You can specify one or several globbing patterns containing "
                                      "<tt>*</tt>, <tt>?</tt> and <tt>[...]</tt>, for example "
                                      "<tt>/spool/tmpspace*</tt>. The filesystems matching the "
                                      "patterns will excluded from grouping and monitored "
                                      "individually. Note that specifically for the check "
                                      "<tt>df</tt>, the pattern matches either the mount point or "
                                      "the combination of volume and mount point, depending on the "
                                      "configuration in "
                                      "<a href='wato.py?mode=edit_ruleset&varname=inventory_df_rules'>"
                                      "Filesystem discovery</a>."),
                                ),
                            ),
                        ],
                    ),
                    add_label=_("Add group"),
                    title=_("Filesystem grouping patterns"),
                    help=
                    _("By default, the filesystem checks (<tt>df</tt>, <tt>hr_fs</tt> and others) will "
                      "create a single service for each filesystem. By defining grouping patterns, you "
                      "can handle groups of filesystems like one filesystem. For each group, you can "
                      "define one or several include and exclude patterns. The filesystems matching one "
                      "of the include patterns will be monitored like one big filesystem in a single "
                      "service. The filesystems matching one of the exclude patterns will be excluded "
                      "from the group and monitored individually."),
                ),
            )],
        ),
        forth=_transform_filesystem_groups,
    )
예제 #20
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(
                valuespec=vs_title_infos(),
                forth=transform_graph_render_options_title_format,
            ),
        ),
        (
            "show_graph_time",
            Checkbox(
                title=_("Show graph time range"),
                label=_("Show the graph time range on top of the graph"),
                default_value=default_values["show_graph_time"],
            ),
        ),
        (
            "show_margin",
            Checkbox(
                title=_("Show margin round the graph"),
                label=_("Show a margin round the graph"),
                default_value=default_values["show_margin"],
            ),
        ),
        (
            "show_legend",
            Checkbox(
                title=_("Show legend"),
                label=_("Show the graph legend"),
                default_value=default_values["show_legend"],
            ),
        ),
        (
            "show_vertical_axis",
            Checkbox(
                title=_("Show vertical axis"),
                label=_("Show the graph vertical axis"),
                default_value=default_values["show_vertical_axis"],
            ),
        ),
        (
            "vertical_axis_width",
            CascadingDropdown(
                title=_("Vertical axis width"),
                orientation="horizontal",
                choices=[
                    ("fixed", _("Use fixed width (relative to font size)")),
                    (
                        "explicit",
                        _("Use absolute width:"),
                        Float(title="", default_value=40.0, unit=_("pt")),
                    ),
                ],
            ),
        ),
        (
            "show_time_axis",
            Checkbox(
                title=_("Show time axis"),
                label=_("Show the graph time axis"),
                default_value=default_values["show_time_axis"],
            ),
        ),
        (
            "show_controls",
            Checkbox(
                title=_("Show controls"),
                label=_("Show the graph controls"),
                default_value=default_values["show_controls"],
            ),
        ),
        (
            "show_pin",
            Checkbox(
                title=_("Show pin"),
                label=_("Show the pin"),
                default_value=default_values["show_pin"],
            ),
        ),
        (
            "show_time_range_previews",
            Checkbox(
                title=_("Show time range previews"),
                label="Show previews",
                default_value=default_values["show_time_range_previews"],
            ),
        ),
        (
            "fixed_timerange",
            Checkbox(
                title=_("Timerange synchronization"),
                label="Do not follow timerange changes of other graphs on the current page",
                default_value=default_values["fixed_timerange"],
            ),
        ),
    ]

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

    return elements
예제 #21
0
파일: emcvnx.py 프로젝트: m3rlinux/checkmk
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=[],
    )
예제 #22
0
파일: if.py 프로젝트: stmps/checkmk
                _('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,
        )


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

vs_elements_if_groups_group = [
    ("group_name",
예제 #23
0
def _parameter_valuespec_temperature():
    return Transform(
        Dictionary(elements=[
            (
                "levels",
                Transform(
                    Tuple(
                        title=_("Upper Temperature Levels"),
                        elements=[
                            Float(title=_("Warning at"),
                                  unit=u"°C",
                                  default_value=26),
                            Float(title=_("Critical at"),
                                  unit=u"°C",
                                  default_value=30),
                        ],
                    ),
                    forth=lambda elems: (float(elems[0]), float(elems[1])),
                ),
            ),
            (
                "levels_lower",
                Transform(
                    Tuple(
                        title=_("Lower Temperature Levels"),
                        elements=[
                            Float(title=_("Warning below"),
                                  unit=u"°C",
                                  default_value=0),
                            Float(title=_("Critical below"),
                                  unit=u"°C",
                                  default_value=-10),
                        ],
                    ),
                    forth=lambda elems: (float(elems[0]), float(elems[1])),
                ),
            ),
            ("output_unit",
             DropdownChoice(
                 title=_("Display values in "),
                 choices=[
                     ("c", _("Celsius")),
                     ("f", _("Fahrenheit")),
                     ("k", _("Kelvin")),
                 ],
             )),
            ("input_unit",
             DropdownChoice(
                 title=_("Override unit of sensor"),
                 help=
                 _("In some rare cases the unit that is signalled by the sensor "
                   "is wrong and e.g. the sensor sends values in Fahrenheit while "
                   "they are misinterpreted as Celsius. With this setting you can "
                   "force the reading of the sensor to be interpreted as customized. "
                   ),
                 choices=[
                     ("c", _("Celsius")),
                     ("f", _("Fahrenheit")),
                     ("k", _("Kelvin")),
                 ],
             )),
            ("device_levels_handling",
             DropdownChoice(
                 title=_(
                     "Interpretation of the device's own temperature status"),
                 choices=[
                     ("usr", _("Ignore device's own levels")),
                     ("dev", _("Only use device's levels, ignore yours")),
                     ("best",
                      _("Use least critical of your and device's levels")),
                     ("worst",
                      _("Use most critical of your and device's levels")),
                     ("devdefault",
                      _("Use device's levels if present, otherwise yours")),
                     ("usrdefault",
                      _("Use your own levels if present, otherwise the device's"
                        )),
                 ],
                 default_value="usrdefault",
             )),
            (
                "trend_compute",
                Dictionary(
                    title=_("Trend computation"),
                    elements=
                    [("period",
                      Integer(
                          title=
                          _("Observation period for temperature trend computation"
                            ),
                          default_value=30,
                          minvalue=5,
                          unit=_("minutes"),
                      )),
                     ("trend_levels",
                      Tuple(
                          title=_("Levels on temperature increase per period"),
                          elements=[
                              Integer(
                                  title=_("Warning at"),
                                  unit=u"°C / " + _("period"),
                                  default_value=5,
                              ),
                              Integer(
                                  title=_("Critical at"),
                                  unit=u"°C / " + _("period"),
                                  default_value=10,
                              )
                          ],
                      )),
                     ("trend_levels_lower",
                      Tuple(
                          title=_("Levels on temperature decrease per period"),
                          elements=[
                              Integer(
                                  title=_("Warning at"),
                                  unit=u"°C / " + _("period"),
                                  default_value=5,
                              ),
                              Integer(
                                  title=_("Critical at"),
                                  unit=u"°C / " + _("period"),
                                  default_value=10,
                              )
                          ],
                      )),
                     ("trend_timeleft",
                      Tuple(
                          title=
                          _("Levels on the time left until a critical temperature (upper or lower) is reached"
                            ),
                          elements=[
                              Integer(
                                  title=_("Warning if below"),
                                  unit=_("minutes"),
                                  default_value=240,
                              ),
                              Integer(
                                  title=_("Critical if below"),
                                  unit=_("minutes"),
                                  default_value=120,
                              ),
                          ],
                      ))],
                    optional_keys=[
                        "trend_levels", "trend_levels_lower", "trend_timeleft"
                    ],
                ),
            ),
        ], ),
        forth=lambda v: isinstance(v, tuple) and {"levels": v} or v,
    )
예제 #24
0
파일: if.py 프로젝트: stmps/checkmk
 def valuespec(self):
     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(),
                      custom_order=True,
                      rows=40,
                      toggle_all=True,
                      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,
     )
예제 #25
0
 def valuespec(self):
     return Transform(
         LockedByValuespec(),
         forth=tuple,
         back=list,
     )
예제 #26
0
파일: if.py 프로젝트: stmps/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,
                  )),
                 ("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")),
                      ])),
             ],
         ),
         forth=transform_if,
     )
예제 #27
0
        result.append((item[0], tuple_convert(item[1])))
    return result


fs_levels_elements = [
    ("levels",
     Alternative(
         title=_("Levels for filesystem"),
         show_alternative_title=True,
         default_value=(80.0, 90.0),
         match=match_dual_level_type,
         elements=[
             get_free_used_dynamic_valuespec("used", "filesystem"),
             Transform(
                 get_free_used_dynamic_valuespec("free", "filesystem", default_value=(20.0, 10.0)),
                 title=_("Levels for filesystem free space"),
                 forth=transform_filesystem_free,
                 back=transform_filesystem_free,
             )
         ],
     )),
    ("show_levels",
     DropdownChoice(
         title=_("Display warn/crit levels in check output..."),
         choices=[
             ("onproblem", _("Only if the status is non-OK")),
             ("onmagic", _("If the status is non-OK or a magic factor is set")),
             ("always", _("Always")),
         ],
         default_value="onmagic",
     )),
]
예제 #28
0
def _valuespec_inv_domino_tasks_rules():
    return Dictionary(
        title=_('Lotus Domino task discovery'),
        help=_(
            "This rule controls the discovery of tasks on Lotus Domino systems. "
            "Any changes later on require a host re-discovery"),
        elements=[
            ('descr',
             TextAscii(
                 title=_('Service Description'),
                 allow_empty=False,
                 help=
                 _('<p>The service description may contain one or more occurances of <tt>%s</tt>. In this '
                   'case, the pattern must be a regular expression prefixed with ~. For each '
                   '<tt>%s</tt> in the description, the expression has to contain one "group". A group '
                   'is a subexpression enclosed in brackets, for example <tt>(.*)</tt> or '
                   '<tt>([a-zA-Z]+)</tt> or <tt>(...)</tt>. When the inventory finds a task '
                   'matching the pattern, it will substitute all such groups with the actual values when '
                   'creating the check. In this way one rule can create several checks on a host.</p>'
                   '<p>If the pattern contains more groups than occurrences of <tt>%s</tt> in the service '
                   'description, only the first matching subexpressions are used for the service '
                   'descriptions. The matched substrings corresponding to the remaining groups '
                   'are nevertheless copied into the regular expression.</p>'
                   '<p>As an alternative to <tt>%s</tt> you may also use <tt>%1</tt>, <tt>%2</tt>, etc. '
                   'These expressions will be replaced by the first, second, ... matching group, allowing '
                   'you to reorder things.</p>'),
             )),
            (
                'match',
                Alternative(
                    title=_("Task Matching"),
                    elements=[
                        TextAscii(
                            title=_("Exact name of the task"),
                            size=50,
                        ),
                        Transform(
                            RegExp(
                                size=50,
                                mode=RegExp.prefix,
                            ),
                            title=_(
                                "Regular expression matching command line"),
                            help=
                            _("This regex must match the <i>beginning</i> of the task"
                              ),
                            forth=lambda x: x[1:],  # remove ~
                            back=lambda x: "~" + x,  # prefix ~
                        ),
                        FixedValue(
                            None,
                            totext="",
                            title=_("Match all tasks"),
                        )
                    ],
                    match=lambda x: (not x and 2) or (x[0] == '~' and 1 or 0),
                    default_value='foo')),
            ('levels',
             Tuple(
                 title=_('Levels'),
                 help=
                 _("Please note that if you specify and also if you modify levels here, the change is "
                   "activated only during an inventory.  Saving this rule is not enough. This is due to "
                   "the nature of inventory rules."),
                 elements=[
                     Integer(
                         title=_("Critical below"),
                         unit=_("processes"),
                         default_value=1,
                     ),
                     Integer(
                         title=_("Warning below"),
                         unit=_("processes"),
                         default_value=1,
                     ),
                     Integer(
                         title=_("Warning above"),
                         unit=_("processes"),
                         default_value=1,
                     ),
                     Integer(
                         title=_("Critical above"),
                         unit=_("processes"),
                         default_value=1,
                     ),
                 ],
             )),
        ],
        required_keys=['match', 'levels', 'descr'],
    )
예제 #29
0
def _parameter_valuespec_cpu_utilization_os():
    return Transform(
        cpu_util_common_dict,
        forth=transform_legacy_cpu_utilization_os,
    )
예제 #30
0
 def parameter_valuespec(self):
     return Transform(
         Dictionary(
             elements=[
                 ("capacity",
                  Tuple(
                      title=_("Levels of battery capacity"),
                      elements=[
                          Percentage(
                              title=_("Warning below"),
                              default_value=95.0,
                          ),
                          Percentage(
                              title=_("Critical below"),
                              default_value=90.0,
                          ),
                      ])),
                 ("calibration_state",
                  MonitoringState(
                      title=_("State if calibration is invalid"),
                      default_value=0,
                  )),
                 ("post_calibration_levels",
                  Dictionary(
                      title=_("Levels of battery parameters after calibration"),
                      help=
                      _("After a battery calibration the battery capacity is reduced until the "
                        "battery is fully charged again. Here you can specify an alternative "
                        "lower level in this post-calibration phase. "
                        "Since apc devices remember the time of the last calibration only "
                        "as a date, the alternative lower level will be applied on the whole "
                        "day of the calibration until midnight. You can extend this time period "
                        "with an additional time span to make sure calibrations occuring just "
                        "before midnight do not trigger false alarms."),
                      elements=[
                          ("altcapacity",
                           Percentage(
                               title=_(
                                   "Alternative critical battery capacity after calibration"),
                               default_value=50,
                           )),
                          ("additional_time_span",
                           Integer(
                               title=("Extend post-calibration phase by additional time span"),
                               unit=_("minutes"),
                               default_value=0,
                           )),
                      ],
                      optional_keys=False,
                  )),
                 ("battime",
                  Tuple(
                      title=_("Time left on battery"),
                      elements=[
                          Age(title=_("Warning at"),
                              help=
                              _("Time left on Battery at and below which a warning state is triggered"
                               ),
                              default_value=0,
                              display=["hours", "minutes"]),
                          Age(title=_("Critical at"),
                              help=
                              _("Time Left on Battery at and below which a critical state is triggered"
                               ),
                              default_value=0,
                              display=["hours", "minutes"]),
                      ],
                  )),
                 ("battery_replace_state",
                  MonitoringState(
                      title=_("State if battery needs replacement"),
                      default_value=1,
                  )),
             ],
             optional_keys=['post_calibration_levels', 'output_load', 'battime'],
         ),
         forth=self._transform_apc_symmetra,
     )