コード例 #1
0
def bar_chart_vs_time_components():
    return [
        ("time_range", Timerange(
            title=_("Time range"),
            default_value='d0',
        )),
        ("time_resolution",
         DropdownChoice(
             title=_("Time resolution"),
             choices=[("h", _("Show per hour")), ("d", _("Show per day"))],
             default_value="h",
         )),
    ]
コード例 #2
0
    def required_columns(properties, context):
        cmc_cols = [
            'host_name', 'host_state', 'service_description', 'service_state',
            'service_check_command', 'service_metrics', 'service_perf_data'
        ]

        from_time, until_time = map(
            int,
            Timerange().compute_range(properties['time_range'])[0])
        metric_columns = metric_in_all_rrd_columns(properties["metric"], 'max',
                                                   from_time, until_time)

        return cmc_cols + metric_columns
コード例 #3
0
ファイル: graph.py プロジェクト: m3rlinux/checkmk
    def _reload_js(self):
        if any(prop not in self._dashlet_spec for prop in
               ["_graph_identification", "graph_render_options", "timerange"]):
            return ""

        return "dashboard_render_graph(%d, %s, %s, %s)" % (
            self._dashlet_id,
            json.dumps(self._dashlet_spec["_graph_identification"]),
            json.dumps(self._dashlet_spec["graph_render_options"]),
            json.dumps(
                Timerange.compute_range(
                    self._dashlet_spec["timerange"]).range),
        )
コード例 #4
0
def required_columns(properties, context):
    cmc_cols = [
        "host_name", "service_check_command", "service_description", "service_perf_data",
        "service_state", "service_has_been_checked"
    ]
    metric_columns = []
    if properties.get("time_range", "current")[0] == "range":
        params = properties["time_range"][1]
        from_time, until_time = map(int, Timerange().compute_range(params['window'])[0])
        metric_columns = metric_in_all_rrd_columns(properties["metric"],
                                                   params["rrd_consolidation"], from_time,
                                                   until_time)

    return cmc_cols + metric_columns
コード例 #5
0
 def bar_chart_vs_components(cls):
     # Specifies the properties for this data generator
     return [
         ("time_range",
          Timerange(
              title=_("Time range"),
              default_value='d0',
          )),
         ("time_resolution",
          DropdownChoice(
              title=_("Time resolution"),
              choices=[("h", _("Show per hour")), ("d", _("Show per day"))],
              default_value="h",
          )),
     ]
コード例 #6
0
def _time_range_historic_dict_elements(with_elements) -> DictionaryElements:
    yield 'window', Timerange(
        title=_("Time range to consider"),
        default_value="d0",
    )
    yield "rrd_consolidation", DropdownChoice(
        choices=[
            ("average", _("Average")),
            ("min", _("Minimum")),
            ("max", _("Maximum")),
        ],
        default_value="max",
        title=_("Metric compression (RRD)"),
        help=_("Consolidation function for the [cms_graphing#rrds|RRD] data column"),
    )
コード例 #7
0
    def _get_data(cls, properties, context):
        cmc_cols = [
            'host_name', 'host_state', 'service_description', 'service_state',
            'service_check_command', 'service_metrics', 'service_perf_data'
        ]

        from_time, until_time = map(int, Timerange().compute_range(properties['time_range'])[0])
        data_range = "%s:%s:%s" % (from_time, until_time, 60)
        _metrics: List[Tuple[str, Optional[str], float]] = [
            (name, None, scale)
            for name, scale in reverse_translate_metric_name(properties['metric'])
        ]
        metric_colums = list(rrd_columns(_metrics, 'max', data_range))

        return cmc_cols + metric_colums
コード例 #8
0
ファイル: alert_statistics.py プロジェクト: maxmalysh/checkmk
 def vs_parameters(cls) -> Dictionary:
     return Dictionary(title=_("Properties"),
                       render="form",
                       optional_keys=["limit_objects"],
                       elements=[
                           ("time_range", Timerange(
                               title=_("Time range"),
                               default_value=90000,
                           )),
                           ("limit_objects",
                            Integer(
                                title=_("Limit objects"),
                                default_value=100,
                                minvalue=1,
                            )),
                       ])
