Пример #1
0
    def _vs_activation(self):
        elements = [
            ("comment",
             TextAreaUnicode(
                 title=_("Comment (optional)"),
                 cols=40,
                 try_max_width=True,
                 rows=3,
                 help=
                 _("You can provide an optional comment for the current activation. "
                   "This can be useful to document the reason why the changes you "
                   "activate have been made."),
             )),
        ]  # type: List[DictionaryEntry]

        if self.has_foreign_changes() and config.user.may(
                "wato.activateforeign"):
            elements.append(("foreign",
                             Checkbox(
                                 title=_("Activate foreign changes"),
                                 label=_("Activate changes of other users"),
                             )))

        return Dictionary(
            title=self.title(),
            elements=elements,
            optional_keys=[],
            render="form_part",
        )
Пример #2
0
def _vs_annotation():
    extra_elements = []  # type: List[Tuple[str, ValueSpec]]
    if not cmk_version.is_raw_edition():
        extra_elements.append(("hide_from_report",
                               Checkbox(title=_("Hide annotation in report"))))

    return Dictionary(
        elements=[
            ("site", TextAscii(title=_("Site"))),
            ("host", TextUnicode(title=_("Hostname"))),
            ("service",
             Optional(TextUnicode(allow_empty=False),
                      sameline=True,
                      title=_("Service"))),
            ("from", AbsoluteDate(title=_("Start-Time"), include_time=True)),
            ("until", AbsoluteDate(title=_("End-Time"), include_time=True)),
            ("downtime",
             Optional(
                 DropdownChoice(choices=[
                     (True, _("regard as scheduled downtime")),
                     (False, _("do not regard as scheduled downtime")),
                 ], ),
                 title=_("Scheduled downtime"),
                 label=_("Reclassify downtime of this period"),
             )),
            ("text", TextAreaUnicode(title=_("Annotation"),
                                     allow_empty=False)),
        ] + extra_elements,
        title=_("Edit annotation"),
        optional_keys=[],
    )
Пример #3
0
 def _vs_key(self) -> Dictionary:
     return Dictionary(
         title=_("Properties"),
         elements=[
             (
                 "alias",
                 TextInput(
                     title=_("Description or comment"),
                     size=64,
                     allow_empty=False,
                 ),
             ),
             (
                 "passphrase",
                 Password(
                     title=_("Passphrase"),
                     help=self._passphrase_help(),
                     allow_empty=False,
                     is_stored_plain=False,
                 ),
             ),
             (
                 "key_file",
                 CascadingDropdown(
                     title=_("Key"),
                     choices=[
                         ("upload", _("Upload CRT/PEM File"), FileUpload()),
                         ("text", _("Paste PEM Content"), TextAreaUnicode()),
                     ],
                 ),
             ),
         ],
         optional_keys=False,
         render="form",
     )
Пример #4
0
 def parameters(cls, mode):
     return [(_("General Properties"), [
         (1.1, 'name',
          ID(
              title=_('Unique ID'),
              help=
              _("The ID will be used do identify this page in URLs. If this page has the "
                "same ID as a builtin page of the type <i>%s</i> then it will shadow the builtin one."
               ) % cls.phrase("title"),
          )),
         (1.2, 'title',
          TextUnicode(
              title=_('Title') + '<sup>*</sup>',
              size=50,
              allow_empty=False,
          )),
         (1.3, 'description',
          TextAreaUnicode(
              title=_('Description') + '<sup>*</sup>',
              help=_(
                  "The description is optional and can be used for explanations or documentation"
              ),
              rows=4,
              cols=50,
          )),
     ])]
Пример #5
0
def _vs_activation(title: str, has_foreign_changes: bool) -> Optional[Dictionary]:
    elements: List[DictionaryEntry] = []

    if config.wato_activate_changes_comment_mode != "disabled":
        is_optional = config.wato_activate_changes_comment_mode != "enforce"
        elements.append(
            ("comment",
             TextAreaUnicode(
                 title=_("Comment (optional)") if is_optional else _("Comment"),
                 cols=40,
                 try_max_width=True,
                 rows=1,
                 help=_("You can provide an optional comment for the current activation. "
                        "This can be useful to document the reason why the changes you "
                        "activate have been made."),
                 allow_empty=is_optional,
             )))

    if has_foreign_changes and config.user.may("wato.activateforeign"):
        elements.append(("foreign",
                         Checkbox(
                             title=_("Activate foreign changes"),
                             label=_("Activate changes of other users"),
                         )))

    if not elements:
        return None

    return Dictionary(
        title=title,
        elements=elements,
        optional_keys=[],
        render="form_part",
    )
