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(), allow_empty=False, ), 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(), allow_empty=False, ), 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(), allow_empty=False, ), 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(), allow_empty=False, ), 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."), )), ("total_traffic", ListOf( CascadingDropdown(title=_("Direction"), orientation="horizontal", choices=[ ('total', _("Total traffic"), vs_interface_traffic()), ]), title=_("Used total bandwidth (in + out) (minimum or maximum traffic)"), help= _("By activating this item, the sum of incoming and outgoing traffic will " "be monitored via a seperate metric. Setting levels on the used total 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 _vs_matching_conditions(): return CascadingDropdown( title=_("Conditions for this rule to apply"), help=_( "Here, you can define conditions for applying this rule. These conditions are evaluated " "on a per-interface basis. When discovering an interface, checkmk will first find all " "rules whose conditions match this interface. Then, these rules are merged together, " "whereby rules from subfolders overwrite rules from the main directory. Within a " "directory, the order of the rules matters, i.e., rules further below in the list are " "overwritten by rules further up."), choices=[ ( True, _("Match all interfaces"), FixedValue( {}, totext="", ), ), ( False, _("Specify matching conditions"), Dictionary(elements=[ ( "porttypes", DualListChoice( title=_("Match port types"), help=_("Apply this rule only to interfaces whose port type is listed " "below."), choices=defines.interface_port_types(), rows=40, default_value=[ '6', '32', '62', '117', '127', '128', '129', '180', '181', '182', '205', '229' ], ), ), ( "portstates", ListChoice( title=_("Match port states"), help=_("Apply this rule only to interfaces whose port state is listed " "below."), choices=defines.interface_oper_states(), toggle_all=True, default_value=['1'], ), ), ( "admin_states", ListChoice( title=_("Match admin states (SNMP with 64-bit counters only)"), help=_("Apply this rule only to interfaces whose admin state " "(<tt>ifAdminStatus</tt>) is listed below. " + _note_for_admin_state_options()), choices=_admin_states(), toggle_all=True, default_value=['1', '2', '3'], ), ), ( "match_index", _vs_regex_matching("index"), ), ( "match_alias", _vs_regex_matching("alias"), ), ( "match_desc", _vs_regex_matching("description"), ), ],), ), ], sorted=False, )
def parameter_valuespec(self): # 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", Alternative( title=_("Levels for error rates"), help= _("These levels make the check go warning or critical whenever the " "<b>percentual error rate</b> or the <b>absolute error rate</b> of the monitored interface reaches " "the given bounds. The percentual error rate is computed by dividing number of " "errors by the total number of packets (successful plus errors)." ), elements=[ Tuple( title=_("Percentual levels for error rates"), elements=[ Percentage(title=_("Warning at"), unit=_("percent errors"), default_value=0.01, display_format='%.3f'), Percentage(title=_("Critical at"), unit=_("percent errors"), default_value=0.1, display_format='%.3f') ]), Tuple(title=_("Absolute levels for error rates"), elements=[ Integer(title=_("Warning at"), unit=_("errors")), Integer(title=_("Critical at"), unit=_("errors")) ]) ])), ("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=[ DropdownChoice( 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", RadioChoice( 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, )), ], ), forth=transform_if, )
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 _vs_matching_conditions(): return CascadingDropdown( title=_("Conditions for this rule to apply"), help= _("Here, you can define conditions for applying this rule. These conditions are evaluated " "on a per-interface basis. When discovering an interface, checkmk will first find all " "rules whose conditions match this interface. Then, these rules are merged together, " "whereby rules from subfolders overwrite rules from the main directory. Within a " "directory, the order of the rules matters, i.e., rules further below in the list are " "overwritten by rules further up."), choices=[ ( True, _("Match all interfaces"), FixedValue( {}, totext="", ), ), ( False, _("Specify matching conditions"), Dictionary(elements=[ ( "porttypes", DualListChoice( title=_("Match port types"), help=_( "Apply this rule only to interfaces whose port type is listed " "below."), choices=defines.interface_port_types(), rows=40, default_value=[ '6', '32', '62', '117', '127', '128', '129', '180', '181', '182', '205', '229' ], ), ), ( "portstates", ListChoice( title=_("Match port states"), help= _("Apply this rule only to interfaces whose port state is listed " "below. Note: the state <i>admin down</i> is in fact not a port " "state but represents an <tt>ifAdminStatus</tt> (SNMP only) of " "<tt>down</tt> - a port administratively switched off. If you check " "this option, <tt>ifAdminState</tt> will be fetched in addition, " "adding approximately 5% of additional SNMP traffic." ), choices=defines.interface_oper_states(), toggle_all=True, default_value=['1'], ), ), ( "match_index", _vs_regex_matching("index"), ), ( "match_alias", _vs_regex_matching("alias"), ), ( "match_desc", _vs_regex_matching("description"), ), ], ), ), ], sorted=False, )