コード例 #9
0
 def _vs_elements(cls):
     return [
         ("metric", MetricName()
          ),  # MetricChoice would be nicer, but we use the context filters
         ("time_range",
          CascadingDropdown(
              title=_("Timerange"),
              orientation="horizontal",
              choices=[
                  ("current", _("Only show current value")),
                  ("range", _("Show historic values"),
                   Dictionary(
                       optional_keys=False,
                       elements=[
                           ('window',
                            Timerange(title=_("Time range to consider"),
                                      default_value="d0",
                                      allow_empty=True)),
                           ("rrd_consolidation",
                            DropdownChoice(
                                choices=[
                                    ("average", _("Average")),
                                    ("min", _("Minimum")),
                                    ("max", _("Maximum")),
                                ],
                                default_value="max",
                                title="RRD consolidation",
                                help=
                                _("Consolidation function for the [cms_graphing#rrds|RRD] data column"
                                  ),
                            )),
                       ])),
              ],
              default_value="current")),
         ("status_border",
          DropdownChoice(
              title=_("Status border"),
              choices=[
                  (False, _("Do not show any service status border")),
                  ("not_ok",
                   _("Draw a status border when service is not OK")),
                  ("always",
                   _("Always draw the service status on the border")),
              ],
              default_value="not_ok")),
     ]
コード例 #10
0
ファイル: single_metric.py プロジェクト: majma24/checkmk
    def _get_data(cls, properties, context):
        cmc_cols = [
            "host_name", "service_check_command", "service_description", "service_perf_data"
        ]
        metric_columns = []
        if properties["time_range"] != "current":
            from_time, until_time = map(int,
                                        Timerange().compute_range(properties["time_range"][1])[0])
            data_range = "%s:%s:%s" % (from_time, until_time, 60)
            _metrics: List[Tuple[str, Optional[str], float]] = [
                (name, None, scale)
                for name, scale in reverse_translate_metric_name(properties["metric"])
            ]
            metric_columns = list(rrd_columns(_metrics, properties["rrd_consolidation"],
                                              data_range))

        return cmc_cols + metric_columns
コード例 #11
0
 def _scatterplot_vs_components(cls):
     return [
         ("time_range", Timerange(
             title=_("Time range"),
             default_value='d0',
         )),
         ("scatterplot_title",
          CascadingDropdown(title=_("Average scatterplot title"),
                            orientation="horizontal",
                            choices=[
                                ("show", _("Show default title")),
                                ("hide", _("Hide title")),
                                ("custom", _("Set a custom title:"),
                                 TextUnicode(default_value="")),
                            ],
                            default_value="show")),
     ]
コード例 #12
0
 def _vs_elements() -> DictionaryElements:
     return [
         ("metric", MetricName()),
         ("time_range",
          Timerange(
              title=_("Time range"),
              default_value='d0',
          )),
         ("metric_color",
          GraphColor(title=_("Color for the main metric scattered dots"),
                     default_value="default")),
         ("avg_color",
          GraphColor(title=_("Color for the average line"),
                     default_value="default")),
         ("median_color",
          GraphColor(title=_("Color for the median line"),
                     default_value="default")),
     ]
コード例 #13
0
ファイル: werks.py プロジェクト: m3rlinux/checkmk
def _werk_table_options_from_request() -> Dict[str, Any]:
    if request.var("show_unack") and not request.has_var("wo_set"):
        return _default_werk_table_options()

    werk_table_options: Dict[str, Any] = {}
    for name, _height, vs, default_value in _werk_table_option_entries():
        value = default_value
        try:
            if request.has_var("wo_set"):
                value = vs.from_html_vars("wo_" + name)
                vs.validate_value(value, "wo_" + name)
        except MKUserError as e:
            html.user_error(e)

        werk_table_options.setdefault(name, value)

    from_date, until_date = Timerange.compute_range(werk_table_options["date"]).range
    werk_table_options["date_range"] = from_date, until_date

    return werk_table_options
