示例#1
0
def _valuespec_sap_value_groups():
    return ListOf(
        Tuple(
            help=_("This defines one value grouping pattern"),
            show_titles=True,
            orientation="horizontal",
            elements=[
                TextAscii(title=_("Name of group"), ),
                Tuple(
                    show_titles=True,
                    orientation="vertical",
                    elements=[
                        RegExpUnicode(
                            title=_("Include Pattern"),
                            mode=RegExp.prefix,
                        ),
                        RegExpUnicode(
                            title=_("Exclude Pattern"),
                            mode=RegExp.prefix,
                        )
                    ],
                ),
            ],
        ),
        add_label=_("Add pattern group"),
        title=_('SAP Value Grouping Patterns'),
        help=
        _('The check <tt>sap.value</tt> normally creates one service for each SAP value. '
          'By defining grouping patterns, you can switch to the check <tt>sap.value_groups</tt>. '
          'That check monitors a list of SAP values at once.'),
    )
示例#2
0
def _parameter_valuespec_filestats():
    return Dictionary(
        elements=file_size_age_elements + [
            ("mincount",
             Tuple(
                 title=_("Minimal file count"),
                 elements=[
                     Integer(title=_("Warning if below")),
                     Integer(title=_("Critical if below")),
                 ],
             )),
            ("maxcount",
             Tuple(
                 title=_("Maximal file count"),
                 elements=[
                     Integer(title=_("Warning if above")),
                     Integer(title=_("Critical if above")),
                 ],
             )),
            (
                "show_all_files",
                Checkbox(
                    title=_("Show files in service details"),
                    label=("Show files"),
                    help=
                    _("Display all files that have reached a WARN or a CRIT status in the "
                      "service details. Note: displaying the files leads to a performance loss "
                      "for large numbers of files within the file group. Please enable this feature "
                      "only if it is needed."),
                ),
            ),
            (
                "additional_rules",
                ListOf(
                    Tuple(elements=[
                        RegExpUnicode(title=_("Filename/- expression"),
                                      mode="case_sensitive"),
                        Dictionary(elements=file_size_age_elements),
                    ], ),
                    title=_("Additional rules for outliers"),
                    help=
                    _("This feature is to apply different rules to files that are "
                      "inconsistent with the files expected in this file group. "
                      "This means that the rules set for the file group are overwritten. "
                      "You can specify a filename or a regular expresion, and additional "
                      "rules that are applied to the matching files. In case of multiple "
                      "matching rules, the first matching rule is applied. "
                      "Note: this feature is intended for outliers, and is therefore not "
                      "suitable to configure subgroups. "),
                ),
            ),
        ],
        help=
        _("Here you can impose various levels on the results reported by the"
          " mk_filstats plugin. Note that some levels only apply to a matching"
          " output format (e.g. max/min count levels are not applied if only the"
          " smallest, largest, oldest and newest file is reported). In order to"
          " receive the required data, you must configure the plugin mk_filestats."
          ),
    )
示例#3
0
 def _vs_host_renaming(self):
     return CascadingDropdown(
         orientation="horizontal",
         choices=[
             ("case", _("Case translation"),
              DropdownChoice(choices=[
                  ("upper", _("Convert hostnames to upper case")),
                  ("lower", _("Convert hostnames to lower case")),
              ])),
             ("add_suffix", _("Add Suffix"), Hostname()),
             ("add_prefix", _("Add Prefix"), Hostname()),
             ("drop_domain", _("Drop Domain Suffix")),
             ("reverse_dns",
              _("Convert IP addresses of hosts into host their DNS names")),
             ("regex", _("Regular expression substitution"),
              Tuple(help=_(
                  "Please specify a regular expression in the first field. This expression should at "
                  "least contain one subexpression exclosed in brackets - for example <tt>vm_(.*)_prod</tt>. "
                  "In the second field you specify the translated host name and can refer to the first matched "
                  "group with <tt>\\1</tt>, the second with <tt>\\2</tt> and so on, for example <tt>\\1.example.org</tt>"
              ),
                    elements=[
                        RegExpUnicode(
                            title=
                            _("Regular expression for the beginning of the host name"
                              ),
                            help=
                            _("Must contain at least one subgroup <tt>(...)</tt>"
                              ),
                            mingroups=0,
                            maxgroups=9,
                            size=30,
                            allow_empty=False,
                            mode=RegExpUnicode.prefix,
                        ),
                        TextUnicode(
                            title=_("Replacement"),
                            help=
                            _("Use <tt>\\1</tt>, <tt>\\2</tt> etc. to replace matched subgroups, <tt>\\0</tt> to insert to original host name"
                              ),
                            size=30,
                            allow_empty=False,
                        )
                    ])),
             ("explicit", _("Explicit renaming"),
              Tuple(orientation="horizontal",
                    elements=[
                        Hostname(title=_("current host name"),
                                 allow_empty=False),
                        Hostname(title=_("new host name"),
                                 allow_empty=False),
                    ])),
         ])