Пример #6
0
 def _vs(self):
     return Dictionary(
         title=_("Read only mode"),
         optional_keys=False,
         render="form",
         elements=[
             (
                 "enabled",
                 Alternative(
                     title=_("Enabled"),
                     elements=[
                         FixedValue(
                             False,
                             title=_("Disabled "),
                             totext="Not enabled",
                         ),
                         FixedValue(
                             True,
                             title=_("Enabled permanently"),
                             totext=_("Enabled until disabling"),
                         ),
                         Tuple(
                             title=_("Enabled in time range"),
                             elements=[
                                 AbsoluteDate(
                                     title=_("Start"),
                                     include_time=True,
                                 ),
                                 AbsoluteDate(
                                     title=_("Until"),
                                     include_time=True,
                                     default_value=time.time() + 3600,
                                 ),
                             ],
                         ),
                     ],
                 ),
             ),
             (
                 "rw_users",
                 ListOf(
                     userdb.UserSelection(),
                     title=_("Can still edit"),
                     help=
                     _("Users listed here are still allowed to modify things."
                       ),
                     movable=False,
                     add_label=_("Add user"),
                     default_value=[user.id],
                 ),
             ),
             (
                 "message",
                 TextAreaUnicode(
                     title=_("Message"),
                     rows=3,
                 ),
             ),
         ],
     )
Пример #7
0
def _vs_notify():
    dest_choices: List[CascadingDropdownChoice] = [
        ('broadcast', _('Everybody (Broadcast)')),
        ('list', _('A list of specific users'),
         DualListChoice(
             choices=sorted([(uid, u.get('alias', uid))
                             for uid, u in config.multisite_users.items()],
                            key=lambda x: x[1].lower()),
             allow_empty=False,
         )),
        #('contactgroup', _('All members of a contact group')),
        ('online', _('All online users')),
    ]

    return Dictionary(
        elements=[
            ('text',
             TextAreaUnicode(
                 title=_('Text'),
                 help=_('Insert the text to be sent to all reciepents.'),
                 allow_empty=False,
                 empty_text=_('You need to provide a text.'),
                 cols=50,
                 rows=10)),
            ('dest',
             CascadingDropdown(
                 title=_('Send notification to'),
                 help=_(
                     'You can send the notification to a list of multiple users, which '
                     'can be choosen out of these predefined filters.'),
                 choices=dest_choices,
             )),
            ('methods',
             ListChoice(
                 title=_('How to notify'),
                 allow_empty=False,
                 choices=[(k, v['title'])
                          for k, v in _notify_methods().items()],
                 default_value=['popup'],
             )),
            ('valid_till',
             Optional(
                 AbsoluteDate(include_time=True, ),
                 title=_('Automatically invalidate notification'),
                 label=_('Enable automatic invalidation at'),
                 help=
                 _('It is possible to automatically delete messages when the '
                   'configured time is reached. This makes it possible to inform '
                   'users about a scheduled event but suppress the notification '
                   'after the event has happened.'),
             )),
        ],
        validate=_validate_msg,
        optional_keys=[],
    )
Пример #8
0
    def spec(self):
        elements = _vs_add_common_mail_elements([
            ("common_body",
             TextAreaUnicode(
                 title=_("Body head for both host and service notifications"),
                 rows=7,
                 cols=58,
                 monospaced=True,
                 default_value="""Host:     $HOSTNAME$
Alias:    $HOSTALIAS$
Address:  $HOSTADDRESS$
""",
             )),
            ("host_body",
             TextAreaUnicode(
                 title=_("Body tail for host notifications"),
                 rows=9,
                 cols=58,
                 monospaced=True,
                 default_value="""Event:    $EVENT_TXT$
Output:   $HOSTOUTPUT$
Perfdata: $HOSTPERFDATA$
$LONGHOSTOUTPUT$
""",
             )),
            ("service_body",
             TextAreaUnicode(
                 title=_("Body tail for service notifications"),
                 rows=11,
                 cols=58,
                 monospaced=True,
                 default_value="""Service:  $SERVICEDESC$
Event:    $EVENT_TXT$
Output:   $SERVICEOUTPUT$
Perfdata: $SERVICEPERFDATA$
$LONGSERVICEOUTPUT$
""",
             )),
        ])
        return Dictionary(
            title=_("Create notification with the following parameters"),
            elements=elements)