コード例 #14
0
 def vs_parameters(cls):
     return Dictionary(
         title=_("Properties"),
         render="form",
         optional_keys=[],
         elements=[
             ("metric", MetricName()),
             ("time_range",
              Timerange(
                  title=_("Time range"),
                  default_value='d0',
              )),
             ("metric_color",
              GraphColor(
                  title=_("Color for the main metric scattered dots"),
                  default_value="default")),
             ("avg_color",
              GraphColor(title=_("Color for the average line"),
                         default_value="default")),
             ("median_color",
              GraphColor(title=_("Color for the median line"),
                         default_value="default")),
         ])
コード例 #15
0
 def _vs_elements(cls):
     return [
         ("render_mode",
          CascadingDropdown(
              title=_("Display"),
              choices=[
                  ("bar_chart", _("Bar chart"),
                   Dictionary(
                       elements=bar_chart_vs_time_components(),
                       optional_keys=[],
                   )),
                  ("simple_number", _("Number of notifications as text"),
                   Dictionary(
                       elements=[
                           ("time_range",
                            Timerange(
                                title=_("Time range"),
                                default_value='d0',
                            )),
                       ],
                       optional_keys=[],
                   )),
              ],
          )),
         ("log_target",
          DropdownChoice(
              title=_("Host or service %ss" % cls.log_type),
              choices=[
                  ("both",
                   _("Show %ss for hosts and services" % cls.log_type)),
                  ("host", _("Show %ss for hosts" % cls.log_type)),
                  ("service", _("Show %ss for services" % cls.log_type)),
              ],
              default_value="both",
          )),
     ]
コード例 #16
0
ファイル: werks.py プロジェクト: bsmr/tribe29-checkmk
def _werk_table_option_entries():
    translator = cmk.utils.werks.WerkTranslator()
    return [
        ("classes", "double",
         ListChoice(
             title=_("Classes"),
             choices=sorted(translator.classes()),
         ), ["feature", "fix", "security"]),
        ("levels", "double",
         ListChoice(
             title=_("Levels"),
             choices=sorted(translator.levels()),
         ), [1, 2, 3]),
        ("date", "double", Timerange(title=_("Date")),
         ('date', (1383149313, int(time.time())))),
        ("id", "single",
         TextAscii(
             title=_("Werk ID"),
             label="#",
             regex="^[0-9]{1,5}$",
             size=7,
         ), ""),
        ("compatibility", "single",
         DropdownChoice(title=_("Compatibility"),
                        choices=[
                            (["compat", "incomp_ack", "incomp_unack"],
                             _("Compatible and incompatible Werks")),
                            (["compat"], _("Compatible Werks")),
                            (["incomp_ack",
                              "incomp_unack"], _("Incompatible Werks")),
                            (["incomp_unack"],
                             _("Unacknowledged incompatible Werks")),
                            (["incomp_ack"],
                             _("Acknowledged incompatible Werks")),
                        ]), ["compat", "incomp_ack", "incomp_unack"]),
        ("component", "single",
         DropdownChoice(
             title=_("Component"),
             choices=[
                 (None, _("All components")),
             ] + sorted(translator.components()),
         ), None),
        ("edition", "single",
         DropdownChoice(
             title=_("Edition"),
             choices=[
                 (None, _("All editions")),
                 ("cme",
                  _("Werks only concerning the Managed Services Edition")),
                 ("cee", _("Werks only concerning the Enterprise Edition")),
                 ("cre", _("Werks also concerning the Raw Edition")),
             ],
         ), None),
        ("werk_content", "single",
         TextUnicode(
             title=_("Werk title or content"),
             size=41,
         ), ""),
        ("version", "single",
         Tuple(title=_("Checkmk Version"),
               orientation="float",
               elements=[
                   TextAscii(label=_("from:"), size=12),
                   TextAscii(label=_("to:"), size=12),
               ]), ("", "")),
        ("grouping", "single",
         DropdownChoice(
             title=_("Group Werks by"),
             choices=[
                 ("version", _("Checkmk Version")),
                 ("day", _("Day of creation")),
                 ("week", _("Week of creation")),
                 (None, _("Do not group")),
             ],
         ), "version"),
        ("group_limit", "single",
         Integer(
             title=_("Show number of groups"),
             unit=_("groups"),
             minvalue=1,
         ), 20),
    ]
