Beispiel #1
0
def _parameter_valuespec_k8s_port():
    return Dictionary(elements=[
        (
            "port",
            NetworkPort(title=_("Port"), ),
        ),
        (
            "target_port",
            NetworkPort(title=_("Target port"), ),
        ),
        (
            "node_port",
            NetworkPort(title=_("Node port"), ),
        ),
        (
            "protocol",
            DropdownChoice(
                title=_("Protocol"),
                choices=[
                    ("TCP", _("TCP")),
                    ("UDP", _("UDP")),
                    ("HTTP", _("HTTP")),
                    ("PROXY", _("PROXY")),
                    ("SCTP", _("SCTP")),
                ],
            ),
        ),
    ], )
Beispiel #2
0
def _parameter_valuespec_tcp_connections():
    return Dictionary(
        help=_(
            "This rule allows to monitor the existence of specific TCP connections or "
            "TCP/UDP listeners."),
        elements=[
            (
                "proto",
                DropdownChoice(
                    title=_("Protocol"),
                    choices=[("TCP", _("TCP")), ("UDP", _("UDP"))],
                    default_value="TCP",
                ),
            ),
            (
                "state",
                DropdownChoice(
                    title=_("State"),
                    choices=[
                        ("ESTABLISHED", "ESTABLISHED"),
                        ("LISTENING", "LISTENING"),
                        ("SYN_SENT", "SYN_SENT"),
                        ("SYN_RECV", "SYN_RECV"),
                        ("LAST_ACK", "LAST_ACK"),
                        ("CLOSE_WAIT", "CLOSE_WAIT"),
                        ("TIME_WAIT", "TIME_WAIT"),
                        ("CLOSED", "CLOSED"),
                        ("CLOSING", "CLOSING"),
                        ("FIN_WAIT1", "FIN_WAIT1"),
                        ("FIN_WAIT2", "FIN_WAIT2"),
                        ("BOUND", "BOUND"),
                    ],
                ),
            ),
            ("local_ip", IPv4Address(title=_("Local IP address"))),
            ("local_port", NetworkPort(title=_("Local port number"))),
            ("remote_ip", IPv4Address(title=_("Remote IP address"))),
            ("remote_port", NetworkPort(title=_("Remote port number"))),
            (
                "max_states",
                Tuple(
                    title=_("Maximum number of connections or listeners"),
                    elements=[
                        Integer(title=_("Warning at")),
                        Integer(title=_("Critical at")),
                    ],
                ),
            ),
            (
                "min_states",
                Tuple(
                    title=_("Minimum number of connections or listeners"),
                    elements=[
                        Integer(title=_("Warning if below")),
                        Integer(title=_("Critical if below")),
                    ],
                ),
            ),
        ],
    )
Beispiel #3
0
def _parameter_valuespec_k8s_port():
    return Dictionary(elements=[
        ('port', NetworkPort(title=_('Port'), )),
        ('target_port', NetworkPort(title=_('Target port'), )),
        ('node_port', NetworkPort(title=_('Node port'), )),
        ('protocol',
         DropdownChoice(
             title=_('Protocol'),
             choices=[
                 ('TCP', _('TCP')),
                 ('UDP', _('UDP')),
                 ('HTTP', _('HTTP')),
                 ('PROXY', _('PROXY')),
                 ('SCTP', _('SCTP')),
             ],
         )),
    ], )
Beispiel #4
0
def _valuespec_special_agents_mobileiron():
    return Dictionary(
        elements=[
            ("username", TextInput(title=_("Username"), allow_empty=False)),
            ("password",
             IndividualOrStoredPassword(title=_("Password"),
                                        allow_empty=False)),
            (
                "port",
                NetworkPort(
                    title=_("Port"),
                    default_value=443,
                    help=_("The port that is used for the API call."),
                ),
            ),
            (
                "no-cert-check",
                FixedValue(
                    True,
                    title=_("Disable SSL certificate validation"),
                    totext=_("SSL certificate validation is disabled"),
                ),
            ),
            (
                "partition",
                ListOfStrings(
                    allow_empty=False,
                    title=_(
                        "Retrieve information about the following partitions"),
                ),
            ),
            (
                "proxy_details",
                Dictionary(
                    title=_("Use proxy for MobileIron API connection"),
                    elements=[
                        ("proxy_host",
                         TextInput(title=_("Proxy host"), allow_empty=True)),
                        ("proxy_port", Integer(title=_("Port"))),
                        (
                            "proxy_user",
                            TextInput(
                                title=_("Username"),
                                size=32,
                            ),
                        ),
                        ("proxy_password",
                         IndividualOrStoredPassword(title=_("Password"))),
                    ],
                    optional_keys=[
                        "proxy_port", "proxy_user", "proxy_password"
                    ],
                ),
            ),
        ],
        optional_keys=["no-cert-check"],
        title=_("MobileIron API"),
    )
