def _vs_add_common_mail_elements(elements): header = [ ("from", Transform( Dictionary( title="From", elements=[ ("address", EmailAddress( title=_("Email address"), size=40, allow_empty=False, )), ("display_name", TextUnicode( title=_("Display name"), size=40, allow_empty=False, )), ], help= _("The email address and visible name used in the From header " "of notifications messages. If no email address is specified " "the default address is <tt>OMD_SITE@FQDN</tt> is used. If the " "environment variable <tt>OMD_SITE</tt> is not set it defaults " "to <tt>checkmk</tt>."), ), forth=lambda x: x if isinstance(x, dict) else {'address': x}, )), ("reply_to", Transform( Dictionary( title="Reply to", elements=[ ("address", EmailAddress( title=_("Email address"), size=40, allow_empty=False, )), ("display_name", TextUnicode( title=_("Display name"), size=40, allow_empty=False, )), ], required_keys=["address"], help=_( "The email address and visible name used in the Reply-To header " "of notifications messages."), ), forth=lambda x: x if isinstance(x, dict) else {'address': x}, )), ("host_subject", TextUnicode( title=_("Subject for host notifications"), help=_( "Here you are allowed to use all macros that are defined in the " "notification context."), default_value="Check_MK: $HOSTNAME$ - $EVENT_TXT$", size=64, )), ("service_subject", TextUnicode( title=_("Subject for service notifications"), help=_( "Here you are allowed to use all macros that are defined in the " "notification context."), default_value="Check_MK: $HOSTNAME$/$SERVICEDESC$ $EVENT_TXT$", size=64, )), ] footer = [ ('bulk_sort_order', DropdownChoice( choices=[ ('oldest_first', _('Oldest first')), ('newest_first', _('Newest first')), ], help= _("With this option you can specify, whether the oldest (default) or " "the newest notification should get shown at the top of the notification mail." ), title=_("Notification sort order for bulk notifications"), default_value="oldest_first", )), ("disable_multiplexing", FixedValue( True, title=_("Send seperate notifications to every recipient"), totext=_( "A seperate notification is send to every recipient. Recipients " "cannot see which other recipients were notified."), help= _("Per default only one notification is generated for all recipients. " "Therefore, all recipients can see who was notified and reply to " "all other recipients."), )), ] return header + elements + footer
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", "discovered_oper_status", "discovered_admin_status", "discovered_speed", ], # Created by discovery 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 operational 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 go critical if the current " "state of the interface does not match one of the expected states."), 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'), help=_( 'Map the operational state (<tt>ifOperStatus</tt>) to a monitoring state.') )), ("admin_state", Optional( ListChoice(title=_("Allowed admin states:"), choices=_admin_states()), title=_("Admin state (SNMP with 64-bit counters only)"), help=_("If you activate the monitoring of the admin state " "(<tt>ifAdminStatus</tt>), the check will go critical if the " "current state of the interface does not match one of the expected " "states. " + _note_for_admin_state_options()), label=_("Ignore the admin state"), none_label=_("ignore"), negate=True)), ("map_admin_states", ListOf( Tuple(orientation="horizontal", elements=[ListChoice(choices=_admin_states()), MonitoringState()]), title=_('Map admin states (SNMP with 64-bit counters only)'), help=_("Map the admin state (<tt>ifAdminStatus</tt>) to a monitoring state. " + _note_for_admin_state_options()), )), ("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."), )), ("average", Integer( title=_("Average values for used bandwidth"), help=_("By activating the computation of averages, the levels on " "traffic and speed 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, )), ( "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")), ]), ), ("multicast", Alternative(title=_("Multicast packet rates"), help=_( "These levels make the check go warning or critical whenever the " "<b>percentual packet rate</b> or the <b>absolute packet " "rate</b> of the monitored interface reaches the given " "bounds. The percentual packet rate is computed by " "dividing the number of multicast packets by the number " "of unicast packets."), elements=[ Tuple(title=_("Percentual levels for multicast packets"), elements=[ Percentage(title=_("Warning at"), unit=_("percent packets"), default_value=10.0, display_format='%.3f'), Percentage(title=_("Critical at"), unit=_("percent packets"), default_value=20.0, display_format='%.3f') ]), Tuple(title=_("Absolute levels for multicast packets"), elements=[ Integer(title=_("Warning at"), unit=_("pkts / sec")), Integer(title=_("Critical at"), unit=_("pkts / sec")) ]) ])), ("broadcast", Alternative(title=_("Broadcast packet rates"), help=_( "These levels make the check go warning or critical whenever the " "<b>percentual packet rate</b> or the <b>absolute packet " "rate</b> of the monitored interface reaches the given " "bounds. The percentual packet rate is computed by " "dividing the number of broadcast packets by the number " "of unicast packets."), elements=[ Tuple(title=_("Percentual levels for broadcast packets"), elements=[ Percentage(title=_("Warning at"), unit=_("percent packets"), default_value=10.0, display_format='%.3f'), Percentage(title=_("Critical at"), unit=_("percent packets"), default_value=20.0, display_format='%.3f') ]), Tuple(title=_("Absolute levels for broadcast packets"), elements=[ Integer(title=_("Warning at"), unit=_("pkts / sec")), Integer(title=_("Critical at"), unit=_("pkts / sec")) ]) ])), ("average_bm", Integer( title=_("Average values for broad- and multicast packet rates"), help=_( "By activating the computation of averages, the levels on " "broad- and multicast packet rates 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, )), ("discards", Tuple(title=_("Absolute levels for discards rates"), elements=[ Integer(title=_("Warning at"), unit=_("discards")), Integer(title=_("Critical at"), unit=_("discards")) ])), ("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(self): 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 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', TextUnicode( 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', TextUnicode( title=_('Link of Title'), help= _('The URL of the target page the link of the element should link to.' ), size=50, )), ], )
def vs_graph_render_option_elements(default_values=None, exclude=None): # Allow custom default values to be specified by the caller. This is, for example, # needed by the dashlets which should add the host/service by default. if default_values is None: default_values = artwork.get_default_graph_render_options() else: default_values = default_values.copy() for k, v in artwork.get_default_graph_render_options().items(): default_values.setdefault(k, v) elements = [ ("font_size", Fontsize(default_value=default_values["font_size"], )), ("show_title", DropdownChoice( title=_("Title"), choices=[ (False, _("Don't show graph title")), (True, _("Show graph title")), ("inline", _("Show graph title on graph area")), ], default_value=default_values["show_title"], )), ("title_format", Transform( CascadingDropdown( title=_("Title format"), orientation="vertical", choices=[ ("plain", _("Just show graph title")), ("add_title_infos", _("Add additional information"), ListChoice(choices=[ ("add_host_name", _("Add host name")), ("add_host_alias", _("Add host alias")), ("add_service_description", _("Add service description")), ])), ], ), forth=transform_graph_render_options_title_format, )), ("show_graph_time", Checkbox( title=_("Show graph time range"), label=_("Show the graph time range on top of the graph"), default_value=default_values["show_graph_time"], )), ("show_margin", Checkbox( title=_("Show margin round the graph"), label=_("Show a margin round the graph"), default_value=default_values["show_margin"], )), ("show_legend", Checkbox( title=_("Show legend"), label=_("Show the graph legend"), default_value=default_values["show_legend"], )), ("show_vertical_axis", Checkbox( title=_("Show vertical axis"), label=_("Show the graph vertical axis"), default_value=default_values["show_vertical_axis"], )), ("vertical_axis_width", CascadingDropdown( title=_("Vertical axis width"), orientation="horizontal", choices=[ ("fixed", _("Use fixed width (relative to font size)")), ("explicit", _("Use absolute width:"), Float(title="", default_value=40.0, unit=_("pt"))), ], )), ("show_time_axis", Checkbox( title=_("Show time axis"), label=_("Show the graph time axis"), default_value=default_values["show_time_axis"], )), ("show_controls", Checkbox( title=_("Show controls"), label=_("Show the graph controls"), default_value=default_values["show_controls"], )), ("show_pin", Checkbox( title=_("Show pin"), label=_("Show the pin"), default_value=default_values["show_pin"], )), ("show_time_range_previews", Checkbox( title=_("Show time range previews"), label="Show previews", default_value=default_values["show_time_range_previews"], )), ("foreground_color", GraphColor( title=_("Foreground color"), default_value=default_values["foreground_color"], )), ("background_color", GraphColor( title=_("Background color"), default_value=default_values["background_color"], )), ("canvas_color", GraphColor( title=_("Canvas color"), default_value=default_values["canvas_color"], )), ] if exclude: elements = [x for x in elements if x[0] not in exclude] return elements
def valuespec(self): return DropdownChoice( title=_("Main menu icons"), choices=[(None, _("Per topic")), ("entry", _("Per entry"))], no_preselect_value=False, )
def parameter_valuespec(self): return Dictionary(elements=[ ("rtt_type", DropdownChoice( title=_("RTT type"), choices=[ ('echo', _("echo")), ('path echo', _("path echo")), ('file IO', _("file IO")), ('UDP echo', _("UDP echo")), ('TCP connect', _("TCP connect")), ('HTTP', _("HTTP")), ('DNS', _("DNS")), ('jitter', _("jitter")), ('DLSw', _("DLSw")), ('DHCP', _("DHCP")), ('FTP', _("FTP")), ('VoIP', _("VoIP")), ('RTP', _("RTP")), ('LSP group', _("LSP group")), ('ICMP jitter', _("ICMP jitter")), ('LSP ping', _("LSP ping")), ('LSP trace', _("LSP trace")), ('ethernet ping', _("ethernet ping")), ('ethernet jitter', _("ethernet jitter")), ('LSP ping pseudowire', _("LSP ping pseudowire")), ], default_value="echo", )), ("threshold", Integer( title=_("Treshold"), help=_("Depending on the precision the unit can be " "either milliseconds or micoseconds."), unit=_("ms/us"), minvalue=1, default_value=5000, )), ("state", DropdownChoice( title=_("State"), choices=[ ('active', _("active")), ('inactive', _("inactive")), ('reset', _("reset")), ('orderly stop', _("orderly stop")), ('immediate stop', _("immediate stop")), ('pending', _("pending")), ('restart', _("restart")), ], default_value="active", )), ("connection_lost_occured", DropdownChoice( title=_("Connection lost occured"), choices=[ ("yes", _("yes")), ("no", _("no")), ], default_value="no", )), ("timeout_occured", DropdownChoice( title=_("Timeout occured"), choices=[ ("yes", _("yes")), ("no", _("no")), ], default_value="no", )), ("completion_time_over_treshold_occured", DropdownChoice( title=_("Completion time over treshold occured"), choices=[ ("yes", _("yes")), ("no", _("no")), ], default_value="no", )), ("latest_rtt_completion_time", Tuple( title=_("Latest RTT completion time"), help=_("Depending on the precision the unit can be " "either milliseconds or micoseconds."), elements=[ Integer( title=_("Warning at"), unit=_("ms/us"), minvalue=1, default_value=100, ), Integer( title=_("Critical at"), unit=_("ms/us"), minvalue=1, default_value=200, ), ], )), ("latest_rtt_state", DropdownChoice( title=_("Latest RTT state"), choices=[ ('ok', _("OK")), ('disconnected', _("disconnected")), ('over treshold', _("over treshold")), ('timeout', _("timeout")), ('other', _("other")), ], default_value="ok", )), ],)
def page(self): check_csrf_token() if not user.may("wato.diag_host"): raise MKAuthException(_("You are not permitted to perform this action.")) if not transactions.check_transaction(): raise MKAuthException(_("Invalid transaction")) api_request = self.webapi_request() hostname = api_request.get("host") if not hostname: raise MKGeneralException(_("The hostname is missing.")) host = Host.host(hostname) if not host: raise MKGeneralException(_("The given host does not exist.")) if host.is_cluster(): raise MKGeneralException(_("This view does not support cluster hosts.")) host.need_permission("read") _test = api_request.get("_test") if not _test: raise MKGeneralException(_("The test is missing.")) # Execute a specific test if _test not in dict(ModeDiagHost.diag_host_tests()): raise MKGeneralException(_("Invalid test.")) # TODO: Use ModeDiagHost._vs_rules() for processing/validation? args: List[str] = [""] * 13 for idx, what in enumerate( [ "ipaddress", "snmp_community", "agent_port", "snmp_timeout", "snmp_retries", "tcp_connect_timeout", ] ): args[idx] = api_request.get(what, "") if api_request.get("snmpv3_use"): snmpv3_use = { "0": "noAuthNoPriv", "1": "authNoPriv", "2": "authPriv", }.get(api_request.get("snmpv3_use", ""), "") args[7] = snmpv3_use if snmpv3_use != "noAuthNoPriv": snmpv3_auth_proto = { str(DropdownChoice.option_id("md5")): "md5", str(DropdownChoice.option_id("sha")): "sha", }.get(api_request.get("snmpv3_auth_proto", ""), "") args[8] = snmpv3_auth_proto args[9] = api_request.get("snmpv3_security_name", "") args[10] = api_request.get("snmpv3_security_password", "") if snmpv3_use == "authPriv": snmpv3_privacy_proto = { str(DropdownChoice.option_id("DES")): "DES", str(DropdownChoice.option_id("AES")): "AES", }.get(api_request.get("snmpv3_privacy_proto", ""), "") args[11] = snmpv3_privacy_proto args[12] = api_request.get("snmpv3_privacy_password", "") else: args[9] = api_request.get("snmpv3_security_name", "") result = diag_host( host.site_id(), hostname, _test, *args, ) return { "next_transid": transactions.fresh_transid(), "status_code": result.return_code, "output": result.response, }
def value_to_text(self, value): text = DropdownChoice.value_to_text(self, value) return text.split(" - ")[-1]
def _valuespec_active_checks_traceroute(): return Transform( valuespec=Dictionary( title=_("Check current routing"), help= _("This active check uses <tt>traceroute</tt> in order to determine the current " "routing from the monitoring host to the target host. You can specify any number " "of missing or expected routes in order to detect e.g. an (unintended) failover " "to a secondary route."), elements=[ ( "dns", Checkbox( title=_("Name resolution"), label=_( "Use DNS to convert IP addresses into hostnames"), help= _("If you use this option, then <tt>traceroute</tt> is <b>not</b> being " "called with the option <tt>-n</tt>. That means that all IP addresses " "are tried to be converted into names. This usually adds additional " "execution time. Also DNS resolution might fail for some addresses." ), ), ), ip_address_family_element(), ( "routers", ListOf( valuespec=Tuple(elements=[ TextInput( title=_("Router (FQDN, IP-Address)"), allow_empty=False, ), DropdownChoice( title=_("How"), choices=[ ("W", _("WARN - if this router is not being used" )), ("C", _("CRIT - if this router is not being used" )), ("w", _("WARN - if this router is being used")), ("c", _("CRIT - if this router is being used")), ], ), ]), title=_("Router that must or must not be used"), add_label=_("Add Condition"), ), ), ( "method", DropdownChoice( title=_("Method of probing"), choices=[ (None, _("UDP (default behaviour of traceroute)")), ("icmp", _("ICMP Echo Request")), ("tcp", _("TCP SYN")), ], ), ), ], optional_keys=False, ), forth=transform_add_address_family, )
def _parameter_valuespec_services(): return Dictionary(elements=[ ( "additional_servicenames", ListOfStrings( title=_("Alternative names for the service"), help= _("Here you can specify alternative names that the service might have. " "This helps when the exact spelling of the services can changed from " "one version to another."), ), ), ( "states", ListOf( valuespec=Tuple( orientation="horizontal", elements=[ DropdownChoice( title=_("Expected state"), default_value="running", choices=[ (None, _("ignore the state")), ("running", _("running")), ("stopped", _("stopped")), ], ), DropdownChoice( title=_("Start type"), default_value="auto", choices=[ (None, _("ignore the start type")), ("demand", _("demand")), ("disabled", _("disabled")), ("auto", _("auto")), ("unknown", _("unknown (old agent)")), ], ), MonitoringState(title=_("Resulting state"), ), ], default_value=("running", "auto", 0), ), title=_("Services states"), help= _("You can specify a separate monitoring state for each possible " "combination of service state and start type. If you do not use " "this parameter, then only running/auto will be assumed to be OK." ), ), ), ( "else", MonitoringState( title=_("State if no entry matches"), default_value=2, ), ), ( "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(self): # Drop Main directory represented by empty string, because it means # don't filter after any folder due to recursive folder filtering. choices = [entry for entry in self.choices() if entry[0]] return ListOf(DropdownChoice(title=_("folders"), choices=choices))
def process_level_elements(): return [ ("cpu_rescale_max", RadioChoice( 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, orientation="vertical", choices=[ (True, _("100% is all cores at full load")), (False, _("<b>N</b> * 100% as each core contributes with 100% at full load" )), ])), ('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), ], )), ("max_age", Tuple( title=_("Maximum allowed age"), help=_( "Alarms you if the age of the process (not the consumed CPU " "time, but the real time) exceed the configured levels."), 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 \"Escape HTML codes in " "plugin output\" is disabled in global settings. This might expose you to " "Cross-Site-Scripting (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." ), choices=[ (None, _("Disable")), ("text", _("Text output")), ("html", _("HTML output")), ], default_value="disable", )), ('icon', UserIconOrAction( title=_("Add custom icon or action"), help= _("You can assign icons or actions to the found services in the status GUI." ), )), ]
def spec(self): return Dictionary( title=_("Create notification with the following parameters"), required_keys=[ 'password', ], elements=[ ("password", PasswordFromStore( title=_( "API Key to use. Depending on your opsgenie " "subscription you can use global or team integration api " "keys."), allow_empty=False, )), ("url", TextAscii( title=_("Domain (only used for european accounts)"), help=_( "If you have an european account, please set the " "domain of your opsgenie. Specify an absolute URL like " "https://api.eu.opsgenie.com."), regex="^https://.*", regex_error=_("The URL must begin with <tt>https</tt>."), size=64, )), ("owner", TextUnicode( title=_("Owner"), help=("Sets the user of the alert. " "Display name of the request owner."), size=100, allow_empty=False, )), ("source", TextUnicode( title=_("Source"), help=_("Source field of the alert. Default value is IP " "address of the incoming request."), size=16, )), ('priority', DropdownChoice( title=_("Priority"), choices=[ ('P1', _('P1 - Critical')), ('P2', _('P2 - High')), ('P3', _('P3 - Moderate')), ('P4', _('P4 - Low')), ('P5', _('P5 - Informational')), ], default_value="P3", )), ("note_created", TextUnicode( title=_("Note while creating"), help= _("Additional note that will be added while creating the alert." ), default_value="Alert created by Check_MK", )), ("note_closed", TextUnicode( title=_("Note while closing"), help= _("Additional note that will be added while closing the alert." ), default_value="Alert closed by Check_MK", )), ("host_msg", TextUnicode( title=_("Description for host alerts"), help=_( "Description field of host alert that is generally " "used to provide a detailed information about the " "alert."), default_value="Check_MK: $HOSTNAME$ - $HOSTSHORTSTATE$", size=64, )), ("svc_msg", TextUnicode( title=_("Description for service alerts"), help=_( "Description field of service alert that is generally " "used to provide a detailed information about the " "alert."), default_value= "Check_MK: $HOSTNAME$/$SERVICEDESC$ $SERVICESHORTSTATE$", size=68, )), ("host_desc", TextAreaUnicode(title=_("Message for host alerts"), rows=7, cols=58, monospaced=True, default_value="""Host: $HOSTNAME$ Event: $EVENT_TXT$ Output: $HOSTOUTPUT$ Perfdata: $HOSTPERFDATA$ $LONGHOSTOUTPUT$ """)), ("svc_desc", TextAreaUnicode(title=_("Message for service alerts"), rows=11, cols=58, monospaced=True, default_value="""Host: $HOSTNAME$ Service: $SERVICEDESC$ Event: $EVENT_TXT$ Output: $SERVICEOUTPUT$ Perfdata: $SERVICEPERFDATA$ $LONGSERVICEOUTPUT$ """)), ("teams", ListOfStrings( title=_("Responsible teams"), help=_( "Team names which will be responsible for the alert. " "If the API Key belongs to a team integration, " "this field will be overwritten with the owner " "team."), allow_empty=False, orientation="horizontal", )), ("actions", ListOfStrings( title=_("Actions"), help=_( "Custom actions that will be available for the alert." ), allow_empty=False, orientation="horizontal", )), ("tags", ListOfStrings( title=_("Tags"), help=_("Tags of the alert."), allow_empty=False, orientation="horizontal", )), ("entity", TextUnicode( title=_("Entity"), help= _("Is used to specify which domain the alert is related to." ), allow_empty=False, size=68, )), ], )
def valuespec(self): return ListOf( DropdownChoice(choices=host_attribute_registry.get_choices), title=_("Locked attributes"), text_if_empty=_("Not locked"), )
def _valuespec_active_checks_dns(): return Transform( valuespec=Dictionary( title=_("Check DNS service"), help= _("Check the resolution of a hostname into an IP address by a DNS " "server. This check uses <tt>check_dns</tt> from the standard " "Nagios plugins. Note, that check_dns will always be executed in " "the monitoring site. By default, the configured host(s) that " "this rule applies to is used as DNS server. This behaviour can " "be configured by using the option <tt>DNS Server</tt>. "), elements=[ ( "hostname", TextInput( title=_("Queried Hostname or IP address"), allow_empty=False, help=_("The name or IPv4 address you want to query"), ), ), ( "name", TextInput( title=_("Alternative Service description"), help= _("The service description will be this name instead <i>DNS Servername</i>" ), ), ), ( "server", Alternative( title=_("DNS Server"), help=_( "The DNS server you want to use for the lookup"), elements=[ FixedValue( value=None, title= _("Use the address of the host for which the service is generated" ), totext=_("This option is set by default."), ), TextInput( title=_("Specify DNS Server"), allow_empty=False, ), FixedValue( value="default DNS server", title= _("Use the default DNS server(s) specified in /etc/resolv.conf" ), ), ], ), ), ( "expect_all_addresses", DropdownChoice( title=_("Address matching"), choices=[ (True, _("Expect all of the addresses")), (False, _("Expect at least one of the addresses")), ], ), ), ( "expected_addresses_list", ListOfStrings( title=_("Expected DNS answers"), help= _("List all allowed expected answers here. If query for an " "IP address then the answer will be host names, that end " "with a dot."), ), ), ( "expected_authority", FixedValue( value=True, title=_("Expect Authoritative DNS Server"), totext=_("Expect Authoritative"), ), ), ( "response_time", Tuple( title=_("Expected response time"), elements=[ Float(title=_("Warning if above"), unit=_("sec"), default_value=1), Float(title=_("Critical if above"), unit=_("sec"), default_value=2), ], ), ), ( "timeout", Integer( title=_("Seconds before connection times out"), unit=_("sec"), default_value=10, ), ), ], required_keys=["hostname", "server"], ), forth=_transform_check_dns_settings, )
def _parameter_valuespec_jenkins_nodes(): return Dictionary(elements=[ ("jenkins_offline", MonitoringState(title=_("Node state: Offline"), default_value=2)), ("jenkins_mode", DropdownChoice( title=_("Expected mode state."), help=_("Choose between Normal (Utilize this node as much " "as possible) and Exclusive (Only build jobs with label " "restrictions matching this node). The state will " "change to warning state, if the mode differs."), choices=[ ("NORMAL", _("Normal")), ("EXCLUSIVE", _("Exclusive")), ], default_value="NORMAL", )), ('jenkins_numexecutors', Tuple( title=_("Lower level for number of executors of this node"), elements=[ Integer(title=_("Warning below")), Integer(title=_("Critical below")), ], )), ('jenkins_busyexecutors', Tuple( title=_("Upper level for number of busy executors of this node"), elements=[ Integer(title=_("Warning at")), Integer(title=_("Critical at")), ], )), ('jenkins_idleexecutors', Tuple( title=_("Upper level for number of idle executors of this node"), elements=[ Integer(title=_("Warning at")), Integer(title=_("Critical at")), ], )), ('avg_response_time', Tuple( title=_("Average round-trip response time to this node"), elements=[ Age(title=_("Warning at")), Age(title=_("Critical at")), ], )), ('jenkins_clock', Tuple( title=_("Clock difference"), elements=[ Age(title=_("Warning at")), Age(title=_("Critical at")), ], )), ("jenkins_temp", Tuple( title=_("Absolute levels for free temp space"), elements=[ Integer( title=_("Warning if below"), unit=_("MB"), minvalue=0, ), Integer( title=_("Critical if below"), unit=_("MB"), minvalue=0, ), ], )), ], )
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]{4}", allow_empty=True, size=4, ), ""), ("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 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=[], )
Transform( get_free_used_dynamic_valuespec("free", "filesystem", default_value=(20.0, 10.0)), title=_("Levels for filesystem free space"), forth=transform_filesystem_free, back=transform_filesystem_free, ) ], )), ("show_levels", DropdownChoice( title=_("Display warn/crit levels in check output..."), choices=[ ("onproblem", _("Only if the status is non-OK")), ("onmagic", _("If the status is non-OK or a magic factor is set")), ("always", _("Always")), ], default_value="onmagic", )), ] # Note: This hack is only required on very old filesystem checks (prior August 2013) fs_levels_elements_hack = [ # Beware: this is a nasty hack that helps us to detect new-style parameters. # Something hat has todo with float/int conversion and has not been documented # by the one who implemented this. ("flex_levels", FixedValue( None, totext="", title="",
def valuespec(self): return DropdownChoice( title=_("Sidebar position"), # FIXME: Why isn't this simply a bool instead of an Optional[Literal["left"]]? choices=[(None, _("Right")), ("left", _("Left"))], )
def _vs_elements(cls): return [ ("metric", MetricName() ), # MetricChoice would be nicer, but we use the context filters ("time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ("current", _("Only show current value")), ("range", _("Show historic values"), Dictionary( optional_keys=False, elements=[ ('window', Timerange(title=_("Time range to consider"), default_value="d0", allow_empty=True)), ("rrd_consolidation", DropdownChoice( choices=[ ("average", _("Average")), ("min", _("Minimum")), ("max", _("Maximum")), ], default_value="max", title="RRD consolidation", help= _("Consolidation function for the [cms_graphing#rrds|RRD] data column" ), )), ])), ], default_value="current")), ("display_range", CascadingDropdown( title=_("Display range"), choices=[ ("infer", _("Infer range from available data and check output")), ("fixed", _("Fixed range"), Tuple( title=_("Fixed range"), help=_( "Use a fixed range for the Data displayed. This " "value has no scaling. If your metric is in the " "range of MB, you'll need to place 9 zeros for " "display to make sense."), elements=[ Float(title=_("Minimum")), Float(title=_("Maximum")), ])), ])), ("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 valuespec(self): return DropdownChoice( title=_("Sidebar position"), choices=[(None, _("Right")), ("left", _("Left"))], no_preselect_value=False, )
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, )
rulespec_registry.register( HostRulespec( group=RulespecGroupCheckParametersDiscovery, match_type="list", name="inventory_if_rules", valuespec=_valuespec_inventory_if_rules, )) vs_elements_if_groups_matches: List[DictionaryEntry] = [ ("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."), )), ] vs_elements_if_groups_group = [ ("group_name", TextAscii(
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), ], ), ), ], )
def parameter_valuespec(self): 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(), title= _("Local: Spooling - Send events to local Event Console into given spool directory" ), allow_empty=False, 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"), allow_empty= False, 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"), allow_empty=False, 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', ListOfStrings( 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' ], ), ], default_value='', )
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 _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 spec(self): return Dictionary( title=_("Create notification with the following parameters"), required_keys=['url', 'username', 'password', 'caller'], elements=[ ("url", HTTPUrl( title=_("Servicenow URL"), help= _("Configure your servicenow URL here (eg. https://myservicenow.com)." ), allow_empty=False, )), ("proxy_url", HTTPProxyReference()), ("username", TextAscii( title=_("Username"), help=_( "The user, used for login, has to have at least the " "role 'itil' in servicenow."), size=40, allow_empty=False, )), ("password", PasswordFromStore( title=_("Password of the user"), allow_empty=False, )), ("caller", TextAscii( title=_("Caller ID"), help= _("Caller is the user on behalf of whom the incident is being reported " "within servicenow. Please enter the name of the caller here. " "It is recommended to user the same user as used for login. " "Otherwise, your ACL rules in servicenow must be " "adjusted, so that the user who is used for login " "can create/edit/resolve incidents on behalf of the " "caller. Please have a look at servicenow " "documentation for details."), )), ("host_short_desc", TextAscii( title=_("Short description for host incidents"), help=_( "Text that should be set in field <tt>Short description</tt> " "for host notifications."), default_value="Check_MK: $HOSTNAME$ - $HOSTSHORTSTATE$", size=64, )), ("svc_short_desc", TextAscii( title=_("Short description for service incidents"), help=_( "Text that should be set in field <tt>Short description</tt> " "for service notifications."), default_value= "Check_MK: $HOSTNAME$/$SERVICEDESC$ $SERVICESHORTSTATE$", size=68, )), ("host_desc", TextAreaUnicode( title=_("Description for host incidents"), help=_( "Text that should be set in field <tt>Description</tt> " "for host notifications."), rows=7, cols=58, monospaced=True, default_value="""Host: $HOSTNAME$ Event: $EVENT_TXT$ Output: $HOSTOUTPUT$ Perfdata: $HOSTPERFDATA$ $LONGHOSTOUTPUT$ """)), ("svc_desc", TextAreaUnicode( title=_("Description for service incidents"), help=_( "Text that should be set in field <tt>Description</tt> " "for service notifications."), rows=11, cols=58, monospaced=True, default_value="""Host: $HOSTNAME$ Service: $SERVICEDESC$ Event: $EVENT_TXT$ Output: $SERVICEOUTPUT$ Perfdata: $SERVICEPERFDATA$ $LONGSERVICEOUTPUT$ """)), ("urgency", DropdownChoice( title=_("Urgency"), help= _("See <a href=\"https://docs.servicenow.com/bundle/" "helsinki-it-service-management/page/product/incident-management/" "reference/r_PrioritizationOfIncidents.html\" target=\"_blank\">" "ServiceNow Incident</a> for more information."), choices=[ ("low", _("Low")), ("medium", _("Medium")), ("high", _("High")), ], default_value="low", )), ("impact", DropdownChoice( title=_("Impact"), help= _("See <a href=\"https://docs.servicenow.com/bundle/" "helsinki-it-service-management/page/product/incident-management/" "reference/r_PrioritizationOfIncidents.html\" target=\"_blank\">" "ServiceNow Incident</a> for more information."), choices=[ ("low", _("Low")), ("medium", _("Medium")), ("high", _("High")), ], default_value="low", )), ("ack_state", Dictionary( title= _("Settings for incident state in case of acknowledgement" ), help= _("Here you can define the state of the incident in case of an " "acknowledgement of the affected host or service problem." ), elements=[ ("start", DropdownChoice( title=_( "State of incident if acknowledgement is set" ), help= _("Here you can define the state of the incident in case of an " "acknowledgement of the host or service problem." ), choices=[ ("none", _("Don't change state")), ("new", _("New")), ("progress", _("In Progress")), ("hold", _("On Hold")), ("resolved", _("Resolved")), ("closed", _("Closed")), ("canceled", _("Canceled")), ], default_value="none", )), ], )), ("dt_state", Dictionary( title=_( "Settings for incident state in case of downtime"), help=_( "Here you can define the state of the incident in case of a " "downtime of the affected host or service."), elements=[ ("start", DropdownChoice( title=_("State of incident if downtime is set"), help= _("Here you can define the state of the incident in case of an " "acknowledgement of the host or service problem." ), choices=[ ("none", _("Don't change state")), ("new", _("New")), ("progress", _("In Progress")), ("hold", _("On Hold")), ("resolved", _("Resolved")), ("closed", _("Closed")), ("canceled", _("Canceled")), ], default_value="none", )), ("end", DropdownChoice( title=_("State of incident if downtime expires"), help= _("Here you can define the state of the incident in case of an " "ending acknowledgement of the host or service problem." ), choices=[ ("none", _("Don't change state")), ("new", _("New")), ("progress", _("In Progress")), ("hold", _("On Hold")), ("resolved", _("Resolved")), ("closed", _("Closed")), ("canceled", _("Canceled")), ], default_value="none", )), ], )), ("timeout", TextAscii( title=_( "Set optional timeout for connections to servicenow"), help=_( "Here you can configure timeout settings in seconds." ), default_value=10, size=3)), ], )