Пример #9
0
    def _parameter_elements(self):
        elements = _vs_add_common_mail_elements([
            ("elements",
             ListChoice(
                 title=_("Information to be displayed in the email body"),
                 choices=[
                     ("omdsite", _("OMD Site")),
                     ("hosttags", _("Tags of the Host")),
                     ("address", _("IP Address of Host")),
                     ("abstime", _("Absolute Time of Alert")),
                     ("reltime", _("Relative Time of Alert")),
                     ("longoutput", _("Additional Plugin Output")),
                     ("ack_author", _("Acknowledgement Author")),
                     ("ack_comment", _("Acknowledgement Comment")),
                     ("perfdata", _("Performance Data")),
                     ("graph", _("Performance Graphs")),
                     ("notesurl", _("Custom Host/Service Notes URL")),
                     ("context", _("Complete variable list (for testing)")),
                 ],
                 default_value=[
                     "perfdata", "graph", "abstime", "address", "longoutput"
                 ],
             )),
            ("insert_html_section",
             TextAreaUnicode(
                 title=_("Insert HTML section between body and table"),
                 default_value="<HTMLTAG>CONTENT</HTMLTAG>",
                 cols=40,
                 rows="auto",
             )),
            ("url_prefix",
             _get_url_prefix_specs(
                 "http://" + socket.gethostname() + "/" +
                 (config.omd_site() and config.omd_site() + "/" or "") +
                 "check_mk/", html.request.is_ssl_request and "automatic_https"
                 or "automatic_http")),
            ("no_floating_graphs",
             FixedValue(
                 True,
                 title=_("Display graphs among each other"),
                 totext=_("Graphs are shown among each other"),
                 help=
                 _("By default all multiple graphs in emails are displayed floating "
                   "nearby. You can enable this option to show the graphs among each "
                   "other."),
             )),
        ])

        if not cmk_version.is_raw_edition():
            import cmk.gui.cee.plugins.wato.syncsmtp  # pylint: disable=no-name-in-module
            elements += cmk.gui.cee.plugins.wato.syncsmtp.cee_html_mail_smtp_sync_option

        return elements
Пример #10
0
    def spec(self):
        return Dictionary(
            title=_("Create notification with the following parameters"),
            required_keys=[
                'password',
            ],
            elements=[
                ("password",
                 PasswordFromStore(
                     title=_(
                         "API Key to use. Depending on your opsgenie "
                         "subscription you can use global or team integration api "
                         "keys."),
                     allow_empty=False,
                 )),
                ("url",
                 TextAscii(
                     title=_("Domain (only used for european accounts)"),
                     help=_(
                         "If you have an european account, please set the "
                         "domain of your opsgenie. Specify an absolute URL like "
                         "https://my.app.eu.opsgenie.com "),
                     regex="^https://.*",
                     regex_error=_("The URL must begin with <tt>https</tt>."),
                     size=64,
                 )),
                ("owner",
                 TextUnicode(
                     title=_("Owner"),
                     help=("Sets the user of the alert. "
                           "Display name of the request owner."),
                     size=100,
                     allow_empty=False,
                 )),
                ("source",
                 TextUnicode(
                     title=_("Source"),
                     help=_("Source field of the alert. Default value is IP "
                            "address of the incoming request."),
                     size=16,
                 )),
                ('priority',
                 DropdownChoice(
                     title=_("Priority"),
                     choices=[
                         ('P1', _('P1 - Critical')),
                         ('P2', _('P2 - High')),
                         ('P3', _('P3 - Moderate')),
                         ('P4', _('P4 - Low')),
                         ('P5', _('P5 - Informational')),
                     ],
                     default_value="P3",
                 )),
                ("note_created",
                 TextUnicode(
                     title=_("Note while creating"),
                     help=
                     _("Additional note that will be added while creating the alert."
                       ),
                     default_value="Alert created by Check_MK",
                 )),
                ("note_closed",
                 TextUnicode(
                     title=_("Note while closing"),
                     help=
                     _("Additional note that will be added while closing the alert."
                       ),
                     default_value="Alert closed by Check_MK",
                 )),
                ("host_msg",
                 TextUnicode(
                     title=_("Description for host alerts"),
                     help=_(
                         "Description field of host alert that is generally "
                         "used to provide a detailed information about the "
                         "alert."),
                     default_value="Check_MK: $HOSTNAME$ - $HOSTSHORTSTATE$",
                     size=64,
                 )),
                ("svc_msg",
                 TextUnicode(
                     title=_("Description for service alerts"),
                     help=_(
                         "Description field of service alert that is generally "
                         "used to provide a detailed information about the "
                         "alert."),
                     default_value=
                     "Check_MK: $HOSTNAME$/$SERVICEDESC$ $SERVICESHORTSTATE$",
                     size=68,
                 )),
                ("host_desc",
                 TextAreaUnicode(title=_("Message for host alerts"),
                                 rows=7,
                                 cols=58,
                                 monospaced=True,
                                 default_value="""Host: $HOSTNAME$
Event:    $EVENT_TXT$
Output:   $HOSTOUTPUT$
Perfdata: $HOSTPERFDATA$
$LONGHOSTOUTPUT$
""")),
                ("svc_desc",
                 TextAreaUnicode(title=_("Message for service alerts"),
                                 rows=11,
                                 cols=58,
                                 monospaced=True,
                                 default_value="""Host: $HOSTNAME$
Service:  $SERVICEDESC$
Event:    $EVENT_TXT$
Output:   $SERVICEOUTPUT$
Perfdata: $SERVICEPERFDATA$
$LONGSERVICEOUTPUT$
""")),
                ("teams",
                 ListOfStrings(
                     title=_("Responsible teams"),
                     help=_(
                         "Team names which will be responsible for the alert. "
                         "If the API Key belongs to a team integration, "
                         "this field will be overwritten with the owner "
                         "team."),
                     allow_empty=False,
                     orientation="horizontal",
                 )),
                ("actions",
                 ListOfStrings(
                     title=_("Actions"),
                     help=_(
                         "Custom actions that will be available for the alert."
                     ),
                     allow_empty=False,
                     orientation="horizontal",
                 )),
                ("tags",
                 ListOfStrings(
                     title=_("Tags"),
                     help=_("Tags of the alert."),
                     allow_empty=False,
                     orientation="horizontal",
                 )),
                ("entity",
                 TextUnicode(
                     title=_("Entity"),
                     help=
                     _("Is used to specify which domain the alert is related to."
                       ),
                     allow_empty=False,
                     size=68,
                 )),
            ],
        )