コード例 #17
0
ファイル: single_metric.py プロジェクト: OguzhanCicek/checkmk
 def _vs_elements(cls):
     return [
         ("metric", MetricName()
          ),  # MetricChoice would be nicer, but we use the context filters
         ("time_range",
          CascadingDropdown(
              title=_("Timerange"),
              orientation="horizontal",
              choices=[
                  ("current", _("Only show current value")),
                  ("range", _("Show historic values"),
                   Dictionary(
                       optional_keys=False,
                       elements=[
                           ('window',
                            Timerange(title=_("Time range to consider"),
                                      default_value="d0",
                                      allow_empty=True)),
                           ("rrd_consolidation",
                            DropdownChoice(
                                choices=[
                                    ("average", _("Average")),
                                    ("min", _("Minimum")),
                                    ("max", _("Maximum")),
                                ],
                                default_value="max",
                                title="RRD consolidation",
                                help=
                                _("Consolidation function for the [cms_graphing#rrds|RRD] data column"
                                  ),
                            )),
                       ])),
              ],
              default_value="current")),
         ("display_range",
          CascadingDropdown(
              title=_("Display range"),
              choices=[
                  ("infer", _("Automatic")),
                  ("fixed", _("Fixed range"),
                   ValuesWithUnits(
                       vs_name="display_range",
                       metric_vs_name="metric",
                       help=_(
                           "Set the range in which data is displayed. "
                           "Having selected a metric before auto selects "
                           "here the matching unit of the metric."),
                       elements=[_("Minimum"), _("Maximum")])),
              ])),
         ("status_border",
          DropdownChoice(
              title=_("Status border"),
              choices=[
                  (False, _("Do not show any service status border")),
                  ("not_ok",
                   _("Draw a status border when service is not OK")),
                  ("always",
                   _("Always draw the service status on the border")),
              ],
              default_value="not_ok")),
     ]