示例#4
0
 def parameter_valuespec(self):
     return Dictionary(elements=[
         ("ignored",
          ListOf(
              RegExpUnicode(
                  title=_("Pattern (Regex)"),
                  size=40,
                  mode=RegExp.infix,
              ),
              title=_(
                  "Exclude services by matching provided regex patterns"),
              help=
              _('<p>You can optionally define one or multiple regular expressions'
                'where a matching case will result in the exclusion of the concerning service(s).'
                'This allows to ignore services which are known to fail beforehand. </p>'
                ),
              add_label=_("Add pattern"),
          )),
         ("states",
          Dictionary(
              title=_("Map systemd states to monitoring states"),
              elements=[
                  ("active",
                   MonitoringState(
                       title=_("Monitoring state if service is active"),
                       default_value=0,
                   )),
              ],
          )),
         ("states_default",
          MonitoringState(
              title=_("Monitoring state for any other service state"),
              default_value=2,
          )),
         ("else",
          MonitoringState(
              title=
              _("Monitoring state if a monitored service is not found at all."
                ),
              default_value=2,
          )),
     ], )
示例#5
0
def _parameter_valuespec_filestats():
    return Dictionary(
        elements=file_size_age_elements + [
            ("mincount",
             Tuple(
                 title=_("Minimal file count"),
                 elements=[
                     Integer(title=_("Warning if below")),
                     Integer(title=_("Critical if below")),
                 ],
             )),
            ("maxcount",
             Tuple(
                 title=_("Maximal file count"),
                 elements=[
                     Integer(title=_("Warning if above")),
                     Integer(title=_("Critical if above")),
                 ],
             )),
            ("show_all_files",
             Checkbox(title=_("Show all files in long output"), label=("Show files"))),
            ("additional_rules",
             ListOf(Tuple(elements=[
                 RegExpUnicode(title=_("Filename/- expression"), mode="case_sensitive"),
                 Dictionary(elements=file_size_age_elements),
             ],),
                    title=_("Additional rules for files"),
                    help=_("You can specify a filename or a regular expresion, and additional "
                           "rules that are applied to the matching files. This means that the "
                           "rules set for the whole file group are overwritten for those files. "
                           "Note that the order in which you specify the rules matters: "
                           "in case of multiple matching rules, the first matching rule is "
                           "applied."))),
        ],
        help=_("Here you can impose various levels on the results reported by the"
               " mk_filstats plugin. Note that some levels only apply to a matching"
               " output format (e.g. max/min count levels are not applied if only the"
               " smallest, largest, oldest and newest file is reported). In order to"
               " receive the required data, you must configure the plugin mk_filestats."),
    )
