def show_log_list(): title = _("All problematic logfiles") html.header(title, make_simple_page_breadcrumb(MegaMenuMonitoring, title)) html.begin_context_buttons() html.context_button( _("Analyze Patterns"), "%swato.py?mode=pattern_editor" % html.request.var('master_url', ''), 'analyze') ack_button() html.end_context_buttons() for site, host_name, logs in all_logs(): if not logs: continue all_logs_empty = not any( [parse_file(site, host_name, file_name) for file_name in logs]) if all_logs_empty: continue # Logfile vanished html.h2( html.render_a(host_name, href=html.makeuri([('site', site), ('host', host_name)]))) list_logs(site, host_name, logs) html.footer()
def user_profile_async_replication_page() -> None: title = _('Replicate new user profile') breadcrumb = make_simple_page_breadcrumb(MegaMenuUser, title) html.header(title, breadcrumb) html.begin_context_buttons() html.context_button(_('User Profile'), 'user_profile.py', 'back') html.end_context_buttons() sites = list(config.user.authorized_login_sites().keys()) user_profile_async_replication_dialog(sites=sites) html.footer()
def show_topology(self, hostnames: List[HostName], mode: str, growth_auto_max_nodes: Optional[int] = None, mesh_depth: int = 0, max_nodes: int = 400) -> None: html.header("", breadcrumb=make_simple_page_breadcrumb( MegaMenuMonitoring, "")) self.show_topology_content(hostnames, mode, growth_auto_max_nodes=growth_auto_max_nodes, mesh_depth=mesh_depth, max_nodes=max_nodes)
def _bi_map() -> None: aggr_name = html.request.var("aggr_name") layout_id = html.request.var("layout_id") title = _("BI visualization") html.header(title, make_simple_page_breadcrumb(MegaMenuMonitoring, title)) div_id = "node_visualization" html.div("", id=div_id) html.javascript( "node_instance = new cmk.node_visualization.BIVisualization(%s);" % json.dumps(div_id)) html.javascript("node_instance.set_theme(%s)" % json.dumps(html.get_theme())) html.javascript("node_instance.show_aggregations(%s, %s)" % (json.dumps([aggr_name]), json.dumps(layout_id)))
def render_page_confirm(acktime, prev_url, failed_notifications): title = _("Confirm failed notifications") html.header(title, make_simple_page_breadcrumb(MegaMenuMonitoring, title)) if failed_notifications: html.open_div(class_="really") html.write_text( _("Do you really want to acknowledge all failed notifications up to %s?") % cmk.utils.render.date_and_time(acktime)) html.begin_form("confirm", method="GET", action=prev_url) html.hidden_field('acktime', acktime) html.button('_confirm', _("Yes")) html.end_form() html.close_div() render_notification_table(failed_notifications) html.footer()
def page(self): title = _("Crash report: %s") % self._crash_id html.header(title, make_simple_page_breadcrumb(MegaMenuMonitoring, title)) row = self._get_crash_row() crash_info = self._get_crash_info(row) # Do not reveal crash context information to unauthenticated users or not permitted # users to prevent disclosure of internal information if not config.user.may("general.see_crash_reports"): html.show_error("<b>%s:</b> %s" % (_("Internal error"), crash_info["exc_value"])) html.p( _("An internal error occurred while processing your request. " "You can report this issue to your Checkmk administrator. " "Detailed information can be found on the crash report page " "or in <tt>var/log/web.log</tt>.")) html.footer() return self._show_context_buttons(crash_info) if html.request.has_var("_report") and html.check_transaction(): details = self._handle_report_form(crash_info) else: details = {} if crash_info["crash_type"] == "gui": html.show_error("<b>%s:</b> %s" % (_("Internal error"), crash_info["exc_value"])) html.p( _("An internal error occured while processing your request. " "You can report this issue to the Checkmk team to help " "fixing this issue. Please use the form below for reporting." )) self._warn_about_local_files(crash_info) self._show_report_form(crash_info, details) self._show_crash_report(crash_info) self._show_crash_report_details(crash_info, row) html.footer()
def do_log_ack(site, host_name, file_name): logs_to_ack = [] if not host_name and not file_name: # all logs on all hosts for this_site, this_host, logs in all_logs(): for int_filename in logs: file_display = form_file_to_ext(int_filename) logs_to_ack.append( (this_site, this_host, int_filename, file_display)) ack_msg = _('all logfiles on all hosts') elif host_name and not file_name: # all logs on one host for int_filename in logfiles_of_host(site, host_name): file_display = form_file_to_ext(int_filename) logs_to_ack.append((site, host_name, int_filename, file_display)) ack_msg = _('all logfiles of host %s') % host_name elif host_name and file_name: # one log on one host int_filename = form_file_to_int(file_name) logs_to_ack = [(site, host_name, int_filename, form_file_to_ext(int_filename))] ack_msg = _('the log file %s on host %s') % (file_name, host_name) else: for this_site, this_host, logs in all_logs(): file_display = form_file_to_ext(file_name) if file_name in logs: logs_to_ack.append( (this_site, this_host, file_name, file_display)) ack_msg = _('log file %s on all hosts') % file_name title = _("Acknowledge %s") % html.render_text(ack_msg) if host_name: breadcrumb = make_host_breadcrumb(host_name) else: breadcrumb = make_simple_page_breadcrumb(MegaMenuMonitoring, title) html.header(title, breadcrumb) html.begin_context_buttons() button_all_logfiles() if host_name: html.context_button(_("All Logfiles of Host"), html.makeuri([('file', '')])) if host_name and file_name: html.context_button(_("Back to Logfile"), html.makeuri([])) html.end_context_buttons() ack = html.request.var('_ack') if not html.confirm( _("Do you really want to acknowledge %s by <b>deleting</b> all stored messages?" ) % ack_msg): html.footer() return if not config.user.may("general.act"): html.h1(_('Permission denied'), class_=["error"]) html.div(_('You are not allowed to acknowledge %s') % ack_msg, class_=["error"]) html.footer() return # filter invalid values if ack != '1': raise MKUserError('_ack', _('Invalid value for ack parameter.')) for this_site, this_host, int_filename, display_name in logs_to_ack: try: acknowledge_logfile(this_site, this_host, int_filename, display_name) except Exception as e: html.show_error( _('The log file <tt>%s</tt> of host <tt>%s</tt> could not be deleted: %s.' ) % (display_name, this_host, e)) html.footer() return html.show_message('<b>%s</b><p>%s</p>' % (_('Acknowledged %s') % ack_msg, _('Acknowledged all messages in %s.') % ack_msg)) html.footer()
def _show_form(self, profile_changed: bool) -> None: assert config.user.id is not None users = userdb.load_users() breadcrumb = make_simple_page_breadcrumb(MegaMenuUser, self._page_title()) html.header(self._page_title(), breadcrumb) self._show_context_buttons() if profile_changed: html.reload_sidebar() html.show_message(_("Successfully updated user profile.")) # Ensure theme changes are applied without additional user interaction html.immediate_browser_redirect(0.5, html.makeuri([])) if html.has_user_errors(): html.show_user_errors() user = users.get(config.user.id) if user is None: html.show_warning(_("Sorry, your user account does not exist.")) html.footer() return html.begin_form("profile", method="POST") html.prevent_password_auto_completion() html.open_div(class_="wato") forms.header(self._page_title()) forms.section(_("Name"), simple=True) html.write_text(user.get("alias", config.user.id)) select_language(user) # Let the user configure how he wants to be notified rulebased_notifications = rulebased_notifications_enabled() if (not rulebased_notifications and config.user.may('general.edit_notifications') and user.get("notifications_enabled")): forms.section(_("Notifications")) html.help( _("Here you can configure how you want to be notified about host and service problems and " "other monitoring events.")) watolib.get_vs_flexible_notifications().render_input( "notification_method", user.get("notification_method")) if config.user.may('general.edit_user_attributes'): for name, attr in userdb.get_user_attributes(): if attr.user_editable(): vs = attr.valuespec() forms.section(_u(vs.title())) value = user.get(name, vs.default_value()) if not attr.permission() or config.user.may( attr.permission()): vs.render_input("ua_" + name, value) html.help(_u(vs.help())) else: html.write(vs.value_to_text(value)) forms.end() html.button("_save", _("Save")) html.close_div() html.hidden_fields() html.end_form() html.footer()
def _show_form(self, profile_changed: bool) -> None: assert config.user.id is not None users = userdb.load_users() breadcrumb = make_simple_page_breadcrumb(MegaMenuUser, self._page_title()) html.header(self._page_title(), breadcrumb) change_reason = html.request.get_ascii_input('reason') if change_reason == 'expired': html.p( _('Your password is too old, you need to choose a new password.' )) elif change_reason == 'enforced': html.p( _('You are required to change your password before proceeding.' )) if profile_changed: html.show_message(_("Your password has been changed.")) if change_reason: raise HTTPRedirect( html.request.get_str_input_mandatory( '_origtarget', 'index.py')) if html.has_user_errors(): html.show_user_errors() user = users.get(config.user.id) if user is None: html.show_warning(_("Sorry, your user account does not exist.")) html.footer() return locked_attributes = userdb.locked_attributes(user.get('connector')) if "password" in locked_attributes: raise MKUserError( "cur_password", _("You can not change your password, because it is " "managed by another system.")) html.begin_form("profile", method="POST") html.prevent_password_auto_completion() html.open_div(class_="wato") forms.header(self._page_title()) forms.section(_("Current Password")) html.password_input('cur_password', autocomplete="new-password") forms.section(_("New Password")) html.password_input('password', autocomplete="new-password") forms.section(_("New Password Confirmation")) html.password_input('password2', autocomplete="new-password") forms.end() html.button("_save", _("Save")) html.close_div() html.hidden_fields() html.end_form() html.footer()