Пример #11
0
    def spec(self):
        return Dictionary(
            title=_("Create notification with the following parameters"),
            required_keys=['url', 'username', 'password', 'caller'],
            elements=[
                ("url",
                 HTTPUrl(
                     title=_("Servicenow URL"),
                     help=
                     _("Configure your servicenow URL here (eg. https://myservicenow.com)."
                       ),
                     allow_empty=False,
                 )),
                ("proxy_url", HTTPProxyReference()),
                ("username",
                 TextAscii(
                     title=_("Username"),
                     size=40,
                     allow_empty=False,
                 )),
                ("password",
                 PasswordFromStore(
                     title=_("Password of the user"),
                     allow_empty=False,
                 )),
                ("caller",
                 TextAscii(
                     title=_("Caller ID"),
                     help=
                     _("Caller is the user on behalf of whom the incident is being reported "
                       "within servicenow. Please enter the name of the caller here."
                       ),
                 )),
                ("host_short_desc",
                 TextAscii(
                     title=_("Short description for host incidents"),
                     help=_(
                         "Text that should be set in field <tt>Short description</tt> "
                         "for host notifications."),
                     default_value="Check_MK: $HOSTNAME$ - $HOSTSHORTSTATE$",
                     size=64,
                 )),
                ("svc_short_desc",
                 TextAscii(
                     title=_("Short description for service incidents"),
                     help=_(
                         "Text that should be set in field <tt>Short description</tt> "
                         "for service notifications."),
                     default_value=
                     "Check_MK: $HOSTNAME$/$SERVICEDESC$ $SERVICESHORTSTATE$",
                     size=68,
                 )),
                ("host_desc",
                 TextAreaUnicode(
                     title=_("Description for host incidents"),
                     help=_(
                         "Text that should be set in field <tt>Description</tt> "
                         "for host notifications."),
                     rows=7,
                     cols=58,
                     monospaced=True,
                     default_value="""Host: $HOSTNAME$
Event:    $EVENT_TXT$
Output:   $HOSTOUTPUT$
Perfdata: $HOSTPERFDATA$
$LONGHOSTOUTPUT$
""")),
                ("svc_desc",
                 TextAreaUnicode(
                     title=_("Description for service incidents"),
                     help=_(
                         "Text that should be set in field <tt>Description</tt> "
                         "for service notifications."),
                     rows=11,
                     cols=58,
                     monospaced=True,
                     default_value="""Host: $HOSTNAME$
Service:  $SERVICEDESC$
Event:    $EVENT_TXT$
Output:   $SERVICEOUTPUT$
Perfdata: $SERVICEPERFDATA$
$LONGSERVICEOUTPUT$
""")),
                ("urgency",
                 DropdownChoice(
                     title=_("Urgency"),
                     help=
                     _("See <a href=\"https://docs.servicenow.com/bundle/"
                       "helsinki-it-service-management/page/product/incident-management/"
                       "reference/r_PrioritizationOfIncidents.html\" target=\"_blank\">"
                       "ServiceNow Incident</a> for more information."),
                     choices=[
                         ("low", _("Low")),
                         ("medium", _("Medium")),
                         ("high", _("High")),
                     ],
                     default_value="low",
                 )),
                ("impact",
                 DropdownChoice(
                     title=_("Impact"),
                     help=
                     _("See <a href=\"https://docs.servicenow.com/bundle/"
                       "helsinki-it-service-management/page/product/incident-management/"
                       "reference/r_PrioritizationOfIncidents.html\" target=\"_blank\">"
                       "ServiceNow Incident</a> for more information."),
                     choices=[
                         ("low", _("Low")),
                         ("medium", _("Medium")),
                         ("high", _("High")),
                     ],
                     default_value="low",
                 )),
                ("ack_state",
                 Dictionary(
                     title=
                     _("Settings for incident state in case of acknowledgement"
                       ),
                     help=
                     _("Here you can define the state of the incident in case of an "
                       "acknowledgement of the affected host or service problem."
                       ),
                     elements=[
                         ("start",
                          DropdownChoice(
                              title=_(
                                  "State of incident if acknowledgement is set"
                              ),
                              help=
                              _("Here you can define the state of the incident in case of an "
                                "acknowledgement of the host or service problem."
                                ),
                              choices=[
                                  ("none", _("Don't change state")),
                                  ("new", _("New")),
                                  ("progress", _("In Progress")),
                                  ("hold", _("On Hold")),
                                  ("resolved", _("Resolved")),
                                  ("closed", _("Closed")),
                                  ("canceled", _("Canceled")),
                              ],
                              default_value="none",
                          )),
                     ],
                 )),
                ("dt_state",
                 Dictionary(
                     title=_(
                         "Settings for incident state in case of downtime"),
                     help=_(
                         "Here you can define the state of the incident in case of a "
                         "downtime of the affected host or service."),
                     elements=[
                         ("start",
                          DropdownChoice(
                              title=_("State of incident if downtime is set"),
                              help=
                              _("Here you can define the state of the incident in case of an "
                                "acknowledgement of the host or service problem."
                                ),
                              choices=[
                                  ("none", _("Don't change state")),
                                  ("new", _("New")),
                                  ("progress", _("In Progress")),
                                  ("hold", _("On Hold")),
                                  ("resolved", _("Resolved")),
                                  ("closed", _("Closed")),
                                  ("canceled", _("Canceled")),
                              ],
                              default_value="none",
                          )),
                         ("end",
                          DropdownChoice(
                              title=_("State of incident if downtime expires"),
                              help=
                              _("Here you can define the state of the incident in case of an "
                                "ending acknowledgement of the host or service problem."
                                ),
                              choices=[
                                  ("none", _("Don't change state")),
                                  ("new", _("New")),
                                  ("progress", _("In Progress")),
                                  ("hold", _("On Hold")),
                                  ("resolved", _("Resolved")),
                                  ("closed", _("Closed")),
                                  ("canceled", _("Canceled")),
                              ],
                              default_value="none",
                          )),
                     ],
                 )),
                ("timeout",
                 TextAscii(
                     title=_(
                         "Set optional timeout for connections to servicenow"),
                     help=_(
                         "Here you can configure timeout settings in seconds."
                     ),
                     default_value=10,
                     size=3)),
            ],
        )