示例#6
0
def _parameter_valuespec_systemd_services():
    return Dictionary(elements=[
        ("ignored",
         ListOf(
             RegExpUnicode(
                 title=_("Pattern (Regex)"),
                 size=40,
                 mode=RegExp.infix,
             ),
             title=_("Exclude services matching provided regex patterns"),
             help=
             _('<p>You can optionally define one or multiple regular expressions '
               'where a matching case will result in the exclusion of the concerning service(s). '
               'This allows to ignore services which are known to fail beforehand. </p>'
               ),
             add_label=_("Add pattern"),
         )),
        ("states",
         Dictionary(
             title=_("Map systemd states to monitoring states"),
             elements=[
                 ("active",
                  MonitoringState(
                      title=_("Monitoring state if service is active"),
                      default_value=0,
                  )),
                 ("inactive",
                  MonitoringState(
                      title=_("Monitoring state if service is inactive"),
                      default_value=0,
                  )),
                 ("failed",
                  MonitoringState(
                      title=_("Monitoring state if service is failed"),
                      default_value=2,
                  )),
             ],
         )),
        ("states_default",
         MonitoringState(
             title=_("Monitoring state for any other service state"),
             default_value=2,
         )),
        ("else",
         MonitoringState(
             title=_(
                 "Monitoring state if a monitored service is not found at all."
             ),
             default_value=2,
         )),
        ("activating_levels",
         Tuple(
             title=_(
                 "Define a tolerating time period for activating services"),
             help=
             _("Choose time levels (in seconds) for which a service is allowed to be in an 'activating' state"
               ),
             elements=[
                 Integer(title=_("Warning at"),
                         unit=_("seconds"),
                         default_value=30),
                 Integer(title=_("Critical at"),
                         unit=_("seconds"),
                         default_value=60),
             ])),
    ], )
示例#7
0
def _valuespec_logwatch_rules():
    return Transform(
        Dictionary(
            title=_('Logwatch Patterns'),
            elements=[
                ("reclassify_patterns",
                 ListOf(
                     Tuple(help=_("This defines one logfile pattern rule"),
                           show_titles=True,
                           orientation="horizontal",
                           elements=[
                               DropdownChoice(
                                   title=_("State"),
                                   choices=[
                                       ('C', _('CRITICAL')),
                                       ('W', _('WARNING')),
                                       ('O', _('OK')),
                                       ('I', _('IGNORE')),
                                   ],
                               ),
                               RegExpUnicode(
                                   title=_("Pattern (Regex)"),
                                   size=40,
                                   mode=RegExp.infix,
                               ),
                               TextUnicode(
                                   title=_("Comment"),
                                   size=40,
                               ),
                           ]),
                     title=_("Reclassify state matching regex pattern"),
                     help=
                     _('<p>You can define one or several patterns (regular expressions) in each logfile pattern rule. '
                       'These patterns are applied to the selected logfiles to reclassify the '
                       'matching log messages. The first pattern which matches a line will '
                       'be used for reclassifying a message. You can use the '
                       '<a href="wato.py?mode=pattern_editor">Logfile Pattern Analyzer</a> '
                       'to test the rules you defined here.</p>'
                       '<p>Select "Ignore" as state to get the matching logs deleted. Other states will keep the '
                       'log entries but reclassify the state of them.</p>'),
                     add_label=_("Add pattern"),
                 )),
                ("reclassify_states",
                 Dictionary(
                     title=_("Reclassify complete state"),
                     help=_(
                         "This setting allows you to convert all incoming states to another state. "
                         "The option is applied before the state conversion via regexes. So the regex values can "
                         "modify the state even further."),
                     elements=[
                         ("c_to",
                          DropdownChoice(
                              title=_("Change CRITICAL State to"),
                              choices=[
                                  ('C', _('CRITICAL')),
                                  ('W', _('WARNING')),
                                  ('O', _('OK')),
                                  ('I', _('IGNORE')),
                                  ('.', _('Context Info')),
                              ],
                              default_value="C",
                          )),
                         ("w_to",
                          DropdownChoice(
                              title=_("Change WARNING State to"),
                              choices=[
                                  ('C', _('CRITICAL')),
                                  ('W', _('WARNING')),
                                  ('O', _('OK')),
                                  ('I', _('IGNORE')),
                                  ('.', _('Context Info')),
                              ],
                              default_value="W",
                          )),
                         ("o_to",
                          DropdownChoice(
                              title=_("Change OK State to"),
                              choices=[
                                  ('C', _('CRITICAL')),
                                  ('W', _('WARNING')),
                                  ('O', _('OK')),
                                  ('I', _('IGNORE')),
                                  ('.', _('Context Info')),
                              ],
                              default_value="O",
                          )),
                         ("._to",
                          DropdownChoice(
                              title=_("Change Context Info to"),
                              choices=[
                                  ('C', _('CRITICAL')),
                                  ('W', _('WARNING')),
                                  ('O', _('OK')),
                                  ('I', _('IGNORE')),
                                  ('.', _('Context Info')),
                              ],
                              default_value=".",
                          )),
                     ],
                     optional_keys=False,
                 )),
            ],
            optional_keys=["reclassify_states"],
            ignored_keys=["pre_comp_group_patterns", "group_patterns"],
        ),
        forth=lambda x: isinstance(x, dict) and x or {"reclassify_patterns": x},
    )
