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=[ RegExpUnicode( 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=RegExpUnicode.prefix, ), TextUnicode( 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 _vs_host_name(self): return Hostname(title=_("Hostname"),)
def _verify_host_type(cls, host): if not host.is_cluster(): raise MKGeneralException(_("Can not clone a regular host as cluster host"))
def page(self): # Show outcome of host validation. Do not validate new hosts errors = None if self._mode == "edit": errors = watolib.validate_all_hosts([self._host.name()]).get( self._host.name(), []) + self._host.validation_errors() if errors: html.open_div(class_="info") html.open_table(class_="validationerror", boder="0", cellspacing="0", cellpadding="0") html.open_tr() html.open_td(class_="img") html.icon("validation_error") html.close_td() html.open_td() html.open_p() html.h3(_("Warning: This host has an invalid configuration!")) html.open_ul() for error in errors: html.li(error) html.close_ul() html.close_p() if html.form_submitted(): html.br() html.b(_("Your changes have been saved nevertheless.")) html.close_td() html.close_tr() html.close_table() html.close_div() lock_message = u"" locked_hosts = watolib.Folder.current().locked_hosts() if locked_hosts: if locked_hosts is True: lock_message = _("Host attributes locked (You cannot edit this host)") elif isinstance(locked_hosts, str): lock_message = locked_hosts if lock_message: html.div(lock_message, class_="info") html.begin_form("edit_host", method="POST") html.prevent_password_auto_completion() basic_attributes = [ # attribute name, valuepec, default value ("host", self._vs_host_name(), self._host.name()), ] if self._is_cluster(): basic_attributes += [ # attribute name, valuepec, default value ("nodes", self._vs_cluster_nodes(), self._host.cluster_nodes() if self._host else []), ] configure_attributes( new=self._mode != "edit", hosts={self._host.name(): self._host} if self._mode != "new" else {}, for_what="host" if not self._is_cluster() else "cluster", parent=watolib.Folder.current(), basic_attributes=basic_attributes, ) if self._mode != "edit": html.set_focus("host") forms.end() html.hidden_fields() html.end_form()
def _vs_host_name(self): return FixedValue( self._host.name(), title=_("Hostname"), )
def render(self, what, row, tags, custom_vars): # Passive checks disabled manually? if "passive_checks_enabled" in row[what + "_modified_attributes_list"]: if row[what + "_accept_passive_checks"] == 0: return 'npassive', _( 'Passive checks have been manually disabled for this %s!') % what
def render(self, what, row, tags, custom_vars): if not row[what + "_in_service_period"]: return 'outof_serviceperiod', _('Out of service period')
default_levels=(100.0, 10000.0), default_difference=(5, 8), default_value=None, ), ), ( "average", Integer( title=_("Averaging"), help=_( "When this option is activated then the block rate is being " "averaged <b>before</b> the levels are being applied."), unit=_("minutes"), default_value=3, minvalue=1, label=_("Compute average over last "), ), ), ], ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="firewall_if", group=RulespecGroupCheckParametersApplications, item_spec=_item_spec_firewall_if, match_type="dict", parameter_valuespec=_parameter_valuespec_firewall_if, title=lambda: _("Firewall Interfaces"), ))
def _item_spec_firewall_if(): return TextInput( title=_("Interface"), help=_("The description of the interface as provided by the device"), )
def title(self): return _("Citrix Netscaler Loadbalancer TCP Connections")
(8, "todEstablished"), (9, "securityEstablished"), (10, "paramTransferComplete"), (11, "registrationComplete"), (12, "operational"), (13, "accessDenied"), ], default_value=[1, 2, 13], )), ("tx_power", Tuple( title=_("Transmit Power"), help=_("The operational transmit power"), elements=[ Float(title=_("warning at"), unit="dBmV", default_value=20.0), Float(title=_("critical at"), unit="dBmV", default_value=10.0), ], )), ],) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="docsis_cm_status", group=RulespecGroupCheckParametersNetworking, item_spec=lambda: TextInput(title=_("ID of the Entry")), match_type="dict", parameter_valuespec=_parameter_valuespec_docsis_cm_status, title=lambda: _("Docsis Cable Modem Status"), ))
def gui_title(cls): return _("Host renaming")
def render_renaming_actions(action_counts): action_titles = { "folder": _("WATO folder"), "notify_user": _("Users' notification rule"), "notify_global": _("Global notification rule"), "notify_flexible": _("Flexible notification rule"), "wato_rules": _("Host and service configuration rule"), "alert_rules": _("Alert handler rule"), "parents": _("Parent definition"), "cluster_nodes": _("Cluster node definition"), "bi": _("BI rule or aggregation"), "favorites": _("Favorite entry of user"), "cache": _("Cached output of monitoring agent"), "counters": _("File with performance counter"), "agent": _("Baked host specific agent"), "agent_deployment": _("Agent deployment status"), "piggyback-load": _("Piggyback information from other host"), "piggyback-pig": _("Piggyback information for other hosts"), "autochecks": _("Auto-disovered services of the host"), "logwatch": _("Logfile information of logwatch plugin"), "snmpwalk": _("A stored SNMP walk"), "rrd": _("RRD databases with performance data"), "rrdcached": _("RRD updates in journal of RRD Cache"), "pnpspool": _("Spool files of PNP4Nagios"), "nagvis": _("NagVis map"), "history": _("Monitoring history entries (events and availability)"), "retention": _("The current monitoring state (including acknowledgements and downtimes)" ), "inv": _("Recent hardware/software inventory"), "invarch": _("History of hardware/software inventory"), } texts = [] for what, count in sorted(action_counts.items()): if what.startswith("dnsfail-"): text = _( "<b>WARNING: </b> the IP address lookup of <b>%s</b> has failed. The core has been " "started by using the address <tt>0.0.0.0</tt> for the while. " "Please update your DNS or configure an IP address for the affected host." ) % what.split("-", 1)[1] else: text = action_titles.get(what, what) if count > 1: text += _(" (%d times)") % count texts.append(text) return texts
def title(self): return _("Rename %s %s") % (_("Cluster") if self._host.is_cluster() else _("Host"), self._host.name())
def _item_spec_mysql_db_size(): return TextInput( title=_("Name of the database"), help=_("Don't forget the instance: instance:dbname"), )
default_value=1), Integer(title=_("Critical at"), unit="collectors", default_value=1) ], )), ("running", MonitoringState(title=_("State when collector is in state running"), default_value=0)), ("stopped", MonitoringState(title=_("State when collector is in state stopped"), default_value=1)), ("failing", MonitoringState(title=_("State when collector is in state failing"), default_value=2)), ("no_ping", MonitoringState(title=_("State when no ping signal from sidecar"), default_value=2)), ], ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="graylog_sidecars", group=RulespecGroupCheckParametersApplications, item_spec=lambda: TextInput(title=_("Sidecar name")), match_type="dict", parameter_valuespec=_parameter_valuespec_graylog_sidecars, title=lambda: _("Graylog sidecars"), ))
def render(self, what, row, tags, custom_vars): if row[what + "_acknowledged"]: return 'ack', _('This problem has been acknowledged')
def _parameter_valuespec_graylog_sidecars(): return Dictionary(elements=[ ("active_state", MonitoringState(title=_("State when active state is not OK"), default_value=2)), ("last_seen", Tuple( title=_("Time since the sidecar was last seen by graylog"), elements=[ Age(title=_("Warning at")), Age(title=_("Critical at")) ], )), ("running_lower", Tuple( title=_("Total number of collectors in state running lower " "level"), elements=[ Integer(title=_("Warning if less then"), unit="collectors", default_value=1), Integer(title=_("Critical if less then"), unit="collectors", default_value=0) ], )), ("running_upper", Tuple( title=_("Total number of collectors in state running upper " "level"), elements=[ Integer(title=_("Warning at"), unit="collectors"), Integer(title=_("Critical at"), unit="collectors") ], )), ("stopped_lower", Tuple( title=_("Total number of collectors in state stopped lower " "level"), elements=[ Integer(title=_("Warning if less then"), unit="collectors"), Integer(title=_("Critical if less then"), unit="collectors") ], )), ("stopped_upper", Tuple( title=_("Total number of collectors in state stopped upper " "level"), elements=[ Integer(title=_("Warning at"), unit="collectors", default_value=1), Integer(title=_("Critical at"), unit="collectors", default_value=1) ], )), ("failing_lower", Tuple( title=_("Total number of collectors in state failing lower " "level"), elements=[ Integer(title=_("Warning if less then"), unit="collectors"), Integer(title=_("Critical if less then"), unit="collectors") ], )), ("failing_upper", Tuple( title=_("Total number of collectors in state failing upper " "level"), elements=[ Integer(title=_("Warning at"), unit="collectors", default_value=1), Integer(title=_("Critical at"), unit="collectors", default_value=1) ], )), ("running", MonitoringState(title=_("State when collector is in state running"), default_value=0)), ("stopped", MonitoringState(title=_("State when collector is in state stopped"), default_value=1)), ("failing", MonitoringState(title=_("State when collector is in state failing"), default_value=2)), ("no_ping", MonitoringState(title=_("State when no ping signal from sidecar"), default_value=2)), ], )
def render(self, what, row, tags, custom_vars): if not row[what + "_in_notification_period"]: return 'outofnot', _('Out of notification period')
("default", MonitoringState(title=_("States other than the above"), default_value=1)), ], optional_keys=False, )), ("map_frozen", Dictionary( title=_("Map Attribute 'Frozen'"), elements=[ ("tfrozen", MonitoringState(title=_("Temporarily frozen"), default_value=1)), ("frozen", MonitoringState(title=_("Frozen"), default_value=2)), ], optional_keys=False, )), ], ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="veritas_vcs", group=RulespecGroupCheckParametersApplications, item_spec=lambda: TextInput(title=_("Cluster Name")), match_type="dict", parameter_valuespec=_parameter_valuespec_veritas_vcs, title=lambda: _("Veritas Cluster Server"), ))
def title(self): if self._mode == "clone": return _("Create clone of %s") % self._host.name() return _("Add host")
def _parameter_valuespec_veritas_vcs(): return Dictionary(elements=[ ("map_states", Dictionary( title=_("Map Attribute 'State'"), elements=[ ("ONLINE", MonitoringState(title=_("ONLINE"), default_value=0)), ("RUNNING", MonitoringState(title=_("RUNNING"), default_value=0)), ("OK", MonitoringState(title=_("OK"), default_value=0)), ("OFFLINE", MonitoringState(title=_("OFFLINE"), default_value=1)), ("EXITED", MonitoringState(title=_("EXITED"), default_value=1)), ("PARTIAL", MonitoringState(title=_("PARTIAL"), default_value=1)), ("FAULTED", MonitoringState(title=_("FAULTED"), default_value=2)), ("UNKNOWN", MonitoringState(title=_("UNKNOWN"), default_value=3)), ("default", MonitoringState(title=_("States other than the above"), default_value=1)), ], optional_keys=False, )), ("map_frozen", Dictionary( title=_("Map Attribute 'Frozen'"), elements=[ ("tfrozen", MonitoringState(title=_("Temporarily frozen"), default_value=1)), ("frozen", MonitoringState(title=_("Frozen"), default_value=2)), ], optional_keys=False, )), ], )
def title(self): return _("Properties of host") + " " + self._host.name()
from cmk.gui.i18n import _ from cmk.gui.plugins.wato import ( CheckParameterRulespecWithoutItem, rulespec_registry, RulespecGroupCheckParametersOperatingSystem, ) from cmk.gui.valuespec import Dictionary, Percentage, Tuple def _parameter_valuespec_sophos_memory(): return Dictionary(elements=[ ("memory_levels", Tuple( title=_("Memory percentage usage"), elements=[ Percentage(title=_("Warning at"), default_value=80), Percentage(title=_("Critical at"), default_value=90) ], )), ]) rulespec_registry.register( CheckParameterRulespecWithoutItem( check_group_name="sophos_memory", group=RulespecGroupCheckParametersOperatingSystem, match_type="dict", parameter_valuespec=_parameter_valuespec_sophos_memory, title=lambda: _("Sophos Memory utilization"), ))
def page_menu_host_entries(mode_name: str, host: CREHost) -> Iterator[PageMenuEntry]: if mode_name != "edit_host": yield PageMenuEntry( title=_("Properties"), icon_name="edit", item=make_simple_link( watolib.folder_preserving_link([("mode", "edit_host"), ("host", host.name())])), ) if mode_name != "inventory": yield PageMenuEntry( title=_("Service configuration"), icon_name="services", item=make_simple_link( watolib.folder_preserving_link([("mode", "inventory"), ("host", host.name())])), ) if mode_name != "diag_host" and not host.is_cluster(): yield PageMenuEntry( title=_("Connection tests"), icon_name="diagnose", item=make_simple_link( watolib.folder_preserving_link([("mode", "diag_host"), ("host", host.name())])), ) if mode_name != "object_parameters" and config.user.may('wato.rulesets'): yield PageMenuEntry( title=_("Effective parameters"), icon_name="rulesets", item=make_simple_link( watolib.folder_preserving_link([("mode", "object_parameters"), ("host", host.name())])), ) if mode_name == "object_parameters" or mode_name == "edit_host" and config.user.may( 'wato.rulesets'): yield PageMenuEntry( title=_("Rules"), icon_name="rulesets", item=make_simple_link( watolib.folder_preserving_link([ ("mode", "rule_search"), ("filled_in", "search"), ("search_p_ruleset_deprecated", "OFF"), ("search_p_rule_host_list_USE", "ON"), ("search_p_rule_host_list", host.name()), ],)), ) yield make_host_status_link(host_name=host.name(), view_name="hoststatus") if config.user.may('wato.rulesets') and host.is_cluster(): yield PageMenuEntry( title=_("Clustered services"), icon_name="rulesets", item=make_simple_link( watolib.folder_preserving_link([("mode", "edit_ruleset"), ("varname", "clustered_services")])), ) if watolib.has_agent_bakery() and config.user.may('wato.download_agents'): yield PageMenuEntry( title=_("Monitoring agent"), icon_name="agents", item=make_simple_link( watolib.folder_preserving_link([("mode", "agent_of_host"), ("host", host.name())])), ) if mode_name == "edit_host" and not host.locked(): if config.user.may("wato.rename_hosts"): yield PageMenuEntry( title=_("Rename"), icon_name="rename_host", item=make_simple_link( watolib.folder_preserving_link([("mode", "rename_host"), ("host", host.name())])), ) if config.user.may("wato.manage_hosts") and config.user.may("wato.clone_hosts"): yield PageMenuEntry( title=_("Clone"), icon_name="insert", item=make_simple_link(host.clone_url()), ) yield PageMenuEntry( title=_("Delete"), icon_name="delete", item=make_simple_link( make_confirm_link( url=html.makeactionuri([("delete", "1")]), message=_("Do you really want to delete the host <tt>%s</tt>?") % host.name(), )), ) if config.user.may("wato.auditlog"): yield PageMenuEntry( title=_("Audit log"), icon_name="auditlog", item=make_simple_link(make_object_audit_log_url(host.object_ref())), )
def _parameter_valuespec_smoke(): return Transform( Dictionary( help=_("For devices that measure smoke in percent"), elements=[ ( 'levels', Tuple( title=_('Upper limits in percent'), elements=[ Percentage(title=_("Warning at"), allow_int=True, default_value=1), Percentage(title=_("Critical at"), allow_int=True, default_value=5), ], ), ), ], ), forth=_transform_smoke_detection_params, ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="smoke", group=RulespecGroupCheckParametersEnvironment, item_spec=lambda: TextInput(title=_("Sensor ID"), help=_("The identifier of the sensor.")), parameter_valuespec=_parameter_valuespec_smoke, title=lambda: _("Smoke Detection"), ))
def title(self): if self._mode == "clone": return _("Create clone of %s") % self._host.name() return _("Create new cluster")
def _item_spec_mysql_db_size(): return TextInput( title=_("Name of the database"), help=_("Don't forget the instance: instance:dbname"), ) def _parameter_valuespec_mysql_db_size(): return Optional( Tuple(elements=[ Filesize(title=_("warning at")), Filesize(title=_("critical at")), ], ), help=_( "The check will trigger a warning or critical state if the size of the " "database exceeds these levels."), title=_("Impose limits on the size of the database"), ) rulespec_registry.register( CheckParameterRulespecWithItem( check_group_name="mysql_db_size", group=RulespecGroupCheckParametersApplications, item_spec=_item_spec_mysql_db_size, parameter_valuespec=_parameter_valuespec_mysql_db_size, title=lambda: _("MySQL database sizes"), ))
def _page_menu_save_topic(self) -> PageMenuTopic: return PageMenuTopic( title=_("Save this host and go to"), entries=list(self._page_menu_save_entries()), )
def page(self): html.begin_form("bulk_rename_host", method="POST") self._vs_renaming_config().render_input("", {}) html.button("_start", _("Bulk Rename")) html.hidden_fields() html.end_form()