Пример #12
0
def _vs_notify():
    dest_choices: List[CascadingDropdownChoice] = [
        ("broadcast", _("Everybody (Broadcast)")),
        (
            "list",
            _("A list of specific users"),
            DualListChoice(
                choices=sorted(
                    [(uid, u.get("alias", uid)) for uid, u in config.multisite_users.items()],
                    key=lambda x: x[1].lower(),
                ),
                allow_empty=False,
            ),
        ),
        # ('contactgroup', _('All members of a contact group')),
        ("online", _("All online users")),
    ]

    return Dictionary(
        elements=[
            (
                "text",
                TextAreaUnicode(
                    title=_("Text"),
                    help=_("Insert the text to be sent to all reciepents."),
                    allow_empty=False,
                    empty_text=_("You need to provide a text."),
                    cols=50,
                    rows=10,
                ),
            ),
            (
                "dest",
                CascadingDropdown(
                    title=_("Send notification to"),
                    help=_(
                        "You can send the notification to a list of multiple users, which "
                        "can be choosen out of these predefined filters."
                    ),
                    choices=dest_choices,
                ),
            ),
            (
                "methods",
                ListChoice(
                    title=_("How to notify"),
                    allow_empty=False,
                    choices=[(k, v["title"]) for k, v in _notify_methods().items()],
                    default_value=["popup"],
                ),
            ),
            (
                "valid_till",
                Optional(
                    AbsoluteDate(
                        include_time=True,
                    ),
                    title=_("Automatically invalidate notification"),
                    label=_("Enable automatic invalidation at"),
                    help=_(
                        "It is possible to automatically delete messages when the "
                        "configured time is reached. This makes it possible to inform "
                        "users about a scheduled event but suppress the notification "
                        "after the event has happened."
                    ),
                ),
            ),
        ],
        validate=_validate_msg,
        optional_keys=[],
    )
    def spec(self):
        return Dictionary(
            title=_("Create notification with the following parameters"),
            optional_keys=[
                "api_url", "host_desc", "svc_desc", "host_msg", "svc_msg",
                "ignore_graphs"
            ],
            required_keys=["bot_token"],
            elements=[
                ("bot_token",
                 PasswordFromStore(
                     title=_("BOT Token"),
                     help=
                     _("You need to provide a valid BOT token to be able to send notifications using Telegram. "
                       "For information see <a href=\"https://core.telegram.org/bots#create-a-new-bot\" "
                       "target=\"_blank\">Bots: An introduction for developers</a>"
                       ),
                     size=58,
                     allow_empty=False,
                 )),
                ("api_url",
                 TextAscii(
                     title=_("API Endpoint"),
                     help=
                     _("Telegram API endpoint URL. Do <tt>not</tt> change unless you know what you are doing."
                       ),
                     default_value="https://api.telegram.org",
                 )),
                ("host_desc",
                 TextUnicode(
                     title=_("Description for host alerts"),
                     help=_(
                         "Description field of host alert that is generally "
                         "used to provide a detailed information about the "
                         "alert."),
                     default_value="Check_MK: $HOSTNAME$ - $EVENT_TXT$",
                     size=64,
                 )),
                ("svc_desc",
                 TextUnicode(
                     title=_("Description for service alerts"),
                     help=_(
                         "Description field of service alert that is generally "
                         "used to provide a detailed information about the "
                         "alert."),
                     default_value=
                     "Check_MK: $HOSTNAME$/$SERVICEDESC$ $EVENT_TXT$",
                     size=68,
                 )),
                ("host_msg",
                 TextAreaUnicode(title=_("Message for host alerts"),
                                 rows=8,
                                 cols=58,
                                 monospaced=True,
                                 default_value="""```
Host:    $HOSTNAME$
Alias:   $HOSTALIAS$
Address: $HOSTADDRESS$
Event:   $EVENT_TXT$
Output:  $HOSTOUTPUT$
```""")),
                ("svc_msg",
                 TextAreaUnicode(title=_("Message for service alerts"),
                                 rows=11,
                                 cols=58,
                                 monospaced=True,
                                 default_value="""```
Host:     $HOSTNAME$
Alias:    $HOSTALIAS$
Address:  $HOSTADDRESS$
Service:  $SERVICEDESC$
Event:    $EVENT_TXT$
Output:   $SERVICEOUTPUT$
```""")),
                ("ignore_graphs",
                 FixedValue(
                     False,
                     title=_(
                         "Disable attaching graphs for PROBLEM and CUSTOM types"
                     ),
                     totext=_(
                         "Disable attaching graphs for PROBLEM and CUSTOM types"
                     ),
                     help=
                     _("Do not attach graphs of the host or service for PROBLEM and CUSTOM notification types."
                       ),
                 )),
            ])

        return Dictionary(
            title=_("Create notification with the following parameters"),
            elements=elements)
