示例#1
0
    def __init__(self, dashboard_name: DashboardName,
                 dashboard: DashboardConfig, dashlet_id: DashletId,
                 dashlet: DashletConfig) -> None:
        super().__init__(dashboard_name=dashboard_name,
                         dashboard=dashboard,
                         dashlet_id=dashlet_id,
                         dashlet=dashlet)

        if any((
                self.type_name() == 'pnpgraph'
                and not self._dashlet_spec["context"],
                self.type_name() == 'custom_graph'
                and self._dashlet_spec.get('custom_graph') is None,
        )):
            return  # The dashlet is not yet configured

        self._dashlet_spec[
            "_graph_identification"] = self.graph_identification()

        graph_recipes = resolve_graph_recipe(
            self._dashlet_spec["_graph_identification"])
        if not isinstance(graph_recipes, list):
            return
        if graph_recipes:
            self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]
        else:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))

        # New graphs which have been added via "add to visual" option don't have a timerange
        # configured. So we assume the default timerange here by default.
        self._dashlet_spec.setdefault('timerange', '1')
示例#2
0
    def __init__(self, dashboard_name: DashboardName, dashboard: DashboardConfig,
                 dashlet_id: DashletId, dashlet: DashletConfig) -> None:
        super().__init__(dashboard_name=dashboard_name,
                         dashboard=dashboard,
                         dashlet_id=dashlet_id,
                         dashlet=dashlet)
        # Be compatible to pre 1.5.0i2 format
        if "graph_render_options" not in self._dashlet_spec:
            self._dashlet_spec["graph_render_options"] = transform_graph_render_options({
                "show_legend": self._dashlet_spec.pop("show_legend", False),
                "show_service": self._dashlet_spec.pop("show_service", True),
            })

        title_format = self._dashlet_spec.setdefault(
            "title_format", default_dashlet_graph_render_options["title_format"])
        self._dashlet_spec["graph_render_options"].setdefault("title_format", title_format)

        self._dashlet_spec["_graph_identification"] = self.graph_identification()

        graph_recipes = resolve_graph_recipe(self._dashlet_spec["_graph_identification"])
        if not isinstance(graph_recipes, list):
            return
        if graph_recipes:
            self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]
        else:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))

        # New graphs which have been added via "add to visual" option don't have a timerange
        # configured. So we assume the default timerange here by default.
        self._dashlet_spec.setdefault('timerange', '1')
示例#3
0
文件: graph.py 项目: Titan-C/checkmk
    def _init_graph(self):
        context = visuals.get_merged_context(
            visuals.get_context_from_uri_vars(["host", "service"],
                                              self.single_infos()),
            self._dashlet_spec["context"])
        self._dashlet_spec[
            "_graph_identification"] = self.graph_identification(context)

        graph_recipes = resolve_graph_recipe(
            self._dashlet_spec["_graph_identification"])
        if isinstance(graph_recipes, list) and graph_recipes:
            self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]
        else:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))
示例#4
0
    def _init_graph(self):
        context = visuals.get_merged_context(
            visuals.get_context_from_uri_vars(["host", "service"], self.single_infos()),
            self._dashlet_spec["context"])
        self._dashlet_spec["_graph_identification"] = self.graph_identification(context)

        try:
            graph_recipes = resolve_graph_recipe(self._dashlet_spec["_graph_identification"])
        except MKMissingDataError:
            raise
        except:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))

        self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]
示例#5
0
    def _init_graph(self):
        self._dashlet_spec[
            "_graph_identification"] = self.graph_identification(self.context)

        try:
            graph_recipes = resolve_graph_recipe(
                self._dashlet_spec["_graph_identification"])
        except MKMissingDataError:
            raise
        except livestatus.MKLivestatusNotFoundError:
            raise make_mk_missing_data_error()
        except Exception:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))

        self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]
示例#6
0
文件: graph.py 项目: NimVek/checkmk
    def _init_graph(self):
        context = visuals.get_merged_context(
            visuals.get_context_from_uri_vars(["host", "service"],
                                              self.single_infos()),
            self._dashlet_spec["context"])
        self._dashlet_spec[
            "_graph_identification"] = self.graph_identification(context)

        try:
            graph_recipes = resolve_graph_recipe(
                self._dashlet_spec["_graph_identification"])
        except MKMissingDataError:
            raise
        except livestatus.MKLivestatusNotFoundError as livestatus_excpt:
            raise MKMissingDataError(
                _("Missing data needed to render this graph. Details: %s") %
                livestatus_excpt)
        except Exception:
            raise MKGeneralException(_("Failed to calculate a graph recipe."))

        self._dashlet_spec["_graph_title"] = graph_recipes[0]["title"]