Exemple #1
0
    def _get_static_check_entries(self, host_config):
        # type: (config.HostConfig) -> Iterator[Service]
        entries = []  # type: List[Service]
        for _checkgroup_name, check_plugin_name, item, params in host_config.static_checks:
            if config.has_timespecific_params(params):
                timespec_params = [params]
                params = {}
            else:
                timespec_params = []

            new_params = config.compute_check_parameters(
                host_config.hostname, check_plugin_name, item, params)

            if timespec_params:
                params = config.set_timespecific_param_list(
                    timespec_params, new_params)
            else:
                params = new_params

            descr = config.service_description(host_config.hostname,
                                               check_plugin_name, item)
            entries.append(Service(check_plugin_name, item, descr, params))

        # Note: We need to reverse the order of the static_checks. This is
        # because users assume that earlier rules have precedence over later
        # ones. For static checks that is important if there are two rules for
        # a host with the same combination of check type and item.
        return reversed(entries)
Exemple #2
0
def _get_static_check_entries(host_config: config.HostConfig,) -> Iterator[Service]:
    entries: List[Service] = []
    for _checkgroup_name, check_plugin_name_str, item, params in host_config.static_checks:
        # TODO (mo): centralize maincheckify: CMK-4295
        check_plugin_name = CheckPluginName(maincheckify(check_plugin_name_str))

        if config.has_timespecific_params(params):
            timespec_params = [params]
            params = {}
        else:
            timespec_params = []

        new_params = config.compute_check_parameters(
            host_config.hostname,
            check_plugin_name,
            item,
            params,
            for_static_checks=True,
        )

        if timespec_params:
            params = config.set_timespecific_param_list(timespec_params, new_params)
        else:
            params = new_params

        descr = config.service_description(host_config.hostname, check_plugin_name, item)
        entries.append(Service(check_plugin_name, item, descr, params))

    # Note: We need to reverse the order of the static_checks. This is
    # because users assume that earlier rules have precedence over later
    # ones. For static checks that is important if there are two rules for
    # a host with the same combination of check type and item.
    return reversed(entries)