Пример #14
0
    def spec(self):
        return Dictionary(
            title=_("Create notification with the following parameters"),
            elements=[
                ("from",
                 EmailAddress(
                     title=_("From: Address"),
                     size=40,
                     allow_empty=False,
                 )),
                ("host_subject",
                 TextUnicode(
                     title=_("Subject for host notifications"),
                     help=_(
                         "Here you are allowed to use all macros that are defined in the "
                         "notification context."),
                     default_value="Check_MK: $HOSTNAME$ - $EVENT_TXT$",
                     size=64,
                 )),
                ("service_subject",
                 TextUnicode(
                     title=_("Subject for service notifications"),
                     help=_(
                         "Here you are allowed to use all macros that are defined in the "
                         "notification context."),
                     default_value=
                     "Check_MK: $HOSTNAME$/$SERVICEDESC$ $EVENT_TXT$",
                     size=64,
                 )),
                ("common_body",
                 TextAreaUnicode(
                     title=_(
                         "Body head for both host and service notifications"),
                     rows=7,
                     cols=58,
                     monospaced=True,
                     default_value="""Host:     $HOSTNAME$
Alias:    $HOSTALIAS$
Address:  $HOSTADDRESS$
""",
                 )),
                ("host_body",
                 TextAreaUnicode(
                     title=_("Body tail for host notifications"),
                     rows=9,
                     cols=58,
                     monospaced=True,
                     default_value="""Event:    $EVENT_TXT$
Output:   $HOSTOUTPUT$
Perfdata: $HOSTPERFDATA$
$LONGHOSTOUTPUT$
""",
                 )),
                ("service_body",
                 TextAreaUnicode(
                     title=_("Body tail for service notifications"),
                     rows=11,
                     cols=58,
                     monospaced=True,
                     default_value="""Service:  $SERVICEDESC$
Event:    $EVENT_TXT$
Output:   $SERVICEOUTPUT$
Perfdata: $SERVICEPERFDATA$
$LONGSERVICEOUTPUT$
""",
                 )),
            ],
        )