Beispiel #5
0
def _parameter_valuespec_logwatch_ec():
    return Alternative(
        title=_("Forwarding"),
        help=
        _("Instead of using the regular logwatch check all lines received by logwatch can "
          "be forwarded to a Check_MK event console daemon to be processed. The target event "
          "console can be configured for each host in a separate rule."),
        elements=[
            FixedValue(
                "",
                totext=_("Messages are handled by logwatch."),
                title=_("No forwarding"),
            ),
            Dictionary(
                title=_("Forward Messages to Event Console"),
                elements=[
                    (
                        "method",
                        Transform(
                            # TODO: Clean this up to some CascadingDropdown()
                            Alternative(
                                title=_("Forwarding Method"),
                                elements=[
                                    FixedValue(
                                        "",
                                        title=
                                        _("Local: Send events to local Event Console in same OMD site"
                                          ),
                                        totext=_(
                                            "Directly forward to Event Console"
                                        ),
                                    ),
                                    TextInput(
                                        title=
                                        _("Local: Send events to local Event Console into unix socket"
                                          ),
                                        allow_empty=False,
                                    ),
                                    FixedValue(
                                        "spool:",
                                        title=
                                        _("Local: Spooling - Send events to local event console in same OMD site"
                                          ),
                                        totext=_("Spool to Event Console"),
                                    ),
                                    Transform(
                                        TextInput(allow_empty=False, ),
                                        title=
                                        _("Local: Spooling - Send events to local Event Console into given spool directory"
                                          ),
                                        forth=lambda x: x[6:],
                                        # remove prefix
                                        back=lambda x: "spool:" +
                                        x,  # add prefix
                                    ),
                                    CascadingDropdown(
                                        title=
                                        _("Remote: Send events to remote syslog host"
                                          ),
                                        choices=[
                                            (
                                                "tcp",
                                                _("Send via TCP"),
                                                Dictionary(
                                                    elements=[
                                                        (
                                                            "address",
                                                            TextInput(
                                                                title=_(
                                                                    "Address"),
                                                                allow_empty=
                                                                False,
                                                            ),
                                                        ),
                                                        (
                                                            "port",
                                                            NetworkPort(
                                                                title=_(
                                                                    "Port"),
                                                                default_value=
                                                                514,
                                                            ),
                                                        ),
                                                        (
                                                            "spool",
                                                            Dictionary(
                                                                title=
                                                                _("Spool messages that could not be sent"
                                                                  ),
                                                                help=
                                                                _("Messages that can not be forwarded, e.g. when the target Event Console is "
                                                                  "not running, can temporarily be stored locally. Forwarding is tried again "
                                                                  "on next execution. When messages are spooled, the check will go into WARNING "
                                                                  "state. In case messages are dropped by the rules below, the check will shortly "
                                                                  "go into CRITICAL state for this execution."
                                                                  ),
                                                                elements=[
                                                                    (
                                                                        "max_age",
                                                                        Age(
                                                                            title
                                                                            =_(
                                                                                "Maximum spool duration"
                                                                            ),
                                                                            help
                                                                            =_(
                                                                                "Messages that are spooled longer than this time will be thrown away."
                                                                            ),
                                                                            default_value
                                                                            =60
                                                                            *
                                                                            60
                                                                            *
                                                                            24
                                                                            *
                                                                            7,  # 1 week should be fine (if size is not exceeded)
                                                                        ),
                                                                    ),
                                                                    (
                                                                        "max_size",
                                                                        Filesize(
                                                                            title
                                                                            =_(
                                                                                "Maximum spool size"
                                                                            ),
                                                                            help=
                                                                            _("When the total size of spooled messages exceeds this number, the oldest "
                                                                              "messages of the currently spooled messages is thrown away until the left "
                                                                              "messages have the half of the maximum size."
                                                                              ),
                                                                            default_value
                                                                            =
                                                                            500000,  # do not save more than 500k of message
                                                                        ),
                                                                    ),
                                                                ],
                                                                optional_keys=
                                                                [],
                                                            ),
                                                        ),
                                                    ],
                                                    optional_keys=["spool"],
                                                ),
                                            ),
                                            (
                                                "udp",
                                                _("Send via UDP"),
                                                Dictionary(
                                                    elements=[
                                                        (
                                                            "address",
                                                            TextInput(
                                                                title=_(
                                                                    "Address"),
                                                                allow_empty=
                                                                False,
                                                            ),
                                                        ),
                                                        (
                                                            "port",
                                                            NetworkPort(
                                                                title=_(
                                                                    "Port"),
                                                                default_value=
                                                                514,
                                                            ),
                                                        ),
                                                    ],
                                                    optional_keys=[],
                                                ),
                                            ),
                                        ],
                                    ),
                                ],
                                match=lambda x: 4 if isinstance(x, tuple) else
                                (0 if not x else
                                 (2 if x == "spool:" else
                                  (3 if x.startswith("spool:") else 1))),
                            ),
                            # migrate old (tcp, address, port) tuple to new dict
                            forth=lambda v: (v[0], {
                                "address": v[1],
                                "port": v[2]
                            }) if (isinstance(v, tuple) and not isinstance(
                                v[1], dict)) else v,
                        ),
                    ),
                    (
                        "facility",
                        DropdownChoice(
                            title=_("Syslog facility for forwarded messages"),
                            help=_(
                                "When forwarding messages and no facility can be extracted from the "
                                "message this facility is used."),
                            choices=mkeventd.syslog_facilities,
                            default_value=17,  # local1
                        ),
                    ),
                    (
                        "restrict_logfiles",
                        ListOfStrings(
                            title=
                            _("Restrict Logfiles (Prefix matching regular expressions)"
                              ),
                            help=
                            _('Put the item names of the logfiles here. For example "System$" '
                              'to select the service "LOG System". You can use regular expressions '
                              "which must match the beginning of the logfile name."
                              ),
                        ),
                    ),
                    (
                        "monitor_logfilelist",
                        Checkbox(
                            title=_("Monitoring of forwarded logfiles"),
                            label=_(
                                "Warn if list of forwarded logfiles changes"),
                            help=
                            _("If this option is enabled, the check monitors the list of forwarded "
                              "logfiles and will warn you if at any time a logfile is missing or exceeding "
                              "when compared to the initial list that was snapshotted during service detection. "
                              "Reinventorize this check in order to make it OK again."
                              ),
                        ),
                    ),
                    (
                        "expected_logfiles",
                        ListOf(
                            TextInput(),
                            title=_("List of expected logfiles"),
                            help=
                            _("When the monitoring of forwarded logfiles is enabled, the check verifies that "
                              "all of the logfiles listed here are reported by the monitored system."
                              ),
                        ),
                    ),
                    (
                        "logwatch_reclassify",
                        Checkbox(
                            title=
                            _("Reclassify messages before forwarding them to the EC"
                              ),
                            label=_("Apply logwatch patterns"),
                            help=
                            _("If this option is enabled, the logwatch lines are first reclassified by the logwatch "
                              "patterns before they are sent to the event console. If you reclassify specific lines to "
                              "IGNORE they are not forwarded to the event console. This takes the burden from the "
                              "event console to process the message itself through all of its rulesets. The reclassifcation "
                              "of each line takes into account from which logfile the message originates. So you can create "
                              "logwatch reclassification rules specifically designed for a logfile <i>access.log</i>, "
                              "which do not apply to other logfiles."),
                        ),
                    ),
                    (
                        "separate_checks",
                        Checkbox(
                            title=_(
                                "Create a separate check for each logfile"),
                            label=_("Separate check"),
                            help=
                            _("If this option is enabled, there will be one separate check for each logfile found during "
                              "the service discovery. This option also changes the behaviour for unknown logfiles. "
                              "The default logwatch check forwards all logfiles to the event console, even logfiles "
                              "which were not known during the service discovery. Creating one check per logfile changes "
                              "this behaviour so that any data from unknown logfiles is discarded."
                              ),
                        ),
                    ),
                ],
                optional_keys=[
                    "restrict_logfiles",
                    "expected_logfiles",
                    "logwatch_reclassify",
                    "separate_checks",
                ],
                ignored_keys=["service_level"],
            ),
        ],
        default_value="",
    )