コード例 #18
0
ファイル: werks.py プロジェクト: m3rlinux/checkmk
def _werk_table_option_entries():
    translator = cmk.utils.werks.WerkTranslator()
    return [
        (
            "classes",
            "double",
            ListChoice(
                title=_("Classes"),
                choices=sorted(translator.classes()),
            ),
            ["feature", "fix", "security"],
        ),
        (
            "levels",
            "double",
            ListChoice(
                title=_("Levels"),
                choices=sorted(translator.levels()),
            ),
            [1, 2, 3],
        ),
        ("date", "double", Timerange(title=_("Date")), ("date", (1383149313, int(time.time())))),
        (
            "id",
            "single",
            TextInput(
                title=_("Werk ID"),
                label="#",
                regex="^[0-9]{1,5}$",
                size=7,
            ),
            "",
        ),
        (
            "compatibility",
            "single",
            DropdownChoice(
                title=_("Compatibility"),
                choices=[
                    (
                        ["compat", "incomp_ack", "incomp_unack"],
                        _("Compatible and incompatible Werks"),
                    ),
                    (["compat"], _("Compatible Werks")),
                    (["incomp_ack", "incomp_unack"], _("Incompatible Werks")),
                    (["incomp_unack"], _("Unacknowledged incompatible Werks")),
                    (["incomp_ack"], _("Acknowledged incompatible Werks")),
                ],
            ),
            ["compat", "incomp_ack", "incomp_unack"],
        ),
        (
            "component",
            "single",
            DropdownChoice(
                title=_("Component"),
                choices=[
                    (None, _("All components")),
                ]
                + sorted(translator.components()),
            ),
            None,
        ),
        (
            "edition",
            "single",
            DropdownChoice(
                title=_("Edition"),
                choices=[
                    (None, _("All editions")),
                    *(
                        (e.short, _("Werks only concerning the %s") % e.title)
                        for e in (Edition.CPE, Edition.CME, Edition.CEE, Edition.CRE)
                    ),
                ],
            ),
            None,
        ),
        (
            "werk_content",
            "single",
            TextInput(
                title=_("Werk title or content"),
                size=41,
            ),
            "",
        ),
        (
            "version",
            "single",
            Tuple(
                title=_("Checkmk Version"),
                orientation="float",
                elements=[
                    TextInput(label=_("from:"), size=12),
                    TextInput(label=_("to:"), size=12),
                ],
            ),
            (Version(__version__).version_base, ""),
        ),
        (
            "grouping",
            "single",
            DropdownChoice(
                title=_("Group Werks by"),
                choices=[
                    ("version", _("Checkmk Version")),
                    ("day", _("Day of creation")),
                    ("week", _("Week of creation")),
                    (None, _("Do not group")),
                ],
            ),
            "version",
        ),
        (
            "group_limit",
            "single",
            Integer(
                title=_("Show number of groups"),
                unit=_("groups"),
                minvalue=1,
            ),
            50,
        ),
    ]
コード例 #19
0
 def _int_time_range_from_rangespec(cls, rangespec):
     time_range, _range_title = Timerange().compute_range(rangespec)
     return [int(t) for t in time_range]
コード例 #20
0
ファイル: single_metric.py プロジェクト: mahdi7839/checkmk
 def _vs_elements(cls):
     return [
         ("metric", MetricName()
          ),  # MetricChoice would be nicer, but we use the context filters
         ("time_range",
          CascadingDropdown(
              title=_("Timerange"),
              orientation="horizontal",
              choices=[
                  ("current", _("Only show current value")),
                  ("range", _("Show historic values"),
                   Dictionary(
                       optional_keys=False,
                       elements=[
                           ('window',
                            Timerange(title=_("Time range to consider"),
                                      default_value="d0",
                                      allow_empty=True)),
                           ("rrd_consolidation",
                            DropdownChoice(
                                choices=[
                                    ("average", _("Average")),
                                    ("min", _("Minimum")),
                                    ("max", _("Maximum")),
                                ],
                                default_value="max",
                                title="RRD consolidation",
                                help=
                                _("Consolidation function for the [cms_graphing#rrds|RRD] data column"
                                  ),
                            )),
                       ])),
              ],
              default_value="current")),
         ("display_range",
          CascadingDropdown(
              title=_("Display range"),
              choices=[
                  ("infer",
                   _("Infer range from available data and check output")),
                  ("fixed", _("Fixed range"),
                   Tuple(
                       title=_("Fixed range"),
                       help=_(
                           "Use a fixed range for the Data displayed. This "
                           "value has no scaling. If your metric is in the "
                           "range of MB, you'll need to place 9 zeros for "
                           "display to make sense."),
                       elements=[
                           Float(title=_("Minimum")),
                           Float(title=_("Maximum")),
                       ])),
              ])),
         ("status_border",
          DropdownChoice(
              title=_("Status border"),
              choices=[
                  (False, _("Do not show any service status border")),
                  ("not_ok",
                   _("Draw a status border when service is not OK")),
                  ("always",
                   _("Always draw the service status on the border")),
              ],
              default_value="not_ok")),
     ]
コード例 #21
0
 def _int_time_range_from_rangespec(self, rangespec) -> Tuple[int, int]:
     time_range, _range_title = Timerange().compute_range(rangespec)
     return int(time_range[0]), int(time_range[1])