Пример #15
0
    def _parameter_elements(self):
        elements = _vs_add_common_mail_elements([
            ("elements",
             ListChoice(
                 title=_("Information to be displayed in the email body"),
                 choices=[
                     ("omdsite", _("OMD Site")),
                     ("hosttags", _("Tags of the Host")),
                     ("address", _("IP Address of Host")),
                     ("abstime", _("Absolute Time of Alert")),
                     ("reltime", _("Relative Time of Alert")),
                     ("longoutput", _("Additional Plugin Output")),
                     ("ack_author", _("Acknowledgement Author")),
                     ("ack_comment", _("Acknowledgement Comment")),
                     ("perfdata", _("Performance Data")),
                     ("graph", _("Performance Graphs")),
                     ("notesurl", _("Custom Host/Service Notes URL")),
                     ("context", _("Complete variable list (for testing)")),
                 ],
                 default_value=[
                     "perfdata", "graph", "abstime", "address", "longoutput"
                 ],
             )),
            ("insert_html_section",
             TextAreaUnicode(
                 title=_("Insert HTML section between body and table"),
                 default_value="<HTMLTAG>CONTENT</HTMLTAG>",
                 cols=40,
                 rows="auto",
             )),
            ("url_prefix",
             Transform(CascadingDropdown(
                 title=_("URL prefix for links to Check_MK"),
                 help=
                 _("If you use <b>Automatic HTTP/s</b> the URL prefix for "
                   "host and service links within the notification mail "
                   "is filled automatically. "
                   "If you specify an URL prefix here, then several parts of the "
                   "email body are armed with hyperlinks to your Check_MK GUI. In both cases "
                   "the recipient of the email can directly visit the host or "
                   "service in question in Check_MK. Specify an absolute URL including "
                   "the <tt>.../check_mk/</tt>"),
                 choices=[
                     ("automatic_http", _("Automatic HTTP")),
                     ("automatic_https", _("Automatic HTTPs")),
                     ("manual", _("Specify URL prefix"),
                      TextAscii(
                          regex="^(http|https)://.*/check_mk/$",
                          regex_error=_(
                              "The URL must begin with <tt>http</tt> or "
                              "<tt>https</tt> and end with <tt>/check_mk/</tt>."
                          ),
                          size=64,
                          default_value="http://" + socket.gethostname() +
                          "/" + (config.omd_site() and config.omd_site() + "/"
                                 or "") + "check_mk/",
                      )),
                 ],
                 default_value=html.request.is_ssl_request
                 and "automatic_https" or "automatic_http",
             ),
                       forth=transform_forth_html_mail_url_prefix,
                       back=transform_back_html_mail_url_prefix)),
            ("no_floating_graphs",
             FixedValue(
                 True,
                 title=_("Display graphs among each other"),
                 totext=_("Graphs are shown among each other"),
                 help=
                 _("By default all multiple graphs in emails are displayed floating "
                   "nearby. You can enable this option to show the graphs among each "
                   "other."),
             )),
        ])

        if not cmk.is_raw_edition():
            elements += cmk.gui.cee.plugins.wato.syncsmtp.cee_html_mail_smtp_sync_option  # pylint: disable=no-member

        return elements
