Exemplo n.º 1
0
 def _vs_ical(self):
     return Dictionary(
         title=_('Import iCalendar File'),
         render="form",
         optional_keys=False,
         elements=[
             ('file',
              FileUpload(
                  title=_('iCalendar File'),
                  help=_("Select an iCalendar file (<tt>*.ics</tt>) from your PC"),
                  custom_validate=self._validate_ical_file,
              )),
             ('horizon',
              Integer(
                  title=_('Time horizon for repeated events'),
                  help=
                  _("When the iCalendar file contains definitions of repeating events, these repeating "
                    "events will be resolved to single events for the number of years you specify here."
                   ),
                  minvalue=0,
                  maxvalue=50,
                  default_value=10,
                  unit=_('years'),
              )),
             ('times',
              Optional(
                  ListOfTimeRanges(default_value=[None],),
                  title=_('Use specific times'),
                  label=_('Use specific times instead of whole day'),
                  help=
                  _("When you specify explicit time definitions here, these will be added to each "
                    "date which is added to the resulting time period. By default the whole day is "
                    "used."),
              )),
         ])
Exemplo n.º 2
0
 def _vs_exceptions(self):
     return ListOf(
         Tuple(
             orientation="horizontal",
             show_titles=False,
             elements=[
                 TextInput(
                     regex="^[-a-z0-9A-Z /]*$",
                     regex_error=
                     _("This is not a valid Nagios timeperiod day specification."
                       ),
                     allow_empty=False,
                     validate=self._validate_timeperiod_exception,
                 ),
                 ListOfTimeRanges()
             ],
         ),
         title=_("Exceptions (from weekdays)"),
         help=_(
             "Here you can specify exceptional time ranges for certain "
             "dates in the form YYYY-MM-DD which are used to define more "
             "specific definitions to override the times configured for the matching "
             "weekday."),
         movable=False,
         add_label=_("Add Exception"),
     )
Exemplo n.º 3
0
def _parameter_valuespec_fileinfo():
    return Dictionary(
        elements=[
            (
                "minage",
                Tuple(
                    title=_("Minimal age"),
                    elements=[
                        Age(title=_("Warning below")),
                        Age(title=_("Critical below")),
                    ],
                ),
            ),
            (
                "maxage",
                Tuple(
                    title=_("Maximal age"),
                    elements=[
                        Age(title=_("Warning at or above")),
                        Age(title=_("Critical at or above")),
                    ],
                ),
            ),
            (
                "minsize",
                Tuple(
                    title=_("Minimal size"),
                    elements=[
                        Filesize(title=_("Warning below")),
                        Filesize(title=_("Critical below")),
                    ],
                ),
            ),
            (
                "maxsize",
                Tuple(
                    title=_("Maximal size"),
                    elements=[
                        Filesize(title=_("Warning at or above")),
                        Filesize(title=_("Critical at or above")),
                    ],
                ),
            ),
            (
                "timeofday",
                ListOfTimeRanges(
                    title=_("Only check during the following times of the day"),
                    help=_("Outside these ranges the check will always be OK"),
                ),
            ),
            (
                "state_missing",
                MonitoringState(default_value=3, title=_("State when file is missing")),
            ),
        ],
    )
Exemplo n.º 4
0
def _parameter_valuespec_motion():
    return Dictionary(elements=[
        ("time_periods",
         Dictionary(
             title=_("Time periods"),
             help=_("Specifiy time ranges during which no motion is expected. "
                    "Outside these times, the motion detector will always be in "
                    "state OK"),
             elements=[(day_id, ListOfTimeRanges(title=day_str))
                       for day_id, day_str in defines.weekdays_by_name()],
             optional_keys=[],
         )),
    ],)
Exemplo n.º 5
0
def _parameter_valuespec_fileinfo():
    return Dictionary(elements=[
        ("minage", min_age_levels()),
        ("maxage", max_age_levels()),
        ("minsize", min_size_levels()),
        ("maxsize", max_size_levels()),
        ("timeofday",
         ListOfTimeRanges(
             title=_("Only check during the following times of the day"),
             help=_("Outside these ranges the check will always be OK"),
         )),
        ("state_missing",
         MonitoringState(default_value=3,
                         title=_("State when file is missing"))),
    ], )
Exemplo n.º 6
0
 def _vs_weekdays(self):
     return CascadingDropdown(
         title=_("Active time range"),
         help=_("For each weekday you can setup no, one or several "
                "time ranges in the format <tt>23:39</tt>, in which the time period "
                "should be active."),
         choices=[
             ("whole_week", _("Same times for all weekdays"), ListOfTimeRanges()),
             ("day_specific", _("Weekday specific times"),
              Dictionary(
                  elements=self._weekday_elements(),
                  optional_keys=False,
                  indent=False,
              )),
         ],
     )
Exemplo n.º 7
0
 def _weekday_elements(self):
     elements = []
     for tp_id, tp_title in cmk.utils.defines.weekdays_by_name():
         elements.append((tp_id, ListOfTimeRanges(title=tp_title)))
     return elements
Exemplo n.º 8
0
def get_fileinfo_groups_param_elements():
    return [
        (
            "minage_oldest",
            Tuple(
                title=_("Minimal age of oldest file"),
                elements=[
                    Age(title=_("Warning below")),
                    Age(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxage_oldest",
            Tuple(
                title=_("Maximal age of oldest file"),
                elements=[
                    Age(title=_("Warning at or above")),
                    Age(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minage_newest",
            Tuple(
                title=_("Minimal age of newest file"),
                elements=[
                    Age(title=_("Warning below")),
                    Age(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxage_newest",
            Tuple(
                title=_("Maximal age of newest file"),
                elements=[
                    Age(title=_("Warning at or above")),
                    Age(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize_smallest",
            Tuple(
                title=_("Minimal size of smallest file"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize_smallest",
            Tuple(
                title=_("Maximal size of smallest file"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize_largest",
            Tuple(
                title=_("Minimal size of largest file"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize_largest",
            Tuple(
                title=_("Maximal size of largest file"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "minsize",
            Tuple(
                title=_("Minimal size"),
                elements=[
                    Filesize(title=_("Warning below")),
                    Filesize(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxsize",
            Tuple(
                title=_("Maximal size"),
                elements=[
                    Filesize(title=_("Warning at or above")),
                    Filesize(title=_("Critical at or above")),
                ],
            ),
        ),
        (
            "mincount",
            Tuple(
                title=_("Minimal file count"),
                elements=[
                    Integer(title=_("Warning below")),
                    Integer(title=_("Critical below")),
                ],
            ),
        ),
        (
            "maxcount",
            Tuple(
                title=_("Maximal file count"),
                elements=[
                    Integer(title=_("Warning at or above")),
                    Integer(title=_("Critical at or 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()),
                                ("size_largest", _("Largest file size at"),
                                 Filesize()),
                                (
                                    "size_largest_lower",
                                    _("Largest file size below"),
                                    Filesize(),
                                ),
                                ("size_smallest", _("Smallest file size at"),
                                 Filesize()),
                                (
                                    "size_smallest_lower",
                                    _("Smallest file size below"),
                                    Filesize(),
                                ),
                                ("age_oldest", _("Oldest file age at"), Age()),
                                ("age_oldest_lower",
                                 _("Oldest file age below"), Age()),
                                ("age_newest", _("Newest file age at"), Age()),
                                ("age_newest_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."
                  ),
            ),
        ),
    ]
Exemplo n.º 9
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"],
    )