def _pnp_icon(self, row, what): url = self._pnp_graph_icon_link(row, what) if not metrics.cmk_graphs_possible(row["site"]): # Directly ask PNP for all data, don't try to use the new graph fetching mechanism # to keep the number of single requests low force_pnp_graphing = True else: # Don't show the icon with Check_MK graphing. The hover makes no sense and there is no # mobile view for graphs, so the graphs on the bottom of the host/service view are enough # for the moment. if html.is_mobile(): return force_pnp_graphing = False return html.render_a( content=html.render_icon('pnp', ''), href=url, onmouseout="cmk.hover.hide()", onmouseover= "cmk.graph_integration.show_hover_graphs(event, %s, %s, %s, %s, %s);" % ( json.dumps(row['site']), json.dumps(row["host_name"]), json.dumps(row.get('service_description', '_HOST_')), json.dumps(self._pnp_popup_url(row, what)), json.dumps(force_pnp_graphing), ))
def create_crash_dump_info_file(tar, what): crash_info = cmk.utils.crash_reporting.create_crash_info( what, details={ "page": html.myfile + ".py", "vars": { key: "***" if value in ["password", "_password"] else value for key, value in html.request.itervars() }, "username": config.user.id, "user_agent": html.request.user_agent, "referer": html.request.referer, "is_mobile": html.is_mobile(), "is_ssl_request": html.request.is_ssl_request, "language": cmk.gui.i18n.get_current_language(), "request_method": html.request.request_method, }, version=get_version(what)) content = cStringIO.StringIO() content.write(cmk.utils.crash_reporting.crash_info_to_string(crash_info)) content.seek(0) tarinfo = tarfile.TarInfo(name="crash.info") content.seek(0, os.SEEK_END) tarinfo.size = content.tell() content.seek(0) tar.addfile(tarinfo=tarinfo, fileobj=content)
def page_index() -> None: # Redirect to mobile GUI if we are a mobile device and the index is requested if html.is_mobile(): raise HTTPRedirect(makeuri(request, [], filename="mobile.py")) title = config.get_page_heading() content = html.render_iframe("", src=_get_start_url(), name="main") SidebarRenderer().show(title, content)
def from_exception(cls, details=None, type_specific_attributes=None): return super(GUICrashReport, cls).from_exception(details={ "page": html.myfile + ".py", "vars": { key: "***" if value in ["password", "_password"] else value for key, value in html.request.itervars() }, "username": config.user.id, "user_agent": html.request.user_agent.string, "referer": html.request.referer, "is_mobile": html.is_mobile(), "is_ssl_request": html.request.is_ssl_request, "language": cmk.gui.i18n.get_current_language(), "request_method": html.request.request_method, },)
def _pnp_icon(self, row, what): url = self._graph_icon_link(row, what) # Don't show the icon with Checkmk graphing. The hover makes no sense and there is no # mobile view for graphs, so the graphs on the bottom of the host/service view are enough # for the moment. if html.is_mobile(): return return html.render_a( content=html.render_icon('graph', ''), href=url, onmouseout="cmk.hover.hide()", onmouseover="cmk.graph_integration.show_hover_graphs(event, %s, %s, %s);" % ( json.dumps(row['site']), json.dumps(row["host_name"]), json.dumps(row['service_description'] if what == "service" else '_HOST_'), ))
def paint_time_graph_cmk(row, cell, override_graph_render_options=None): graph_identification = ("template", { "site": row["site"], "host_name": row["host_name"], "service_description": row.get("service_description", "_HOST_"), }) # Load the graph render options from # a) the painter parameters configured in the view # b) the painter options set per user and view painter_params = cell.painter_parameters() painter_params = _transform_old_graph_render_options(painter_params) graph_render_options = painter_params["graph_render_options"] if override_graph_render_options is not None: graph_render_options.update(override_graph_render_options) painter_options = PainterOptions.get_instance() options = painter_options.get_without_default("graph_render_options") if options is not None: graph_render_options.update(options) graph_data_range = {} now = time.time() if "set_default_time_range" in painter_params: duration = painter_params["set_default_time_range"] graph_data_range["time_range"] = now - duration, now else: graph_data_range["time_range"] = now - 3600 * 4, now # Load timerange from painter option (overrides the defaults, if set by the user) painter_option_pnp_timerange = painter_options.get_without_default("pnp_timerange") if painter_option_pnp_timerange is not None: graph_data_range["time_range"] = get_graph_timerange_from_painter_options() if html.is_mobile(): graph_render_options.update({ "interaction": False, "show_controls": False, "show_pin": False, "show_graph_time": False, "show_time_range_previews": False, "show_legend": False, # Would be much better to autodetect the possible size (like on dashboard) "size": (27, 18), # ex }) if "host_metrics" in row: available_metrics = row["host_metrics"] perf_data = row["host_perf_data"] else: available_metrics = row["service_metrics"] perf_data = row["service_perf_data"] if not available_metrics and perf_data: return "", _("No historic metrics recorded but performance data is available. " "Maybe performance data processing is disabled.") return "", html_render.render_graphs_from_specification_html(graph_identification, graph_data_range, graph_render_options)