def _parameter_valuespec_nimble_latency(): return Dictionary( help=_("You can set limits for the latency of read or write I/O operations of Nimble " "storage volumes. Note that the operations are shown in terms of number of " "operations as a percentage of total read or write I/O operations within various " "latency ranges (e.g. 0-0.1 ms, 0.1-0.2 ms, etc.). In order to effectively " "set limits for these volumes, please select WARN/CRIT levels in terms of " "percentage of overall number of operations. To accommodate the large range of " "Nimble storage devices and their various functionalities (all-flash, hybrid, " "tape, etc.), it is possible to select the starting point at which values should " "be considered. " "For example, for some devices, you may only want to be notified with a WARN if " "10% of operations have a latency of 10-20 ms or above, and a CRIT if 20% of " "operations reach this threshold. You can achieve this by setting the \"Range " "Reference\" parameter to 10-20 ms, and warning and critical levels to 10% and 20% " "respectively."), elements=[ ("range_reference", DropdownChoice( title="Range Reference", help=_("The latency range at which values should start to be considered."), choices=[ ("0.1", _("0.0 - 0.1 ms")), ("0.2", _("0.1 - 0.2 ms")), ("0.5", _("0.2 - 0.5 ms")), ("1", _("0.5 - 1.0 ms")), ("2", _("1.0 - 2.0 ms")), ("5", _("2.0 - 5.0 ms")), ("10", _("5.0 - 10.0 ms")), ("20", _("10.0 - 20.0 ms")), ("50", _("20.0 - 50.0 ms")), ("100", _("50.0 - 100.0 ms")), ("200", _("100.0 - 200.0 ms")), ("500", _("200.0 - 500.0 ms")), ("1000", _("500.0+ ms")), ], default_value="20", )), ( "read", Tuple( title=_("Read Latency"), elements=[ Percentage( title=_("Warning at"), unit="%", minvalue=0.0, maxvalue=100.0, default_value=10.0, ), Percentage( title=_("Critical at"), unit="%", minvalue=0.0, maxvalue=100.0, default_value=20.0, ), ], help=_("The default levels are suitable for hybrid storage systems. " "Please consider lowering them if your storage system is all-flash."), ), ), ( "write", Tuple( title=_("Write Latency"), elements=[ Percentage( title=_("Warning at"), unit="%", minvalue=0.0, maxvalue=100.0, default_value=10.0, ), Percentage( title=_("Critical at"), unit="%", minvalue=0.0, maxvalue=100.0, default_value=20.0, ), ], help=_("The default levels are suitable for hybrid storage systems. " "Please consider lowering them if your storage system is all-flash."), ), ), ], )
rulespec_registry.register( HostRulespec( group=RulespecGroupCheckParametersDiscovery, match_type="list", name="inventory_if_rules", valuespec=_valuespec_inventory_if_rules, )) vs_elements_if_groups_matches = [ ("iftype", Transform( DropdownChoice( title=_("Select interface port type"), choices=ListChoice.dict_choices(defines.interface_port_types()), help=_("Only interfaces with the given port type are put into this group. " "For example 53 (propVirtual)."), ), forth=str, back=int, )), ("items", ListOfStrings( title=_("Restrict interface items"), help=_("Only interface with these item names are put into this group."), )), ] # type: List[DictionaryEntry] vs_elements_if_groups_group = [ ("group_name", TextAscii(
def _valuespec_inventory_if_rules(): return Transform( Dictionary( title=_("Network Interface and Switch Port Discovery"), elements=[ ('item_appearance', DropdownChoice( title=_("Appearance of network interface"), help=_( "This option lets Check_MK use either the interface description, alias or " " port number as item. The port number is the fallback/default." "used anyway."), choices=[ ('descr', _('Use description')), ('alias', _('Use alias')), ('index', _('Use index')), ], default_value='index', )), ("pad_portnumbers", DropdownChoice( choices=[ (True, _('Pad port numbers with zeros')), (False, _('Do not pad')), ], title=_("Port numbers"), help=_("If this option is activated then Check_MK will pad port numbers of " "network interfaces with zeroes so that all port descriptions from " "all ports of a host or switch have the same length and thus sort " "currectly in the GUI. In versions prior to 1.1.13i3 there was no " "padding. You can switch back to the old behaviour by disabling this " "option. This will retain the old service descriptions and the old " "performance data."), )), ("match_alias", ListOfStrings( title=_("Match interface alias (regex)"), help=_( "Only discover interfaces whose alias matches one of the configured " "regular expressions. The match is done on the beginning of the alias. " "This allows you to select interfaces based on the alias without having " "the alias be part of the service description."), orientation="horizontal", valuespec=RegExp( size=32, mode=RegExp.prefix, ), )), ("match_desc", ListOfStrings( title=_("Match interface description (regex)"), help= _("Only discover interfaces whose the description matches one of the configured " "regular expressions. The match is done on the beginning of the description. " "This allows you to select interfaces based on the description without having " "the alias be part of the service description."), orientation="horizontal", valuespec=RegExp( size=32, mode=RegExp.prefix, ), )), ("portstates", ListChoice( title=_("Network interface port states to discover"), help= _("When doing discovery on switches or other devices with network interfaces " "then only ports found in one of the configured port states will be added to the monitoring. " "Note: the state <i>admin down</i> is in fact not an <tt>ifOperStatus</tt> but represents the " "<tt>ifAdminStatus</tt> of <tt>down</tt> - a port administratively switched off. If you check this option " "then an alternate version of the check is being used that fetches the <tt>ifAdminState</tt> in addition. " "This will add about 5% of additional SNMP traffic."), choices=defines.interface_oper_states(), toggle_all=True, default_value=['1'], )), ("porttypes", DualListChoice( title=_("Network interface port types to discover"), help=_( "When doing discovery on switches or other devices with network interfaces " "then only ports of the specified types will be created services for."), choices=defines.interface_port_types(), rows=40, default_value=[ '6', '32', '62', '117', '127', '128', '129', '180', '181', '182', '205', '229' ], )), ("rmon", DropdownChoice( choices=[ (True, _("Create extra service with RMON statistics data (if available for the device)" )), (False, _('Do not create extra services')), ], title=_("Collect RMON statistics data"), help= _("If you enable this option, for every RMON capable switch port an additional service will " "be created which is always OK and collects RMON data. This will give you detailed information " "about the distribution of packet sizes transferred over the port. Note: currently " "this extra RMON check does not honor the inventory settings for switch ports. In a future " "version of Check_MK RMON data may be added to the normal interface service and not add " "an additional service."), )), ], help=_('This rule can be used to control the inventory for network ports. ' 'You can configure the port types and port states for inventory ' 'and the use of alias or description as service name.'), ), forth=_transform_discovery_if_rules, )
def parameter_valuespec(self): return Dictionary(elements=[ ("roles", Alternative( title=_("Roles"), elements=[ FixedValue(None, totext="", title=_("Do not monitor")), ListOf(Tuple( orientation="horizontal", elements=[ DropdownChoice( title=_("DRBD shows up as"), default_value="running", choices=[("primary_secondary", _("Primary / Secondary")), ("primary_primary", _("Primary / Primary")), ("secondary_primary", _("Secondary / Primary")), ("secondary_secondary", _("Secondary / Secondary"))], ), MonitoringState(title=_("Resulting state"), ), ], default_value=("ignore", 0)), title=_("Set roles"), add_label=_("Add role rule")) ], )), ( "diskstates", Alternative( title=_("Diskstates"), elements=[ FixedValue(None, totext="", title=_("Do not monitor")), ListOf(Tuple( elements=[ DropdownChoice( title=_("Diskstate"), choices=[ ("primary_Diskless", _("Primary - Diskless")), ("primary_Attaching", _("Primary - Attaching")), ("primary_Failed", _("Primary - Failed")), ("primary_Negotiating", _("Primary - Negotiating")), ("primary_Inconsistent", _("Primary - Inconsistent")), ("primary_Outdated", _("Primary - Outdated")), ("primary_DUnknown", _("Primary - DUnknown")), ("primary_Consistent", _("Primary - Consistent")), ("primary_UpToDate", _("Primary - UpToDate")), ("secondary_Diskless", _("Secondary - Diskless")), ("secondary_Attaching", _("Secondary - Attaching")), ("secondary_Failed", _("Secondary - Failed")), ("secondary_Negotiating", _("Secondary - Negotiating")), ("secondary_Inconsistent", _("Secondary - Inconsistent")), ("secondary_Outdated", _("Secondary - Outdated")), ("secondary_DUnknown", _("Secondary - DUnknown")), ("secondary_Consistent", _("Secondary - Consistent")), ("secondary_UpToDate", _("Secondary - UpToDate")), ], ), MonitoringState(title=_("Resulting state")) ], orientation="horizontal", ), title=_("Set diskstates"), add_label=_("Add diskstate rule")) ], ), ) ], )
Tuple( elements=[ Float(title=_("Frequencies up to"), unit=u"MHz"), Float(title=_("Warning below"), unit=u"V"), Float(title=_("Critical below"), unit=u"V"), Float(title=_("Warning at or above"), unit=u"V"), Float(title=_("Critical at or above"), unit=u"V"), ], ), title=_("Lock voltages for TX PLL"), help= _("Specify frequency ranges by the upper boundary of the range " "to which the voltage levels are to apply. The list is sorted " "automatically when saving."), movable=False)), ], optional_keys=["rx", "tx"], ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="pll_lock_voltage", group=RulespecGroupCheckParametersEnvironment, item_spec=lambda: DropdownChoice(title=_("RX/TX"), choices=[("RX", _("RX")), ("TX", _("TX"))]), match_type="dict", parameter_valuespec=_parameter_valuespec_pll_lock_voltage, title=lambda: _("Lock Voltage for PLLs"), ))
def valuespec(self): return DropdownChoice( title=_("Sidebar position"), choices=[(None, _("Right")), ("left", _("Left"))], no_preselect_value=False, )
def _render_options(cls): return [ ( "metric_render_options", Transform( Dictionary( elements=[ ("font_size", CascadingDropdown( title=_("Metric value font size"), orientation="horizontal", choices=[ ("fix", _("Set the metric value font size to:"), Fontsize(default_value="22.5")), ("dynamic", _("Dynamically adapt the metric font size to the dashlet size" )) ], default_value="dynamic")), ("link_to_svc_detail", DropdownChoice( title=_("Link to service detail page"), choices=[ ("true", _("Open service detail page when clicking on the metric value" )), ("false", _("Do not add a link to the metric value")) ], default_value="true")), ("show_site", CascadingDropdown( title=_("Show the site name"), orientation="horizontal", sorted=False, choices=[("above", _("... above the metric value with font size:"), Fontsize(default_value="12.0")), ("below", _("... below the metric value with font size:"), Fontsize(default_value="12.0")), ("tooltip", _("... in a tooltip when hovering the metric value")), ("false", _("Do not show the site name"))], default_value="false")), ("show_host", CascadingDropdown( title=_("Show the host name"), orientation="horizontal", sorted=False, choices=[("above", _("... above the metric value with font size:"), Fontsize(default_value="12.0")), ("below", _("... below the metric value with font size:"), Fontsize(default_value="12.0")), ("tooltip", _("... in a tooltip when hovering the metric value")), ("false", _("Do not show the host name"))], default_value="false")), ("show_service", CascadingDropdown( title=_("Show the service name"), orientation="horizontal", sorted=False, choices=[("above", _("... above the metric value with font size:"), Fontsize(default_value="12.0")), ("below", _("... below the metric value with font size:"), Fontsize(default_value="12.0")), ("tooltip", _("... in a tooltip when hovering the metric value")), ("false", _("Do not show the service name"))], default_value="tooltip")), ("show_metric", CascadingDropdown( title=_("Show the metric name"), orientation="horizontal", sorted=False, choices=[("above", _("... above the metric value with font size:"), Fontsize(default_value="12.0")), ("below", _("... below the metric value with font size:"), Fontsize(default_value="12.0")), ("tooltip", _("... in a tooltip when hovering the metric value")), ("false", _("Do not show the metric name"))], default_value="above")), ("show_state_color", DropdownChoice(title=_("Show the service state color"), choices=[ ("background", _("... as background color")), ("font", _("... as font color")), ("false", _("Do not show the service state color")), ], default_value="background")), ("show_unit", DropdownChoice(title=_("Show the metric's unit"), choices=[ ("true", _("Show the metric's unit")), ("false", _("Do not show the metric's unit")), ], default_value="true")), ], optional_keys=[], title=_("Metric rendering options"), ),), ), ]
def _valuespec_special_agents_elasticsearch(): return Dictionary( optional_keys=["user", "password"], title=_("Elasticsearch"), help=_( "Requests data about Elasticsearch clusters, nodes and indices."), elements=[ ( "hosts", ListOfStrings( title=_("Hostnames to query"), help= _("Use this option to set which host should be checked by the special agent. If the " "connection to the first server fails, the next server will be queried (fallback). " "The check will only output data from the first host that sends a response." ), size=32, allow_empty=False, ), ), ("user", TextInput(title=_("Username"), size=32, allow_empty=True)), ( "password", PasswordFromStore( title=_("Password of the user"), allow_empty=False, ), ), ( "protocol", DropdownChoice( title=_("Protocol"), choices=[ ("http", "HTTP"), ("https", "HTTPS"), ], default_value="https", ), ), ( "port", Integer( title=_("Port"), help= _("Use this option to query a port which is different from standard port 9200." ), default_value=9200, ), ), ( "infos", ListChoice( title=_("Informations to query"), help=_( "Defines what information to query. " "Checks for Cluster, Indices and Shard statistics follow soon." ), choices=[ ("cluster_health", _("Cluster health")), ("nodes", _("Node statistics")), ("stats", _("Cluster, Indices and Shard statistics")), ], default_value=["cluster_health", "nodes", "stats"], allow_empty=False, ), ), ], )
def _parameter_valuespec_heartbeat_crm(): return Transform( Dictionary( elements=[ ( "max_age", Integer( title=_("Maximum age"), help=_("Maximum accepted age of the reported data in seconds"), unit=_("seconds"), default_value=60, ), ), ( "dc", TextInput( allow_empty=False, title=_("Expected DC"), help=_( "The hostname of the expected distinguished controller of the cluster" ), ), ), ( "num_nodes", Integer( minvalue=0, default_value=2, title=_("Number of Nodes"), help=_("The expected number of nodes in the cluster"), ), ), ( "num_resources", Integer( minvalue=0, title=_("Number of Resources"), help=_("The expected number of resources in the cluster"), ), ), ( "show_failed_actions", DropdownChoice( title=_('Show "Failed Actions"'), choices=[ ( False, _('Don\'t show or warn if "Failed Actions" are present (default)'), ), (True, _('Show "Failed Actions" and warn if any is present')), ], default_value=False, help=_( 'If activated, any "Failed Action" entry will be shown in the main check ' "and the check will go to the WARN state." ), ), ), ], optional_keys=["dc", "num_nodes", "num_resources", "show_failed_actions"], ), forth=_heartbeat_crm_transform_heartbeat_crm, )
def _parameter_valuespec_temperature(): return Transform( valuespec=Dictionary( elements=[ ( "levels", Transform( valuespec=Tuple( title=_("Upper Temperature Levels"), elements=[ Float(title=_("Warning at"), unit="°C", default_value=26), Float(title=_("Critical at"), unit="°C", default_value=30), ], ), forth=lambda elems: (float(elems[0]), float(elems[1])), ), ), ( "levels_lower", Transform( valuespec=Tuple( title=_("Lower Temperature Levels"), elements=[ Float(title=_("Warning below"), unit="°C", default_value=0), Float(title=_("Critical below"), unit="°C", default_value=-10), ], ), forth=lambda elems: (float(elems[0]), float(elems[1])), ), ), ( "output_unit", DropdownChoice( title=_("Display values in "), choices=[ ("c", _("Celsius")), ("f", _("Fahrenheit")), ("k", _("Kelvin")), ], ), ), ( "input_unit", DropdownChoice( title=_("Override unit of sensor"), help= _("In some rare cases the unit that is signalled by the sensor " "is wrong and e.g. the sensor sends values in Fahrenheit while " "they are misinterpreted as Celsius. With this setting you can " "force the reading of the sensor to be interpreted as customized. " ), choices=[ ("c", _("Celsius")), ("f", _("Fahrenheit")), ("k", _("Kelvin")), ], ), ), ( "device_levels_handling", DropdownChoice( title= _("Interpretation of the device's own temperature status" ), choices=[ ("usr", _("Ignore device's own levels")), ("dev", _("Only use device's levels, ignore yours")), ("best", _("Use least critical of your and device's levels" )), ("worst", _("Use most critical of your and device's levels") ), ("devdefault", _("Use device's levels if present, otherwise yours" )), ( "usrdefault", _("Use your own levels if present, otherwise the device's" ), ), ], default_value="usrdefault", ), ), ( "trend_compute", Dictionary( title=_("Trend computation"), elements=[ ( "period", Integer( title= _("Observation period for temperature trend computation" ), default_value=30, minvalue=5, unit=_("minutes"), ), ), ( "trend_levels", Tuple( title= _("Levels on temperature increase per period" ), elements=[ Integer( title=_("Warning at"), unit="°C / " + _("period"), default_value=5, ), Integer( title=_("Critical at"), unit="°C / " + _("period"), default_value=10, ), ], ), ), ( "trend_levels_lower", Tuple( title= _("Levels on temperature decrease per period" ), elements=[ Integer( title=_("Warning at"), unit="°C / " + _("period"), default_value=5, ), Integer( title=_("Critical at"), unit="°C / " + _("period"), default_value=10, ), ], ), ), ( "trend_timeleft", Tuple( title= _("Levels on the time left until a critical temperature (upper or lower) is reached" ), elements=[ Integer( title=_("Warning if below"), unit=_("minutes"), default_value=240, ), Integer( title=_("Critical if below"), unit=_("minutes"), default_value=120, ), ], ), ), ], optional_keys=[ "trend_levels", "trend_levels_lower", "trend_timeleft" ], ), ), ], ignored_keys=["_item_key"], ), forth=lambda v: isinstance(v, tuple) and {"levels": v} or v, )
def process_level_elements(): cpu_rescale_max_choices: DropdownChoices = [ ( True, # xgettext: no-python-format _("100% is all cores at full load"), ), (False, _("N * 100% as each core contributes with 100% at full load")), ] return [ ( "cpu_rescale_max", DropdownChoice( title=_("CPU rescale maximum load"), help=_( "CPU utilization is delivered by the Operating " "System as a per CPU core basis. Thus each core contributes " "with a 100% at full utilization, producing a maximum load " "of N*100% (N=number of cores). For simplicity this maximum " "can be rescaled down, making 100% the maximum and thinking " "in terms of total CPU utilization." ), default_value=True, choices=cpu_rescale_max_choices, invalid_choice_title=_("Unspecified.") + " " + _( "Starting from version 1.6.0 this value must be configured. " "Read Werk #6646 for further information." ), invalid_choice_error=_("CPU rescale maximum load is Unspecified.") + " " + _( "Starting from version 1.6.0 this value must be configured. " "Read Werk #6646 for further information." ), deprecated_choices=[CPU_RESCALE_MAX_UNSPEC], ), ), ( "levels", Tuple( title=_("Levels for process count"), help=_( "Please note that if you specify and also if you modify levels " "here, the change is activated only during an inventory." "Saving this rule is not enough. This is due to the nature of" "inventory rules." ), elements=[ Integer( title=_("Critical below"), unit=_("processes"), default_value=1, ), Integer( title=_("Warning below"), unit=_("processes"), default_value=1, ), Integer( title=_("Warning above"), unit=_("processes"), default_value=99999, ), Integer( title=_("Critical above"), unit=_("processes"), default_value=99999, ), ], ), ), ( "cpulevels", Tuple( title=_("Levels on total CPU utilization"), help=_( "By activating this options you can set levels on the total " "CPU utilization of all included processes." ), elements=[ Percentage(title=_("Warning at"), default_value=90, maxvalue=10000), Percentage(title=_("Critical at"), default_value=98, maxvalue=10000), ], ), ), ( "cpu_average", Integer( title=_("CPU Averaging"), help=_( "By activating averaging, Check_MK will compute the average of " "the total CPU utilization over a given interval. If you have defined " "alerting levels then these will automatically be applied on the " "averaged value. This helps to mask out short peaks. " ), unit=_("minutes"), minvalue=1, default_value=15, ), ), ( "single_cpulevels", Tuple( title=_("Levels on CPU utilization of a single process"), help=_( "Here you can define levels on the CPU utilization of single " "processes. For performance reasons CPU Averaging will not be " "applied to to the levels of single processes." ), elements=[ Percentage(title=_("Warning at"), default_value=90, maxvalue=10000), Percentage(title=_("Critical at"), default_value=98, maxvalue=10000), ], ), ), ( "min_age", Tuple( title=_("Minimum allowed age"), help=_( "Set lower levels on the age of the process (not the consumed CPU time, " "but the real time)." ), elements=[ Age(title=_("Warning at"), default_value=3600), Age(title=_("Critical at"), default_value=1800), ], ), ), ( "max_age", Tuple( title=_("Maximum allowed age"), help=_( "Set upper levels on the age of the process (not the consumed CPU time, " "but the real time)." ), elements=[ Age(title=_("Warning at"), default_value=3600), Age(title=_("Critical at"), default_value=7200), ], ), ), ( "virtual_levels", Tuple( title=_("Virtual memory usage"), elements=[ Filesize(title=_("Warning at"), default_value=1000 * 1024 * 1024 * 1024), Filesize(title=_("Critical at"), default_value=2000 * 1024 * 1024 * 1024), ], ), ), ( "resident_levels", Tuple( title=_("Physical memory usage"), elements=[ Filesize(title=_("Warning at"), default_value=100 * 1024 * 1024), Filesize(title=_("Critical at"), default_value=200 * 1024 * 1024), ], ), ), ( "resident_levels_perc", Tuple( title=_("Physical memory usage, in percentage of total RAM"), elements=[ Percentage(title=_("Warning at"), default_value=25.0), Percentage(title=_("Critical at"), default_value=50.0), ], ), ), ( "handle_count", Tuple( title=_("Handle Count (Windows only)"), help=_( "The number of object handles in the processes object table. This includes " "open handles to threads, files and other resources like registry keys." ), elements=[ Integer( title=_("Warning above"), unit=_("handles"), ), Integer( title=_("Critical above"), unit=_("handles"), ), ], ), ), ( "process_info", DropdownChoice( title=_("Enable per-process details in long-output"), label=_("Enable per-process details"), help=_( "If active, the long output of this service will contain a list of all the " "matching processes and their details (i.e. PID, CPU usage, memory usage). " "Please note that HTML output will only work if rules in the rulesets " '"%s" or "%s" are created or the global setting "%s" is disabled. ' "This might expose you to Cross-Site-Scripting attacks (everyone with " "write-access to checks could get scripts executed on the monitoring site " "in the context of the user of the monitoring site), so please do this if " "you understand the consequences." ) % ( _("Escape HTML codes in host output"), _("Escape HTML codes in service output"), _("Escape HTML codes in service output"), ), choices=[ (None, _("Disable")), ("text", _("Text output")), ("html", _("HTML output")), ], default_value=None, ), ), ( "process_info_arguments", Integer( title=_("Include process arguments in long-output"), label=_("Include per-process arguments (security risk!)"), help=_( "If non-zero, the list of all the matching processes and their details in the" " long-output will include up to the first N characters of all arguments for each" " process. Please note this may include sensitive data like credentials," " and is strongly discouraged." ), default_value=0, ), ), ( "icon", UserIconOrAction( title=_("Add custom icon or action"), help=_("You can assign icons or actions to the found services in the status GUI."), ), ), ]
def _valuespec_special_agents_azure(): return Dictionary( title=_("Microsoft Azure"), help= _("To monitor Azure resources add this datasource to <b>one</b> host. " "The data will be transported using the piggyback mechanism, so make " "sure to create one host for every monitored resource group. You can " "learn about the discovered groups in the <i>Azure Agent Info</i> " "service of the host owning the datasource program."), # element names starting with "--" will be passed do cmd line w/o parsing! elements=[ ( "subscription", TextInput( title=_("Subscription ID"), allow_empty=False, size=45, ), ), ( "tenant", TextInput( title=_("Tenant ID / Directory ID"), allow_empty=False, size=45, ), ), ( "client", TextInput( title=_("Client ID / Application ID"), allow_empty=False, size=45, ), ), ( "secret", Password( title=_("Client Secret"), allow_empty=False, size=45, ), ), ( "config", Dictionary( title=_("Retrieve information about..."), # Since we introduced this, Microsoft has already reduced the number # of allowed API requests. At the time of this writing (11/2018) # you can find the number here: # https://docs.microsoft.com/de-de/azure/azure-resource-manager/resource-manager-request-limits help= _("By default, all resources associated to the configured tenant ID" " will be monitored.") + " " + _("However, since Microsoft limits API calls to %s per hour" " (%s per minute), you can restrict the monitoring to individual" " resource groups and resources.") % ("12000", "200"), elements=[ ("explicit", _special_agents_azure_azure_explicit_config()), ("tag_based", _special_agents_azure_azure_tag_based_config()), ], ), ), ( "piggyback_vms", DropdownChoice( title=_("Map data relating to VMs"), help= _("By default, data relating to a VM is sent to the group host" " corresponding to the resource group of the VM, the same way" " as for any other resource. If the VM is present in your " " monitoring as a separate host, you can choose to send the data" " to the VM itself."), choices=[ ("grouphost", _("Map data to group host")), ("self", _("Map data to the VM itself")), ], ), ), ( "sequential", DropdownChoice( title=_("Force agent to run in single thread"), help=_("Check this to turn off multiprocessing." " Recommended for debugging purposes only."), choices=[ (False, _("Run agent multithreaded")), (True, _("Run agent in single thread")), ], ), ), ], optional_keys=["subscription", "piggyback_vms", "sequential"], )
def _parameter_valuespec_tcp_connections(): return Dictionary( help=_( "This rule allows to monitor the existence of specific TCP connections or " "TCP/UDP listeners."), elements=[ ( "proto", DropdownChoice( title=_("Protocol"), choices=[("TCP", _("TCP")), ("UDP", _("UDP"))], default_value="TCP", ), ), ( "state", DropdownChoice(title=_("State"), choices=[ ("ESTABLISHED", "ESTABLISHED"), ("LISTENING", "LISTENING"), ("SYN_SENT", "SYN_SENT"), ("SYN_RECV", "SYN_RECV"), ("LAST_ACK", "LAST_ACK"), ("CLOSE_WAIT", "CLOSE_WAIT"), ("TIME_WAIT", "TIME_WAIT"), ("CLOSED", "CLOSED"), ("CLOSING", "CLOSING"), ("FIN_WAIT1", "FIN_WAIT1"), ("FIN_WAIT2", "FIN_WAIT2"), ("BOUND", "BOUND"), ]), ), ("local_ip", IPv4Address(title=_("Local IP address"))), ("local_port", Integer( title=_("Local port number"), minvalue=1, maxvalue=65535, )), ("remote_ip", IPv4Address(title=_("Remote IP address"))), ("remote_port", Integer( title=_("Remote port number"), minvalue=1, maxvalue=65535, )), ("max_states", Tuple( title=_("Maximum number of connections or listeners"), elements=[ Integer(title=_("Warning at")), Integer(title=_("Critical at")), ], )), ("min_states", Tuple( title=_("Minimum number of connections or listeners"), elements=[ Integer(title=_("Warning if below")), Integer(title=_("Critical if below")), ], )), ], )
def dashlet_vs_general_settings(dashlet_type: Type[Dashlet], single_infos: List[str]): return Dictionary( title=_("General Settings"), render="form", optional_keys=["title", "title_url"], elements=[ ( "type", FixedValue( dashlet_type.type_name(), totext=dashlet_type.title(), title=_("Element type"), ), ), visuals.single_infos_spec(single_infos), ( "background", Checkbox( title=_("Colored background"), label=_("Render background"), help= _("Render gray background color behind the elements content." ), default_value=True, ), ), ( "show_title", DropdownChoice( title=_("Show title header"), help= _("Render the titlebar including title and link above the element." ), choices=[ (False, _("Don't show any header")), (True, _("Show header with highlighted background")), ("transparent", _("Show title without any background")), ], default_value=True, ), ), ( "title", TextInput( title=_("Custom title") + "<sup>*</sup>", placeholder=_( "This option is macro-capable, please check the inline help for more " "information."), help=" ".join(( _("Most elements have a hard coded static title and some are aware of their " "content and set the title dynamically, like the view snapin, which " "displays the title of the view. If you like to use any other title, set it " "here."), _title_help_text_for_macros(dashlet_type), )), size=75, ), ), ( "title_url", TextInput( title=_("Link of Title"), help= _("The URL of the target page the link of the element should link to." ), size=50, ), ), ], )
def _parameter_valuespec_logwatch_ec(): return Alternative( title=_("Forwarding"), help= _("Instead of using the regular logwatch check all lines received by logwatch can " "be forwarded to a Check_MK event console daemon to be processed. The target event " "console can be configured for each host in a separate rule."), style="dropdown", elements=[ FixedValue( "", totext=_("Messages are handled by logwatch."), title=_("No forwarding"), ), Dictionary( title=_('Forward Messages to Event Console'), elements=[ ( 'method', Transform( # TODO: Clean this up to some CascadingDropdown() Alternative( style="dropdown", title=_("Forwarding Method"), elements=[ FixedValue( "", title= _("Local: Send events to local Event Console in same OMD site" ), totext=_( "Directly forward to Event Console" ), ), TextAscii( title= _("Local: Send events to local Event Console into unix socket" ), allow_empty=False, ), FixedValue( "spool:", title= _("Local: Spooling - Send events to local event console in same OMD site" ), totext=_("Spool to Event Console"), ), Transform( TextAscii(allow_empty=False, ), title= _("Local: Spooling - Send events to local Event Console into given spool directory" ), forth=lambda x: x[6:], # remove prefix back=lambda x: "spool:" + x, # add prefix ), CascadingDropdown( title= _("Remote: Send events to remote syslog host" ), choices=[ ( "tcp", _("Send via TCP"), Dictionary( elements=[ ("address", TextAscii( title=_( "Address"), allow_empty=False, )), ("port", Integer( title=_("Port"), default_value=514, minvalue=1, maxvalue=65535, size=6, )), ( "spool", Dictionary( title= _("Spool messages that could not be sent" ), help= _("Messages that can not be forwarded, e.g. when the target Event Console is " "not running, can temporarily be stored locally. Forwarding is tried again " "on next execution. When messages are spooled, the check will go into WARNING " "state. In case messages are dropped by the rules below, the check will shortly " "go into CRITICAL state for this execution." ), elements=[ ( "max_age", Age( title =_( "Maximum spool duration" ), help =_( "Messages that are spooled longer than this time will be thrown away." ), default_value =60 * 60 * 24 * 7, # 1 week should be fine (if size is not exceeded) )), ( "max_size", Filesize( title =_( "Maximum spool size" ), help= _("When the total size of spooled messages exceeds this number, the oldest " "messages of the currently spooled messages is thrown away until the left " "messages have the half of the maximum size." ), default_value = 500000, # do not save more than 500k of message )), ], optional_keys= [], )), ], optional_keys=["spool"], )), ("udp", _("Send via UDP"), Dictionary( elements=[ ("address", TextAscii( title=_("Address"), allow_empty=False, )), ("port", Integer( title=_("Port"), default_value=514, minvalue=1, maxvalue=65535, size=6, )), ], optional_keys=[], )), ], ), ], match=lambda x: 4 if isinstance(x, tuple) else (0 if not x else (2 if x == 'spool:' else (3 if x.startswith('spool:') else 1)))), # migrate old (tcp, address, port) tuple to new dict forth=lambda v: (v[0], { "address": v[1], "port": v[2] }) if (isinstance(v, tuple) and not isinstance( v[1], dict)) else v, )), ( 'facility', DropdownChoice( title=_("Syslog facility for forwarded messages"), help=_( "When forwarding messages and no facility can be extracted from the " "message this facility is used."), choices=mkeventd.syslog_facilities, default_value=17, # local1 )), ( 'restrict_logfiles', ListOfStrings( title= _('Restrict Logfiles (Prefix matching regular expressions)' ), help= _("Put the item names of the logfiles here. For example \"System$\" " "to select the service \"LOG System\". You can use regular expressions " "which must match the beginning of the logfile name." ), ), ), ('monitor_logfilelist', Checkbox( title=_("Monitoring of forwarded logfiles"), label=_("Warn if list of forwarded logfiles changes"), help= _("If this option is enabled, the check monitors the list of forwarded " "logfiles and will warn you if at any time a logfile is missing or exceeding " "when compared to the initial list that was snapshotted during service detection. " "Reinventorize this check in order to make it OK again." ), )), ('expected_logfiles', ListOf( TextUnicode(), title=_("List of expected logfiles"), help= _("When the monitoring of forwarded logfiles is enabled, the check verifies that " "all of the logfiles listed here are reported by the monitored system." ), )), ('logwatch_reclassify', Checkbox( title= _("Reclassify messages before forwarding them to the EC" ), label=_("Apply logwatch patterns"), help= _("If this option is enabled, the logwatch lines are first reclassified by the logwatch " "patterns before they are sent to the event console. If you reclassify specific lines to " "IGNORE they are not forwarded to the event console. This takes the burden from the " "event console to process the message itself through all of its rulesets. The reclassifcation " "of each line takes into account from which logfile the message originates. So you can create " "logwatch reclassification rules specifically designed for a logfile <i>access.log</i>, " "which do not apply to other logfiles."), )), ('separate_checks', Checkbox( title=_("Create a separate check for each logfile"), label=_("Separate check"), help= _("If this option is enabled, there will be one separate check for each logfile found during " "the service discovery. This option also changes the behaviour for unknown logfiles. " "The default logwatch check forwards all logfiles to the event console, even logfiles " "which were not known during the service discovery. Creating one check per logfile changes " "this behaviour so that any data from unknown logfiles is discarded." ), )) ], optional_keys=[ 'restrict_logfiles', 'expected_logfiles', 'logwatch_reclassify', 'separate_checks' ], ignored_keys=['service_level'], ), ], default_value='', )
def _valuespec_special_agents_vsphere(): return Transform( valuespec=Dictionary( title=_("VMWare ESX via vSphere"), help=_( "This rule allows monitoring of VMWare ESX via the vSphere API. " "You can configure your connection settings here.", ), elements=[ ( "user", TextInput( title=_("vSphere User name"), allow_empty=False, ), ), ( "secret", IndividualOrStoredPassword( title=_("vSphere secret"), allow_empty=False, ), ), ( "direct", DropdownChoice( title=_("Type of query"), choices=[ (True, _("Queried host is a host system")), (False, _("Queried host is the vCenter")), ], ), ), ( "tcp_port", Integer( title=_("TCP Port number"), help=_("Port number for HTTPS connection to vSphere"), default_value=443, minvalue=1, maxvalue=65535, ), ), ( "ssl", Alternative( title=_("SSL certificate checking"), elements=[ FixedValue(value=False, title=_("Deactivated"), totext=""), FixedValue(value=True, title=_("Use hostname"), totext=""), TextInput( title=_("Use other hostname"), help= _("The IP of the other hostname needs to be the same IP as the host address" ), ), ], default_value=True, ), ), ( "timeout", Integer( title=_("Connect Timeout"), help= _("The network timeout in seconds when communicating with vSphere or " "to the Check_MK Agent. The default is 60 seconds. Please note that this " "is not a total timeout but is applied to each individual network transation." ), default_value=60, minvalue=1, unit=_("seconds"), ), ), ( "infos", Transform( valuespec=ListChoice( choices=[ ("hostsystem", _("Host Systems")), ("virtualmachine", _("Virtual Machines")), ("datastore", _("Datastores")), ("counters", _("Performance Counters")), ("licenses", _("License Usage")), ], default_value=[ "hostsystem", "virtualmachine", "datastore", "counters" ], allow_empty=False, ), forth=lambda v: [x.replace("storage", "datastore") for x in v], title=_("Retrieve information about..."), ), ), ( "skip_placeholder_vms", Checkbox( title=_("Placeholder VMs"), label=_("Do not monitor placeholder VMs"), default_value=True, true_label=_("ignore"), false_label=_("monitor"), help= _("Placeholder VMs are created by the Site Recovery Manager(SRM) and act as backup " "virtual machines in case the default vm is unable to start. This option tells the " "vsphere agent to exclude placeholder vms in its output." ), ), ), ( "host_pwr_display", DropdownChoice( title=_("Display ESX Host power state on"), choices=[ (None, _("The queried ESX system (vCenter / Host)")), ("esxhost", _("The ESX Host")), ("vm", _("The Virtual Machine")), ], default_value=None, ), ), ( "vm_pwr_display", DropdownChoice( title=_( "Display VM power state <i>additionally</i> on"), help= _("The power state can be displayed additionally either " "on the ESX host or the VM. This will result in services " "for <i>both</i> the queried system and the ESX host / VM. " "By disabling the unwanted services it is then possible " "to configure where the services are displayed."), choices=[ (None, _("The queried ESX system (vCenter / Host)")), ("esxhost", _("The ESX Host")), ("vm", _("The Virtual Machine")), ], default_value=None, ), ), ( "snapshots_on_host", Checkbox( title=_("VM snapshot summary"), label=_("Display snapshot summary on ESX hosts"), default_value=False, help= _("By default the snapshot summary service is displayed on the vCenter. " "Users who run an ESX host on its own or do not include their vCenter in the " "monitoring can choose to display the snapshot summary on the ESX host itself." ), ), ), ( "vm_piggyname", DropdownChoice( title=_("Piggyback name of virtual machines"), choices=[ ("alias", _("Use the name specified in the ESX system")), ( "hostname", _("Use the VMs hostname if set, otherwise fall back to ESX name" ), ), ], default_value="alias", ), ), ( "spaces", DropdownChoice( title=_("Spaces in hostnames"), choices=[ ("cut", _("Cut everything after first space")), ("underscore", _("Replace with underscores")), ], default_value="underscore", ), ), ], optional_keys=[ "tcp_port", "timeout", "vm_pwr_display", "host_pwr_display", "vm_piggyname", ], ignored_keys=["use_pysphere"], ), forth=_transform_agent_vsphere, )
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"], ), forth=lambda x: isinstance(x, dict) and x or {"reclassify_patterns": x}, )
def _valuespec_active_checks_cmk_inv(): return Transform( valuespec=Dictionary( elements=[ ( "sw_changes", MonitoringState( title=_("State when software changes are detected"), default_value=0, ), ), ( "sw_missing", MonitoringState( title=_("State when software packages info is missing"), default_value=0, ), ), ( "hw_changes", MonitoringState( title=_("State when hardware changes are detected"), default_value=0, ), ), ( "fail_status", MonitoringState( title=_("State when inventory fails"), help=_( "The check takes this state in case the inventory cannot be " "updated because of any possible reason. A common use is " "setting this to OK for workstations that can be switched " "off - so you will get no notifications in that case." ), default_value=1, ), ), ( "status_data_inventory", DropdownChoice( title=_("Status data inventory"), help=_( "All hosts configured via this ruleset will do a hardware and " "software inventory after every check cycle if there's at least " "one inventory plugin which processes status data. " "<b>Note:</b> in order to get any useful " "result for agent based hosts make sure that you have installed " "the agent plugin <tt>mk_inventory</tt> on these hosts." ), choices=[ (True, _("Do status data inventory")), (False, _("Do not status data inventory")), ], default_value=True, ), ), ] ), title=_("Do hardware/software inventory"), help=_( "All hosts configured via this ruleset will do a hardware and " "software inventory. For each configured host a new active check " "will be created. You should also create a rule for changing the " "normal interval for that check to something between a couple of " "hours and one day. " "<b>Note:</b> in order to get any useful " "result for agent based hosts make sure that you have installed " "the agent plugin <tt>mk_inventory</tt> on these hosts." ), forth=lambda x: x is not None and x or {}, # convert from legacy None )
def valuespec(self): return DropdownChoice( title=_("Main menu icons"), choices=[(None, _("Per topic")), ("entry", _("Per entry"))], no_preselect_value=False, )
def get_vs_flexible_notifications(): # Make sure, that list is not trivially false def validate_only_services(value, varprefix): for s in value: if s and s[0] != '!': return raise MKUserError(varprefix + "_0", _("The list of services will never match")) return CascadingDropdown( title=_("Notification Method"), choices=[ ("email", _("Plain Text Email (using configured templates)")), ( "flexible", _("Flexible Custom Notifications"), ListOf( Foldable( Dictionary( optional_keys=[ "service_blacklist", "only_hosts", "only_services", "escalation", "match_sl" ], columns=1, elements=[ ( "plugin", DropdownChoice( title=_("Notification Plugin"), choices=notification_script_choices, default_value="mail", ), ), ("parameters", ListOfStrings( title=_("Plugin Arguments"), help= _("You can specify arguments to the notification plugin here. " "Please refer to the documentation about the plugin for what " "parameters are allowed or required here."), )), ("disabled", Checkbox( title=_("Disabled"), label=_("Currently disable this notification"), default_value=False, )), ("timeperiod", cmk.gui.watolib.timeperiods.TimeperiodSelection( title=_("Timeperiod"), help=_("Do only notifiy alerts within this time period"), )), ( "escalation", Tuple( title= _("Restrict to n<sup>th</sup> to m<sup>th</sup> notification (escalation)" ), orientation="float", elements=[ Integer( label=_("from"), help= _("Let through notifications counting from this number" ), default_value=1, minvalue=1, maxvalue=999999, ), Integer( label=_("to"), help= _("Let through notifications counting upto this number" ), default_value=999999, minvalue=1, maxvalue=999999, ), ], ), ), ( "match_sl", Tuple( title=_("Match service level"), help= _("Host or Service must be in the following service level to get notification" ), orientation="horizontal", show_titles=False, elements=[ DropdownChoice(label=_("from:"), choices=cmk.gui.mkeventd.service_levels, prefix_values=True), DropdownChoice(label=_(" to:"), choices=cmk.gui.mkeventd.service_levels, prefix_values=True), ], ), ), ("host_events", ListChoice( title=_("Host Events"), choices=[ ('d', _("Host goes down")), ('u', _("Host gets unreachble")), ('r', _("Host goes up again")), ('f', _("Start or end of flapping state")), ('s', _("Start or end of a scheduled downtime ")), ('x', _("Acknowledgement of host problem")), ], default_value=['d', 'u', 'r', 'f', 's', 'x'], )), ("service_events", ListChoice( title=_("Service Events"), choices=[ ('w', _("Service goes into warning state")), ('u', _("Service goes into unknown state")), ('c', _("Service goes into critical state")), ('r', _("Service recovers to OK")), ('f', _("Start or end of flapping state")), ('s', _("Start or end of a scheduled downtime")), ('x', _("Acknowledgement of service problem")), ], default_value=['w', 'c', 'u', 'r', 'f', 's', 'x'], )), ( "only_hosts", ListOfStrings( title=_("Limit to the following hosts"), help= _("Configure the hosts for this notification. Without prefix, only exact, case sensitive matches, " "<tt>!</tt> for negation and <tt>~</tt> for regex matches." ), orientation="horizontal", # TODO: Clean this up to use an alternative between TextInput() and RegExp(). Also handle the negation in a different way valuespec=TextInput(size=20,), ), ), ( "only_services", ListOfStrings( title=_("Limit to the following services"), help= _("Configure regular expressions that match the beginning of the service names here. Prefix an " "entry with <tt>!</tt> in order to <i>exclude</i> that service." ), orientation="horizontal", # TODO: Clean this up to use an alternative between TextInput() and RegExp(). Also handle the negation in a different way valuespec=TextInput(size=20,), validate=validate_only_services, ), ), ( "service_blacklist", ListOfStrings( title=_("Blacklist the following services"), help= _("Configure regular expressions that match the beginning of the service names here." ), orientation="horizontal", valuespec=RegExp( size=20, mode=RegExp.prefix, ), validate=validate_only_services, ), ), ]), title_function=lambda v: _("Notify by: ") + notification_script_title(v[ "plugin"]), ), title=_("Flexible Custom Notifications"), add_label=_("Add notification"), ), ), ])
def _special_agents_siemens_plc_siemens_plc_value(): return [ Transform( valuespec=CascadingDropdown( title=_("The Area"), choices=[ ( "db", _("Datenbaustein"), Integer( title="<nobr>%s</nobr>" % _("DB Number"), minvalue=1, ), ), ("input", _("Input")), ("output", _("Output")), ("merker", _("Merker")), ("timer", _("Timer")), ("counter", _("Counter")), ], orientation="horizontal", sorted=True, ), # Transform old Integer() value spec to new cascading dropdown value forth=lambda x: isinstance(x, int) and ("db", x) or x, ), Float( title=_("Address"), display_format="%.1f", help= _("Addresses are specified with a dot notation, where number " "before the dot specify the byte to fetch and the number after the " "dot specifies the bit to fetch. The number of the bit is always " "between 0 and 7."), ), CascadingDropdown( title=_("Datatype"), choices=[ ("dint", _("Double Integer (DINT)")), ("real", _("Real Number (REAL)")), ("bit", _("Single Bit (BOOL)")), ( "str", _("String (STR)"), Integer( minvalue=1, title=_("Size"), unit=_("Bytes"), ), ), ( "raw", _("Raw Bytes (HEXSTR)"), Integer( minvalue=1, title=_("Size"), unit=_("Bytes"), ), ), ], orientation="horizontal", sorted=True, ), DropdownChoice( title=_("Type of the value"), choices=[ (None, _("Unclassified")), ("temp", _("Temperature")), ("hours_operation", _("Hours of operation")), ("hours_since_service", _("Hours since service")), ("hours", _("Hours")), ("seconds_operation", _("Seconds of operation")), ("seconds_since_service", _("Seconds since service")), ("seconds", _("Seconds")), ("counter", _("Increasing counter")), ("flag", _("State flag (on/off)")), ("text", _("Text")), ], sorted=True, ), ID( title=_("Ident of the value"), help=_(" An identifier of your choice. This identifier " "is used by the Check_MK checks to access " "and identify the single values. The identifier " "needs to be unique within a group of VALUETYPES."), ), ]
def _vs_elements(with_elements) -> DictionaryElements: yield ("metric", MetricName() ) # MetricChoice would be nicer, but we use the context filters if "time_range" in with_elements: yield "time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ( "current", _("Only show current value"), ), ( "range", _("Show historic values"), Dictionary( optional_keys=False, elements=_time_range_historic_dict_elements( with_elements), ), ), ], default_value="current", ) if "display_range" in with_elements: def validate_range(value, varprefix): _min, _max = value if _min >= _max: raise MKUserError( varprefix, _("Display range: Minimum must be strictly less than maximum" )) yield "display_range", CascadingDropdown( title=_("Display range"), choices=[ ("fixed", _("Fixed range"), ValuesWithUnits( vs_name="display_range", metric_vs_name="metric", help=_("Set the range in which data is displayed. " "Having selected a metric before auto selects " "here the matching unit of the metric."), elements=[_("Minimum"), _("Maximum")], validate_value_elemets=validate_range)), # ("infer", _("Automatic")), # For future logic ], default_value="fixed") if "metric_status_display" in with_elements: yield "metric_status_display", DropdownChoice( title=_("Metric Status"), choices=[(None, _("Metric value is displayed in neutral color")), ("text", _("Metric state is colored in its value")), ("background", _("Metric status is colored on the dashlet background")) ], ) if "status_border" in with_elements: yield "status_border", DropdownChoice( title=_("Status border"), choices=[ (False, _("Do not show any service status border")), ("not_ok", _("Draw a status border when service is not OK")), ("always", _("Always draw the service status on the border")), ], default_value="not_ok")
def vs_bulk_discovery(render_form=False, include_subfolders=True): selection_elements: List[ValueSpec] = [] if include_subfolders: selection_elements.append( Checkbox(label=_("Include all subfolders"), default_value=True)) selection_elements += [ Checkbox( label=_("Only include hosts that failed on previous discovery"), default_value=False), Checkbox(label=_("Only include hosts with a failed discovery check"), default_value=False), Checkbox(label=_("Exclude hosts where the agent is unreachable"), default_value=False), ] return Dictionary( title=_("Bulk discovery"), render="form" if render_form else "normal", elements=[ ( "mode", DropdownChoice( title=_("Mode"), default_value="new", choices=[ ("new", _("Add unmonitored services and new host labels")), ("remove", _("Remove vanished services")), ( "fixall", _("Add unmonitored services and new host labels, remove vanished services" ), ), ("refresh", _("Refresh all services (tabula rasa), add new host labels" )), ("only-host-labels", _("Only discover new host labels")), ], ), ), ("selection", Tuple(title=_("Selection"), elements=selection_elements)), ( "performance", Tuple( title=_("Performance options"), elements=[ Checkbox(label=_("Do a full service scan"), default_value=True), Integer(label=_("Number of hosts to handle at once"), default_value=10), ], ), ), ( "error_handling", Checkbox( title=_("Error handling"), label=_("Ignore errors in single check plugins"), default_value=True, ), ), ], optional_keys=[], )
def _network_scan_elements(self): elements = [ ("ip_ranges", ListOf( self._vs_ip_range(), title=_("IP ranges to scan"), add_label=_("Add new IP range"), text_if_empty=_("No IP range configured"), )), ("exclude_ranges", ListOf( self._vs_ip_range(), title=_("IP ranges to exclude"), add_label=_("Add new IP range"), text_if_empty=_("No exclude range configured"), )), ( "scan_interval", Age( title=_("Scan interval"), display=["days", "hours"], default_value=60 * 60 * 24, minvalue=3600, # 1 hour )), ("time_allowed", Transform( ListOf( TimeofdayRange(allow_empty=False, ), title=_("Time allowed"), help=_( "Limit the execution of the scan to this time range." ), allow_empty=False, style=ListOf.Style.FLOATING, movable=False, default_value=[((0, 0), (24, 0))], ), forth=lambda x: [x] if isinstance(x, tuple) else x, back=sorted, )), ("set_ipaddress", Checkbox( title=_("Set IPv4 address"), help=_( "Whether or not to configure the found IP address as the IPv4 " "address of the found hosts."), default_value=True, )), ] elements += self._optional_tag_criticality_element() elements += [ ("max_parallel_pings", Integer( title=_("Parallel pings to send"), help=_( "Set the maximum number of concurrent pings sent to target IP " "addresses."), minvalue=1, maxvalue=200, default_value=100, )), ("run_as", DropdownChoice( title=_("Run as"), help= _("Execute the network scan in the Check_MK user context of the " "choosen user. This user needs the permission to add new hosts " "to this folder."), choices=self._get_all_user_ids, default_value=lambda: config.user.id, )), ("translate_names", HostnameTranslation(title=_("Translate Hostnames"), )), ] return elements
def _werk_table_option_entries(): translator = cmk.utils.werks.WerkTranslator() return [ ("classes", "double", ListChoice( title=_("Classes"), choices=sorted(translator.classes()), ), ["feature", "fix", "security"]), ("levels", "double", ListChoice( title=_("Levels"), choices=sorted(translator.levels()), ), [1, 2, 3]), ("date", "double", Timerange(title=_("Date")), ('date', (1383149313, int(time.time())))), ("id", "single", TextAscii( title=_("Werk ID"), label="#", regex="^[0-9]{1,5}$", size=7, ), ""), ("compatibility", "single", DropdownChoice(title=_("Compatibility"), choices=[ (["compat", "incomp_ack", "incomp_unack"], _("Compatible and incompatible Werks")), (["compat"], _("Compatible Werks")), (["incomp_ack", "incomp_unack"], _("Incompatible Werks")), (["incomp_unack"], _("Unacknowledged incompatible Werks")), (["incomp_ack"], _("Acknowledged incompatible Werks")), ]), ["compat", "incomp_ack", "incomp_unack"]), ("component", "single", DropdownChoice( title=_("Component"), choices=[ (None, _("All components")), ] + sorted(translator.components()), ), None), ("edition", "single", DropdownChoice( title=_("Edition"), choices=[ (None, _("All editions")), ("cme", _("Werks only concerning the Managed Services Edition")), ("cee", _("Werks only concerning the Enterprise Edition")), ("cre", _("Werks also concerning the Raw Edition")), ], ), None), ("werk_content", "single", TextUnicode( title=_("Werk title or content"), size=41, ), ""), ("version", "single", Tuple(title=_("Checkmk Version"), orientation="float", elements=[ TextAscii(label=_("from:"), size=12), TextAscii(label=_("to:"), size=12), ]), ("", "")), ("grouping", "single", DropdownChoice( title=_("Group Werks by"), choices=[ ("version", _("Checkmk Version")), ("day", _("Day of creation")), ("week", _("Week of creation")), (None, _("Do not group")), ], ), "version"), ("group_limit", "single", Integer( title=_("Show number of groups"), unit=_("groups"), minvalue=1, ), 20), ]
def valuespec(self): return ListOf( DropdownChoice(choices=host_attribute_registry.get_choices), title=_("Locked attributes"), text_if_empty=_("Not locked"), )
def _parameter_valuespec_if(): # Transform old traffic related levels which used "traffic" and "traffic_minimum" # keys where each was configured with an Alternative valuespec return Transform( Dictionary( ignored_keys=["aggregate"], # Created by discovery when using interface grouping elements=[ ("errors_in", _vs_if_errors("IN")), ("errors_out", _vs_if_errors("OUT")), ("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 100Mbit/s instead of 1Gbit/s.<b>Note:</b> " "some interfaces do not provide speed information. In such cases " "this setting is used as the assumed speed when it comes to " "traffic monitoring (see below)."), choices=[ (None, _("ignore speed")), (10000000, "10 Mbit/s"), (100000000, "100 Mbit/s"), (1000000000, "1 Gbit/s"), (10000000000, "10 Gbit/s"), ], otherlabel=_("specify manually ->"), explicit=Integer(title=_("Other speed in bits per second"), label=_("Bits per second")))), ("state", Optional( ListChoice(title=_("Allowed states:"), choices=defines.interface_oper_states()), title=_("Operational state"), help= _("If you activate the monitoring of the operational state (<tt>ifOperStatus</tt>) " "the check will get warning or critical if the current state " "of the interface does not match one of the expected states. Note: the status 9 (<i>admin down</i>) " "is only visible if you activate this status during switch port inventory or if you manually " "use the check plugin <tt>if64adm</tt> instead of <tt>if64</tt>."), label=_("Ignore the operational state"), none_label=_("ignore"), negate=True)), ("map_operstates", ListOf( Tuple(orientation="horizontal", elements=[ ListChoice(choices=defines.interface_oper_states()), MonitoringState() ]), title=_('Map operational states'), )), ("assumed_speed_in", OptionalDropdownChoice( title=_("Assumed input speed"), help=_( "If the automatic detection of the link speed does not work " "or the switch's capabilities are throttled because of the network setup " "you can set the assumed speed here."), choices=[ (None, _("ignore speed")), (10000000, "10 Mbit/s"), (100000000, "100 Mbit/s"), (1000000000, "1 Gbit/s"), (10000000000, "10 Gbit/s"), ], otherlabel=_("specify manually ->"), default_value=16000000, explicit=Integer(title=_("Other speed in bits per second"), label=_("Bits per second"), size=10))), ("assumed_speed_out", OptionalDropdownChoice( title=_("Assumed output speed"), help=_( "If the automatic detection of the link speed does not work " "or the switch's capabilities are throttled because of the network setup " "you can set the assumed speed here."), choices=[ (None, _("ignore speed")), (10000000, "10 Mbit/s"), (100000000, "100 Mbit/s"), (1000000000, "1 Gbit/s"), (10000000000, "10 Gbit/s"), ], otherlabel=_("specify manually ->"), default_value=1500000, explicit=Integer(title=_("Other speed in bits per second"), label=_("Bits per second"), size=12))), ("unit", DropdownChoice( title=_("Measurement unit"), help=_("Here you can specifiy the measurement unit of the network interface"), default_value="byte", choices=[ ("bit", _("Bits")), ("byte", _("Bytes")), ], )), ("infotext_format", DropdownChoice( title=_("Change infotext in check output"), help= _("This setting allows you to modify the information text which is displayed between " "the two brackets in the check output. Please note that this setting does not work for " "grouped interfaces, since the additional information of grouped interfaces is different" ), choices=[ ("alias", _("Show alias")), ("description", _("Show description")), ("alias_and_description", _("Show alias and description")), ("alias_or_description", _("Show alias if set, else description")), ("desription_or_alias", _("Show description if set, else alias")), ("hide", _("Hide infotext")), ])), ("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."), )), ( "nucasts", Tuple( title=_("Non-unicast packet rates"), help=_( "Setting levels on non-unicast packet rates is optional. This may help " "to detect broadcast storms and other unwanted traffic."), elements=[ Integer(title=_("Warning at"), unit=_("pkts / sec")), Integer(title=_("Critical at"), unit=_("pkts / sec")), ]), ), ("discards", Tuple(title=_("Absolute levels for discards rates"), elements=[ Integer(title=_("Warning at"), unit=_("discards")), Integer(title=_("Critical at"), unit=_("discards")) ])), ("average", Integer( title=_("Average values"), help=_("By activating the computation of averages, the levels on " "errors and traffic are applied to the averaged value. That " "way you can make the check react only on long-time changes, " "not on one-minute events."), unit=_("minutes"), minvalue=1, default_value=15, )), ("match_same_speed", DropdownChoice(title=_("Speed of interface groups (Netapp only)"), help=_("Choose the behaviour for different interface speeds in " "interface groups. The default is \"Check and WARN\". This " "feature is currently only supported by the check " "netapp_api_if."), choices=[ ("check_and_warn", _("Check and WARN")), ("check_and_crit", _("Check and CRIT")), ("check_and_display", _("Check and display only")), ("dont_show_and_check", _("Don't show and check")), ])), ("home_port", DropdownChoice(title=_("Is-Home state (Netapp only)"), help=_("Choose the behaviour when the current port is not the " "home port of the respective interface. The default is " "\"Check and Display\". This feature is currently only " "supported by the check netapp_api_if."), choices=[ ("check_and_warn", _("Check and WARN")), ("check_and_crit", _("Check and CRIT")), ("check_and_display", _("Check and display only")), ("dont_show_and_check", _("Don't show home port info")), ])), ], ), forth=transform_if, )
def _valuespec_special_agents_jenkins(): return Transform( valuespec=Dictionary( title=_("Jenkins jobs and builds"), help=_("Requests data from a jenkins instance."), optional_keys=["port"], elements=[ ( "instance", TextInput( title=_("Jenkins instance to query."), help=_( "Use this option to set which instance should be " "checked by the special agent. Please add the " "hostname here, eg. my_jenkins.com."), size=32, allow_empty=False, ), ), ( "user", TextInput( title=_("Username"), help= _("The username that should be used for accessing the " "jenkins API. Has to have read permissions at least." ), size=32, allow_empty=False, ), ), ( "password", PasswordFromStore( help=_("The password or API key of the user."), title=_("Password of the user"), allow_empty=False, ), ), ( "protocol", DropdownChoice( title=_("Protocol"), choices=[ ("http", "HTTP"), ("https", "HTTPS"), ], default_value="https", ), ), ( "port", Integer( title=_("Port"), help= _("Use this option to query a port which is different from standard port 8080." ), default_value=443, ), ), ( "sections", ListChoice( title=_("Informations to query"), help= _("Defines what information to query. You can choose " "between the instance state, job states, node states " "and the job queue."), choices=[ ("instance", _("Instance state")), ("jobs", _("Job state")), ("nodes", _("Node state")), ("queue", _("Queue info")), ], default_value=["instance", "jobs", "nodes", "queue"], allow_empty=False, ), ), ], ), forth=_transform_jenkins_infos, )
def item_spec(self): return DropdownChoice(title=_(u"Host or Disk"), choices=[ ("Disk", _(u"Disk")), ("Host", _(u"Host")), ])
def _parameter_valuespec_oracle_tablespaces(): return Dictionary( help= _("A tablespace is a container for segments (tables, indexes, etc). A " "database consists of one or more tablespaces, each made up of one or " "more data files. Tables and indexes are created within a particular " "tablespace. " "This rule allows you to define checks on the size of tablespaces."), elements=db_levels_common() + [ ( "autoextend", DropdownChoice( title=_("Expected autoextend setting"), choices=[ (True, _("Autoextend is expected to be ON")), (False, _("Autoextend is expected to be OFF")), (None, _("Autoextend will be ignored")), ], ), ), ( "autoextend_severity", MonitoringState( title=_("Severity of invalid autoextend setting"), default_value=2, ), ), ( "defaultincrement", DropdownChoice( title=_("Default Increment"), choices=[ (True, _("State is WARNING in case the next extent has the default size." )), (False, _("Ignore default increment")), ], ), ), ( "map_file_online_states", ListOf( valuespec=Tuple( orientation="horizontal", elements=[ DropdownChoice(choices=[ ("RECOVER", _("Recover")), ("OFFLINE", _("Offline")), ], ), MonitoringState(), ], ), title=_("Map file online states"), ), ), ( "temptablespace", DropdownChoice( title=_("Monitor temporary Tablespace"), choices=[ (False, _("Ignore temporary Tablespaces (Default)")), (True, _("Apply rule to temporary Tablespaces")), ], ), ), ], )