Beispiel #6
0
def _valuespec_special_agents_mqtt() -> Dictionary:
    return Dictionary(
        title=_("MQTT broker statistics"),
        help=
        _("Connect to an MQTT broker to get statistics out of your instance. "
          "The information is fetched from the <tt>$SYS</tt> topic of the broker. The "
          "different brokers implement different topics as they are not standardized, "
          "means that not every service available with every broker. "
          "In multi-tentant, enterprise level cluster this agent may not be useful or "
          "probably only when directly connecting to single nodes, because the "
          "<tt>$SYS</tt> topic is node-specific."),
        elements=[
            (
                "username",
                TextInput(
                    title=_("Username"),
                    help=_("The username used for broker authentication."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            (
                "password",
                PasswordFromStore(
                    title=_("Password of the user"),
                    allow_empty=False,
                ),
            ),
            (
                "address",
                HostAddress(
                    title=_("Custom address"),
                    help=
                    _("When set, this address is used for connecting to the MQTT "
                      "broker. If not set, the special agent will use the primary "
                      "address of the host to connect to the MQTT broker."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            (
                "port",
                NetworkPort(
                    title=_("Port"),
                    default_value=1883,
                    help=_("The port that is used for the api call."),
                ),
            ),
            (
                "client-id",
                TextInput(
                    title=_("Client ID"),
                    help=_(
                        "Unique client ID used for the broker. Will be randomly "
                        "generated when not set."),
                    size=32,
                    allow_empty=False,
                ),
            ),
            (
                "protocol",
                DropdownChoice(
                    title=_("Protocol"),
                    choices=[
                        ("MQTTv31", "MQTTv31"),
                        ("MQTTv311", "MQTTv311"),
                        ("MQTTv5", "MQTTv5"),
                    ],
                    default_value="MQTTv311",
                ),
            ),
            (
                "instance-id",
                TextInput(
                    title=_("Instance ID"),
                    help=
                    _("Unique ID used to identify the instance on the host within Checkmk."
                      ),
                    size=32,
                    allow_empty=False,
                    default_value="broker",
                ),
            ),
        ],
        required_keys=[],
    )