示例#8
0
def _parameter_valuespec_fileinfo_groups():
    return Dictionary(
        elements=file_size_age_elements + [
            ("minsize",
             Tuple(
                 title=_("Minimal size"),
                 elements=[
                     Filesize(title=_("Warning if below")),
                     Filesize(title=_("Critical if below")),
                 ],
             )),
            ("maxsize",
             Tuple(
                 title=_("Maximal size"),
                 elements=[
                     Filesize(title=_("Warning if above")),
                     Filesize(title=_("Critical if above")),
                 ],
             )),
            ("mincount",
             Tuple(
                 title=_("Minimal file count"),
                 elements=[
                     Integer(title=_("Warning if below")),
                     Integer(title=_("Critical if below")),
                 ],
             )),
            ("maxcount",
             Tuple(
                 title=_("Maximal file count"),
                 elements=[
                     Integer(title=_("Warning if above")),
                     Integer(title=_("Critical if above")),
                 ],
             )),
            ("timeofday",
             ListOfTimeRanges(
                 title=_("Only check during the following times of the day"),
                 help=_("Outside these ranges the check will always be OK"),
             )),
            ("conjunctions",
             ListOf(
                 Tuple(elements=[
                     MonitoringState(title=_("Monitoring state"),
                                     default_value=2),
                     ListOf(
                         CascadingDropdown(
                             orientation="horizontal",
                             choices=[
                                 ("count", _("File count at"), Integer()),
                                 ("count_lower", _("File count below"),
                                  Integer()),
                                 ("size", _("File size at"), Filesize()),
                                 ("size_lower", _("File size below"),
                                  Filesize()),
                                 ("largest_size", _("Largest file size at"),
                                  Filesize()),
                                 ("largest_size_lower",
                                  _("Largest file size below"), Filesize()),
                                 ("smallest_size", _("Smallest file size at"),
                                  Filesize()),
                                 ("smallest_size_lower",
                                  _("Smallest file size below"), Filesize()),
                                 ("oldest_age", _("Oldest file age at"),
                                  Age()),
                                 ("oldest_age_lower",
                                  _("Oldest file age below"), Age()),
                                 ("newest_age", _("Newest file age at"),
                                  Age()),
                                 ("newest_age_lower",
                                  _("Newest file age below"), Age()),
                             ],
                         ),
                         magic="@#@#",
                     )
                 ], ),
                 title=_("Level conjunctions"),
                 help=
                 _("In order to check dependent file group statistics you can configure "
                   "conjunctions of single levels now. A conjunction consists of a monitoring state "
                   "and any number of upper or lower levels. If all of the configured levels within "
                   "a conjunction are reached then the related state is reported."
                   ),
             )),
            ("additional_rules",
             ListOf(
                 Tuple(elements=[
                     RegExpUnicode(title=_("Filename/- expression"),
                                   mode="case_sensitive"),
                     Dictionary(elements=file_size_age_elements),
                 ], ),
                 title=_("Additional rules for files"),
                 help=
                 _("You can specify a filename or a regular expresion, and additional "
                   "rules that are applied to the matching files. This means that the "
                   "rules set for the whole file group are overwritten for those files. "
                   "Note that the order in which you specify the rules matters: "
                   "in case of multiple matching rules, the first matching rule is "
                   "applied."),
             )),
        ],
        ignored_keys=["precompiled_patterns", "group_patterns"],
    )