Esempio n. 1
0
    def render(self, row: Row, cell: Cell) -> CellSpec:
        classes = ["perfometer"]
        if is_stale(row):
            classes.append("stale")

        try:
            title, h = Perfometer(row).render()
            if title is None and h is None:
                return "", ""
        except Exception as e:
            logger.exception("error rendering performeter")
            if config.debug:
                raise
            return " ".join(classes), _("Exception: %s") % e

        assert h is not None
        content = (html.render_div(HTML(h), class_=["content"]) +
                   html.render_div(title, class_=["title"]) +
                   html.render_div("", class_=["glass"]))

        # pnpgraph_present: -1 means unknown (path not configured), 0: no, 1: yes
        if display_options.enabled(
                display_options.X) and row["service_pnpgraph_present"] != 0:
            url = cmk_graph_url(row, "service")
            disabled = False
        else:
            url = "javascript:void(0)"
            disabled = True

        return " ".join(classes), html.render_a(
            content=content,
            href=url,
            title=escaping.strip_tags(title),
            class_=["disabled" if disabled else None],
        )
Esempio n. 2
0
 def render(self, what, row, tags, custom_vars):
     # Adds the url_prefix of the services site to the notes url configured in this site.
     # It also adds the master_url which will be used to link back to the source site
     # in multi site environments.
     if display_options.enabled(display_options.X):
         notes_url = row[what + "_notes_url_expanded"]
         if notes_url:
             return "notes", _("Custom Notes"), (notes_url, "_blank")
Esempio n. 3
0
 def render(self, what, row, tags, custom_vars):
     if display_options.enabled(display_options.X):
         # action_url (only, if not a PNP-URL and pnp_graph is working!)
         action_url = row[what + "_action_url_expanded"]
         pnpgraph_present = row[what + "_pnpgraph_present"]
         if action_url and not ("/pnp4nagios/" in action_url
                                and pnpgraph_present >= 0):
             return "action", _("Custom Action"), action_url