Пример #16
0
def _valuespec_active_checks_sql() -> Dictionary:
    return Dictionary(
        title=_("Check SQL Database"),
        help=
        _("This check connects to the specified database, sends a custom SQL-statement "
          "or starts a procedure, and checks that the result has a defined format "
          "containing three columns, a number, a text, and performance data. Upper or "
          "lower levels may be defined here.  If they are not defined the number is taken "
          "as the state of the check.  If a procedure is used, input parameters of the "
          "procedures may by given as comma separated list. "
          "This check uses the active check <tt>check_sql</tt>."),
        optional_keys=[
            "levels", "levels_low", "perfdata", "port", "procedure", "text",
            "host"
        ],
        elements=[
            (
                "description",
                TextInput(
                    title=_("Service Description"),
                    help=_("The name of this active service to be displayed."),
                    allow_empty=False,
                ),
            ),
            (
                "dbms",
                DropdownChoice(
                    title=_("Type of Database"),
                    choices=[
                        ("mysql", _("MySQL")),
                        ("postgres", _("PostgreSQL")),
                        ("mssql", _("MSSQL")),
                        ("oracle", _("Oracle")),
                        ("db2", _("DB2")),
                    ],
                    default_value="postgres",
                ),
            ),
            (
                "port",
                Integer(
                    title=_("Database Port"),
                    help=_("The port the DBMS listens to"),
                ),
            ),
            (
                "name",
                TextInput(
                    title=_("Database Name"),
                    help=_("The name of the database on the DBMS"),
                    allow_empty=False,
                ),
            ),
            (
                "user",
                TextInput(
                    title=_("Database User"),
                    help=_("The username used to connect to the database"),
                    allow_empty=False,
                ),
            ),
            (
                "password",
                IndividualOrStoredPassword(
                    title=_("Database Password"),
                    help=_("The password used to connect to the database"),
                    allow_empty=False,
                ),
            ),
            (
                "sql",
                Transform(
                    valuespec=TextAreaUnicode(
                        title=_("Query or SQL statement"),
                        help=
                        _("The SQL-statement or procedure name which is executed on the DBMS. It must return "
                          "a result table with one row and at least two columns. The first column must be "
                          "an integer and is interpreted as the state (0 is OK, 1 is WARN, 2 is CRIT). "
                          "Alternatively the first column can be interpreted as number value and you can "
                          "define levels for this number. The "
                          "second column is used as check output. The third column is optional and can "
                          "contain performance data."),
                        allow_empty=False,
                        monospaced=True,
                    ),
                    # Former Alternative(Text, Alternative(FileUpload, Text)) based implementation
                    # would save a string or a tuple with a string or a binary array as third element
                    # which would then be turned into a string.
                    # Just make all this a string
                    forth=lambda old_val: [
                        elem.decode() if isinstance(elem, bytes) else str(elem)
                        for elem in
                        ((old_val[-1]
                          if isinstance(old_val, tuple) else old_val), )
                    ][0],
                ),
            ),
            (
                "procedure",
                Dictionary(
                    optional_keys=["input"],
                    title=_("Use procedure call instead of SQL statement"),
                    help=_(
                        "If you activate this option, a name of a stored "
                        "procedure is used instead of an SQL statement. "
                        "The procedure should return one output variable, "
                        "which is evaluated in the check. If input parameters "
                        "are required, they may be specified below."),
                    elements=[
                        (
                            "useprocs",
                            FixedValue(
                                value=True,
                                totext=_("procedure call is used"),
                            ),
                        ),
                        (
                            "input",
                            TextInput(
                                title=_("Input Parameters"),
                                allow_empty=True,
                                help=
                                _("Input parameters, if required by the database procedure. "
                                  "If several parameters are required, use commas to separate them."
                                  ),
                            ),
                        ),
                    ],
                ),
            ),
            (
                "levels",
                Tuple(
                    title=_("Upper levels for first output item"),
                    elements=[
                        Float(title=_("Warning at")),
                        Float(title=_("Critical at"))
                    ],
                ),
            ),
            (
                "levels_low",
                Tuple(
                    title=_("Lower levels for first output item"),
                    elements=[
                        Float(title=_("Warning below")),
                        Float(title=_("Critical below"))
                    ],
                ),
            ),
            (
                "perfdata",
                Transform(
                    TextInput(
                        title=_("Performance Data"),
                        help=
                        _("Store output value into RRD database in a metric with this name."
                          ),
                        default_value="performance_data",
                        allow_empty=False,
                    ),
                    forth=transform_check_sql_perfdata,
                ),
            ),
            (
                "text",
                TextInput(
                    title=_("Prefix text"),
                    help=_("Additional text prefixed to the output"),
                    allow_empty=False,
                ),
            ),
            (
                "host",
                TextInput(
                    title=_("DNS hostname or IP address"),
                    help=
                    _("This defaults to the host for which the active check is configured."
                      ),
                ),
            ),
        ],
    )