def show_log_list(): title = _("All problematic logfiles") breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb, _log_list_page_menu(breadcrumb)) if request.has_var("_ack") and not request.var("_do_actions") == _("No"): do_log_ack(site=None, host_name=None, file_name=None) return 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.h3( html.render_a( host_name, href=makeuri( request, [("site", site), ("host", host_name)], ), ), class_="table", ) list_logs(site, host_name, logs) html.footer()
def page(self) -> None: acktime = request.get_float_input_mandatory('acktime', time.time()) if request.var('_confirm'): _acknowledge_failed_notifications(acktime, time.time()) if user.authorized_login_sites(): watolib.init_wato_datastructures(with_wato_lock=True) title = _('Replicate user profile') breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb) for message in get_flashed_messages(): html.show_message(message) # This local import is needed for the moment import cmk.gui.wato.user_profile # pylint: disable=redefined-outer-name cmk.gui.wato.user_profile.user_profile_async_replication_page( back_url="clear_failed_notifications.py") return failed_notifications = load_failed_notifications( before=acktime, after=acknowledged_time()) self._show_page(acktime, failed_notifications) if request.var('_confirm'): html.reload_whole_page()
def show_log_list(): title = _("All problematic logfiles") breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb, _log_list_page_menu(breadcrumb)) if html.request.has_var( '_ack') and not html.request.var("_do_actions") == _("No"): do_log_ack(site=None, host_name=None, file_name=None) return 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 dashboard_breadcrumb(name: str, board: DashboardConfig, title: str) -> Breadcrumb: breadcrumb = make_topic_breadcrumb( mega_menu_registry.menu_monitoring(), PagetypeTopics.get_topic(board["topic"])) breadcrumb.append( BreadcrumbItem(title, makeuri_contextless(request, [("name", name)]))) return breadcrumb
def show_topology(self, topology_settings: TopologySettings) -> None: visual_spec = ParentChildTopologyPage.visual_spec() breadcrumb = make_topic_breadcrumb(mega_menu_registry.menu_monitoring(), PagetypeTopics.get_topic(visual_spec["topic"])) breadcrumb.append(make_current_page_breadcrumb_item(visual_spec["title"])) page_menu = PageMenu(breadcrumb=breadcrumb) self._extend_display_dropdown(page_menu, visual_spec["name"]) html.header(visual_spec["title"], breadcrumb, page_menu) self.show_topology_content(topology_settings=topology_settings)
def _show_page(self, acktime: float, failed_notifications: LivestatusResponse) -> None: title = _("Confirm failed notifications") breadcrumb = make_simple_page_breadcrumb(mega_menu_registry.menu_monitoring(), title) page_menu = self._page_menu(acktime, failed_notifications, breadcrumb) make_header(html, title, breadcrumb, page_menu) self._show_notification_table(failed_notifications) html.footer()
def _bi_map() -> None: aggr_name = html.request.var("aggr_name") layout_id = html.request.var("layout_id") title = _("BI visualization") breadcrumb = make_simple_page_breadcrumb(mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb) 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.show_aggregations(%s, %s)" % (json.dumps([aggr_name]), json.dumps(layout_id)))
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: breadcrumb = make_simple_page_breadcrumb(mega_menu_registry.menu_monitoring(), "") html.header("", breadcrumb) self.show_topology_content(hostnames, mode, growth_auto_max_nodes=growth_auto_max_nodes, mesh_depth=mesh_depth, max_nodes=max_nodes)
def _breadcrumb(self, title: str) -> Breadcrumb: breadcrumb = make_topic_breadcrumb(mega_menu_registry.menu_monitoring(), PagetypeTopics.get_topic("analyze")) # Add the parent element: List of all crashes breadcrumb.append( BreadcrumbItem( title=_("Crash reports"), url=html.makeuri_contextless([("view_name", "crash_reports")], filename="view.py"), )) breadcrumb.append(make_current_page_breadcrumb_item(title)) return breadcrumb
def render_page_confirm(acktime, failed_notifications): title = _("Confirm failed notifications") breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title) confirm_url = make_confirm_link( url=html.makeactionuri_contextless([ ("mode", "clear_failed_notifications"), ("acktime", str(acktime)), ("_confirm", "1"), ]), message= _("Do you really want to acknowledge all failed notifications up to %s?" ) % cmk.utils.render.date_and_time(acktime), ) page_menu = PageMenu( dropdowns=[ PageMenuDropdown( name="actions", title=_("Actions"), topics=[ PageMenuTopic( title=_("Actions"), entries=[ PageMenuEntry( title=_("Confirm"), icon_name="save", item=make_javascript_link(confirm_url), is_shortcut=True, is_suggested=True, is_enabled=failed_notifications, ), ], ), ], ), ], breadcrumb=breadcrumb, ) html.header(title, breadcrumb, page_menu) render_notification_table(failed_notifications) html.footer()
def page(self): title = _("Crash report: %s") % self._crash_id breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb) 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 render_page_confirm(acktime, prev_url, failed_notifications): title = _("Confirm failed notifications") breadcrumb = make_simple_page_breadcrumb(mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb) 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 show_topology(self, hostnames: List[HostName], mode: str, growth_auto_max_nodes: Optional[int] = None, mesh_depth: int = 0, max_nodes: int = 400) -> None: visual_spec = ParentChildTopologyPage.visual_spec() breadcrumb = make_topic_breadcrumb( mega_menu_registry.menu_monitoring(), PagetypeTopics.get_topic(visual_spec["topic"])) breadcrumb.append( make_current_page_breadcrumb_item(visual_spec["title"])) page_menu = PageMenu(breadcrumb=breadcrumb) self._extend_display_dropdown(page_menu, visual_spec["name"]) html.header(visual_spec["title"], breadcrumb, page_menu) self.show_topology_content(hostnames, mode, growth_auto_max_nodes=growth_auto_max_nodes, mesh_depth=mesh_depth, max_nodes=max_nodes)
def page(self) -> None: acktime = request.get_float_input_mandatory("acktime", time.time()) if request.var("_confirm"): _acknowledge_failed_notifications(acktime, time.time()) if user.authorized_login_sites(): title = _("Replicate user profile") breadcrumb = make_simple_page_breadcrumb( mega_menu_registry.menu_monitoring(), title ) make_header(html, title, breadcrumb) for message in get_flashed_messages(): html.show_message(message) user_profile_async_replication_page(back_url="clear_failed_notifications.py") return failed_notifications = load_failed_notifications(before=acktime, after=acknowledged_time()) self._show_page(acktime, failed_notifications) if request.var("_confirm"): html.reload_whole_page()
def show_log_list(): title = _("All problematic logfiles") breadcrumb = make_simple_page_breadcrumb(mega_menu_registry.menu_monitoring(), title) html.header(title, breadcrumb) 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 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(mega_menu_registry.menu_monitoring(), 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()