def parameters(cls, mode): parameters = super(CustomSnapins, cls).parameters(mode) parameters += [( cls.phrase("title"), # sort-index, key, valuespec [(2.5, "custom_snapin", CascadingDropdown( title=_("Snapin type"), choices=cls._customizable_snapin_type_choices, ))])] return parameters
def DualMemoryLevels(what, default_percents=None): return CascadingDropdown( title=_("Levels for %s") % what, choices=[ ("perc_used", _("Percentual levels for used %s") % what, UsedPercentage(default_percents)), ("perc_free", _("Percentual levels for free %s") % what, FreePercentage()), ("abs_used", _("Absolute levels for used %s") % what, UsedSize()), ("abs_free", _("Absolute levels for free %s") % what, FreeSize()), # PredictiveMemoryChoice(_("used %s") % what), # not yet implemented ("ignore", _("Do not impose levels")), ])
def wrap_with_no_levels_dropdown( title: str, value_spec: ValueSpec, default_choice: Literal["levels", "no_levels"] = "no_levels", ) -> CascadingDropdown: return CascadingDropdown( title=title, choices=[ ("no_levels", _("Do not impose levels")), ("levels", _("Impose levels"), value_spec), ], default_value=default_choice, )
def connection_method_valuespec(cls): return CascadingDropdown( title=_("Connection"), orientation="horizontal", choices=cls._connection_choices(), render=CascadingDropdown.Render.foldable, help= _("When connecting to remote site please make sure " "that Livestatus over TCP is activated there. You can use UNIX sockets " "to connect to foreign sites on localhost. Please make sure that this " "site has proper read and write permissions to the UNIX socket of the " "foreign site."), )
def _vs_grouping(): return CascadingDropdown( title=_("Configure grouping of interfaces"), help=_( 'Normally, the interface checks create a single service for each interface. By defining ' 'interface groups, multiple interfaces can be combined together. For each group, a ' 'single service is created. This services reports the total traffic amount summed over ' 'all group members.'), choices=[ ( False, _("Do not group interfaces"), FixedValue( [], totext="", ), ), ( True, _("Create the following interface groups"), ListOf( title=_("Interface groups"), add_label=_("Add pattern"), valuespec=Dictionary( elements=[ ( "group_name", TextAscii( title=_("Group name"), help=_("Name of group in service description"), allow_empty=False, ), ), ( 'member_appearance', _vs_item_appearance( _("Appearance of group members in service output"), _("When listing the group members in the output of the service " "monitoring the group, this option makes checkmk use either " "the interface description, alias or port number."), ), ), ], optional_keys=False, ), allow_empty=False, ), ), ], sorted=False, )
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 api_request_authentication(): return ( "auth_basic", Transform( valuespec=CascadingDropdown( title=_("Authentication"), choices=[ ( "auth_login", _("Basic authentication"), Dictionary( elements=[ ( "username", TextInput( title=_("Login username"), allow_empty=False, ), ), ( "password", IndividualOrStoredPassword( title=_("Password"), allow_empty=False, ), ), ], optional_keys=[], ), ), ( "auth_token", _("Token authentication"), Dictionary( elements=[ ( "token", IndividualOrStoredPassword( title=_("Login token"), allow_empty=False, ), ), ], optional_keys=[], ), ), ], ), forth=lambda v: ("auth_login", v) if "username" in v else v, ), )
def vs_parameters(cls): return [ ("rows", ListOf( Dictionary( elements=[ ("title", TextUnicode( title=_("Title"), allow_empty=False, )), ("query", CascadingDropdown( orientation="horizontal", title=_("Query"), label=_("Table") + ": ", choices=[ ("hosts", _("Hosts"), visuals.VisualFilterList(info_list=["host" ], )), ("services", _("Services"), visuals.VisualFilterList( info_list=["host", "service"], )), ("events", _("Events"), visuals.VisualFilterList( info_list=["host", "event"], )), ])), ], optional_keys=[], ), title=_("Rows"), add_label=_("Add new row"), del_label=_("Delete this row"), allow_empty=False, )), ("show_stale", Checkbox( title=_("Show stale hosts and services"), default_value=True, )), ("show_failed_notifications", Checkbox( title=_("Show failed notifications"), default_value=True, )), ("show_sites_not_connected", Checkbox( title=_("Display a message if sites are not connected"), default_value=True, )), ]
def spec(self): return Dictionary( title=_("Create notification with the following parameters"), optional_keys=[ 'url_prefix', 'ilert_priority', 'ilert_summary_host', 'ilert_summary_service' ], elements=[ ("ilert_api_key", CascadingDropdown( title=_("iLert alert source API key"), help=_("API key for iLert alert server"), choices=[( "ilert_api_key", _("API key"), TextAscii(size=80, allow_empty=False), ), ("store", _("API key from password store"), DropdownChoice(sorted=True, choices=passwordstore_choices)) ])), ("ilert_priority", DropdownChoice( sorted=True, choices=[ ("high", _("High (with escalation)")), ('low', _("Low (without escalation")), ], title= _("Notifcation priority (This will overrride the priority configured in the alert source)" ), default_value='high')), ("ilert_summary_host", TextUnicode( title=_("Custom incident summary for host alerts"), default_value= "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ - $HOSTOUTPUT$", size=64, )), ("ilert_summary_service", TextUnicode( title=_("Custom incident summary for service alerts"), default_value= "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ - $SERVICEOUTPUT$", size=64, )), ("url_prefix", _get_url_prefix_specs(local_site_url, default_value="automatic_https")), ], )
def _vs_audit_log_options(self): return Dictionary( title=_("Options"), elements=[ ("filter_regex", RegExp( title=_("Filter pattern (RegExp)"), mode="infix", )), ("start", CascadingDropdown( title=_("Start log from"), default_value="now", orientation="horizontal", choices=[ ("now", _("Current date")), ("time", _("Specific date"), AbsoluteDate()), ], )), ("display", CascadingDropdown( title=_("Display mode of entries"), default_value="daily", orientation="horizontal", choices=[ ("daily", _("Daily paged display")), ("number_of_days", _("Number of days from now (single page)"), Integer( minvalue=1, unit=_("days"), default_value=1, )), ], )), ], optional_keys=[], )
def LowerMemoryLevels(what, default_percents=None, of_what=None, help_text=None): return CascadingDropdown( title=_("Lower levels for %s") % what, help=help_text, choices=[ ("perc_free", _("Percentual levels"), FreePercentage(default_percents, of_what)), ("abs_free", _("Absolute levels"), FreeSize()), # PredictiveMemoryChoice(what), # not yet implemented ("ignore", _("Do not impose levels")), ])
def vs_choices(title): return CascadingDropdown( title=title, choices=[ ("nothing", _("Restrict all")), ("choices", _("Restrict the following keys"), ListOfStrings( orientation="horizontal", size=15, allow_empty=True, )), ], default_value="nothing", )
def _vs_limits_vcpu_families(): return ListOf( CascadingDropdown( orientation="horizontal", choices=[("%s_vcpu" % inst_fam, fam_name, _vs_limits( fam_name, AWSEC2LimitsSpecial.get("%s_vcpu" % inst_fam, AWSEC2LimitsDefault)[0])) for inst_fam, fam_name in AWSEC2InstFamilies.items()]), title= _("Set limits and levels for running on-demand vCPUs on instance Families" ), )
def _get_rule_choices(): action_choices = _get_action_cascading_dropdown_choices() choices = list(action_choices) for search_plugin in ["host_search", "service_search"]: plugin = bi_config_search_registry[search_plugin] plugin_type, title, valuespec = plugin.cascading_dropdown_choice_element( ) choices.append((plugin_type, title, Tuple(elements=[ valuespec, CascadingDropdown(title=_("Nodes to create"), choices=action_choices) ]))) return choices
def UpperMemoryLevels(what, default_percents=None, of_what=None): return CascadingDropdown( title=_("Upper levels for %s") % what, choices=[ ( "perc_used", _("Percentual levels%s") % (of_what and (_(" in relation to %s") % of_what) or ""), UsedPercentage(default_percents, of_what), ), ("abs_used", _("Absolute levels"), UsedSize()), # PredictiveMemoryChoice(what), # not yet implemented ("ignore", _("Do not impose levels")), ], )
def get_aggregation_function_choices(): choices: List[Any] = [] for aggr_func_id, bi_aggr_func in bi_config_aggregation_function_registry.items(): choices.append((aggr_func_id, bi_aggr_func.title(), bi_aggr_func.valuespec())) return Transform( CascadingDropdown(title=_("Aggregation Function"), help=_("The aggregation function decides how the status of a node " "is constructed from the states of the child nodes."), orientation="horizontal", choices=choices), forth=convert_to_cascading_vs_choice, back=convert_from_cascading_vs_choice, )
def _valuespec_inventory_df_rules(): return Dictionary( title=_("Discovery parameters for filesystem checks"), elements=[ ("include_volume_name", Transform( CascadingDropdown( title=_("Service description format"), choices= [(False, _("Name of mount point")), (True, _("Name of volume and name of mount point"), DropdownChoice( label=_("Filesystem grouping"), choices=[ ('mountpoint', _('Grouping pattern applies to mount point only' )), ('volume_name_and_mountpoint', _('Grouping pattern applies to volume name and mount point' )), ], help=_( "Specifies how the <a href='wato.py?mode=edit_ruleset&varname=filesystem_groups'>Filesystem grouping patterns</a> " "feature processes this filesystem."), ))]), forth=lambda x: (True, "mountpoint") if x is True else x, )), ("ignore_fs_types", ListChoice(title=_("Filesystem types to ignore"), choices=[ ("tmpfs", "tmpfs"), ("nfs", "nfs"), ("smbfs", "smbfs"), ("cifs", "cifs"), ("iso9660", "iso9660"), ], default_value=[ "tmpfs", "nfs", "smbfs", "cifs", "iso9660" ])), ("never_ignore_mountpoints", ListOf( TextUnicode(), title=_(u"Mountpoints to never ignore"), help= _(u"Regardless of filesystem type, these mountpoints will always be discovered." u"Globbing or regular expressions are currently not supported." ), )), ], )
def _parameter_valuespec_fcp(): return Dictionary(elements=[ ("speed", OptionalDropdownChoice( title=_("Operating speed"), help=_( "If you use this parameter then the check goes warning if the " "interface is not operating at the expected speed (e.g. it " "is working with 8Gbit/s instead of 16Gbit/s)."), choices=[ (None, _("ignore speed")), (4000000000, "4 Gbit/s"), (8000000000, "8 Gbit/s"), (16000000000, "16 Gbit/s"), ], otherlabel=_("specify manually ->"), explicit=Integer(title=_("Other speed in bits per second"), label=_("Bits per second")))), ("traffic", ListOf( CascadingDropdown( title=_("Direction"), orientation="horizontal", choices=[ ('both', _("In / Out"), vs_interface_traffic()), ('in', _("In"), vs_interface_traffic()), ('out', _("Out"), vs_interface_traffic()), ], ), title=_("Used bandwidth (minimum or maximum traffic)"), help=_( "Setting levels on the used bandwidth is optional. If you do set " "levels you might also consider using averaging."), )), ("read_latency", Levels(title=_("Read latency"), unit=_("ms"), default_value=None, default_levels=(50.0, 100.0))), ("write_latency", Levels(title=_("Write latency"), unit=_("ms"), default_value=None, default_levels=(50.0, 100.0))), ("latency", Levels(title=_("Overall latency"), unit=_("ms"), default_value=None, default_levels=(50.0, 100.0))), ], )
def _get_component_specific_checkmk_files_choices( self, title: str, checkmk_files: List[Tuple[str, CheckmkFileInfo]], ) -> ValueSpec: high_sensitive_files = [] sensitive_files = [] insensitive_files = [] for rel_filepath, file_info in checkmk_files: if file_info.sensitivity == CheckmkFileSensitivity.high_sensitive: high_sensitive_files.append((rel_filepath, file_info)) elif file_info.sensitivity == CheckmkFileSensitivity.sensitive: sensitive_files.append((rel_filepath, file_info)) else: insensitive_files.append((rel_filepath, file_info)) sorted_files = sorted(high_sensitive_files + sensitive_files + insensitive_files, key=lambda t: t[0]) sorted_non_high_sensitive_files = sorted(sensitive_files + insensitive_files, key=lambda t: t[0]) sorted_insensitive_files = sorted(insensitive_files, key=lambda t: t[0]) return CascadingDropdown( title=_(title), sorted=False, choices=[ ("all", _("Pack all files: High, Medium, Low sensitivity"), FixedValue( [f for f, fi in sorted_files], totext=self._list_of_files_to_text(sorted_files), )), ("non_high_sensitive", _("Pack only Medium and Low sensitivity files"), FixedValue( [f for f, fi in sorted_non_high_sensitive_files], totext=self._list_of_files_to_text(sorted_non_high_sensitive_files), )), ("insensitive", _("Pack only Low sensitivity files"), FixedValue( [f for f, fi in sorted_insensitive_files], totext=self._list_of_files_to_text(sorted_insensitive_files), )), ("explicit_list_of_files", _("Select individual files from list"), DualListChoice( choices=self._list_of_files_choices(sorted_files), size=80, rows=10, )), ], default_value="non_high_sensitive", )
def _valuespec_special_agents_ipmi_sensors() -> Transform: return Transform( valuespec=CascadingDropdown( choices=[ ("freeipmi", _("Use FreeIPMI"), _special_agents_ipmi_sensors_vs_freeipmi()), ("ipmitool", _("Use IPMItool"), _special_agents_ipmi_sensors_vs_ipmitool()), ], title=_("IPMI Sensors via Freeipmi or IPMItool"), help=_( "This rule selects the Agent IPMI Sensors instead of the normal Check_MK Agent " "which collects the data through the FreeIPMI resp. IPMItool command" ), ), forth=_special_agents_ipmi_sensors_transform_ipmi_sensors, )
def get_bi_aggregation_node_choices(): return Dictionary( elements=[("search", Transform( CascadingDropdown(title=_("Search node arguments"), choices=_get_search_cascading_dropdown_choices()), forth=convert_to_cascading_vs_choice, back=convert_from_cascading_vs_choice, )), ("action", Transform( CascadingDropdown( title=_("Nodes to create from search result(s)"), choices=[ bi_config_action_registry[bi_actions.BICallARuleAction.type()]. cascading_dropdown_choice_element() ], ), forth=convert_to_cascading_vs_choice, back=convert_from_cascading_vs_choice, ))], title=_("Node configuration"), optional_keys=[], )
def _vs_inventory_paths_and_keys(self) -> CascadingDropdown: def vs_choices(title): return CascadingDropdown( title=title, choices=[ ("nothing", _("Restrict all")), ( "choices", _("Restrict the following keys"), ListOfStrings( orientation="horizontal", size=15, allow_empty=True, ), ), ], default_value="nothing", ) return CascadingDropdown( choices=[ ("allow_all", _("Allowed to see the whole tree")), ("forbid_all", _("Forbid to see the whole tree")), ( "paths", _("Allowed to see parts of the tree"), ListOf( Dictionary( elements=[ vs_element_inventory_visible_raw_path(), ("attributes", vs_choices(_("Restrict single values"))), ("columns", vs_choices(_("Restrict table columns"))), ("nodes", vs_choices(_("Restrict subcategories"))), ], optional_keys=["attributes", "columns", "nodes"], ), help=vs_inventory_path_or_keys_help() + _("<br>If single values, table columns or subcategories are not" " restricted, then all entries are added respectively." ), ), ), ], default_value="allow_all", )
def valuespec(self): return CascadingDropdown( title=_("Fallback notification email format"), choices=[ ( "asciimail", _("ASCII Email"), notification_parameter_registry["asciimail"]().spec, ), ( "mail", _("HTML Email"), notification_parameter_registry["mail"]().spec, ), ], )
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, )), ], )
def __levels(title): return CascadingDropdown( title=title, choices=[ ("no_levels", _("No levels"), None), ( "levels", _("Impose levels"), Tuple(elements=[ Age(title=_("Warning above")), Age(title=_("Critical above")) ]), ), ], default_value="no_levels", )
def ibm_mq_version(): return [ ( "version", CascadingDropdown( title=_("Check for correct version"), help=_("You can make sure that the plugin is running" " with a specific or a minimal version."), choices=[ ('at_least', _("At least"), TextAscii(title=_("At least"), allow_empty=False)), ('specific', _("Specific version"), TextAscii(title=_("Specific version"), allow_empty=False)), ], ), ), ]
def _discovery_parameters_valuespec_alertmanager(): return Dictionary( title=_("Alertmanager discovery"), elements=[ ("group_services", CascadingDropdown( title=_("Service creation"), choices=[ (True, _("Create services for alert rule groups"), Dictionary( elements=[ ("min_amount_rules", Integer( title= _("Minimum amount of alert rules in a group to create a group service" ), minvalue=1, default_value=3, help=_( "Below the specified value alert rules will be monitored as a" "single service."), )), ("no_group_services", ListOfStrings(title=_( "Don't create a group service for the following groups" ), )), ], optional_keys=[], )), (False, _("Create one service per alert rule"), FixedValue( {}, title=_("Enabled"), totext="", )), ], )), ("summary_service", FixedValue( True, title=_("Create a summary service for all alert rules"), totext="", )), ], optional_keys=["summary_service"], default_keys=["summary_service"], )
def _vs_single_discovery(): return CascadingDropdown( title=_("Configure discovery of single interfaces"), choices=[ ( True, _("Discover single interfaces"), Dictionary( elements=[ ( 'item_appearance', _vs_item_appearance( _("Appearance of network interface"), _("This option makes checkmk use either the interface description, " "alias or port number as item."), ), ), ( "pad_portnumbers", DropdownChoice( choices=[ (True, _('Pad port numbers with zeros')), (False, _('Do not pad')), ], title=_("Port numbers"), help=_( "If this option is activated, checkmk will pad port numbers of " "network interfaces with zeroes so that the descriptions of all " "ports of a host or switch have the same length and thus are " "sorted correctly in the GUI."), ), ), ], optional_keys=False, ), ), ( False, _("Do not discover single interfaces"), FixedValue( {}, totext="", ), ), ], sorted=False, )
def _parameter_valuespec_rabbitmq_nodes_filedesc(): return Dictionary(elements=[ ("levels", CascadingDropdown( title=_("Levels for file descriptor usage"), choices=[ ("fd_perc", _("Percentual levels for used file descriptors"), Tuple(elements=[ Percentage(title=_("Warning at usage of"), default_value=80.0, maxvalue=None), Percentage(title=_("Critical at usage of"), default_value=90.0, maxvalue=None) ], )), ("fd_abs", _("Absolut level for total number of used file descriptors"), Tuple(elements=[ Integer(title=_("Warning at"), unit="descriptors"), Integer(title=_("Critical at"), unit="descriptors"), ], )), ])), ("fd_open_upper", Tuple( title=_("Upper level for file descriptor open attempts"), elements=[ Integer(title=_("Warning at"), unit="open attempts"), Integer(title=_("Critical at"), unit="open attempts"), ], )), ("fd_open_rate_upper", Tuple( title=_("Upper level for file descriptor open attempts rate"), elements=[ Float(title=_("Warning at"), unit="1/s"), Float(title=_("Critical at"), unit="1/s"), ], )), ("fd_open_rate_lower", Tuple( title=_("Lower level for file descriptor open attempts rate"), elements=[ Float(title=_("Warning below"), unit="1/s"), Float(title=_("Critical below"), unit="1/s"), ], )), ], )
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=[ RegExp( 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=RegExp.prefix, ), TextInput( 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), ])), ])