예제 #1
0
def _get_monitoring_data_kwargs_by_source(
    parsed_sections_broker: ParsedSectionsBroker,
    host_config: config.HostConfig,
    config_cache: config.ConfigCache,
    ipaddress: Optional[HostAddress],
    service: Service,
    sections: Sequence[ParsedSectionName],
    source_type: SourceType,
) -> Tuple[Mapping[str, object], ServiceCheckResult]:
    if host_config.is_cluster:
        nodes = config_cache.get_clustered_service_node_keys(
            host_config,
            source_type,
            service.description,
        )
        return (
            get_section_cluster_kwargs(
                parsed_sections_broker,
                nodes,
                sections,
            ),
            cluster_received_no_data(nodes),
        )

    return (
        get_section_kwargs(
            parsed_sections_broker,
            HostKey(host_config.hostname, ipaddress, source_type),
            sections,
        ),
        RECEIVED_NO_DATA,
    )
예제 #2
0
def _get_monitoring_data_kwargs(
    parsed_sections_broker: ParsedSectionsBroker,
    host_config: config.HostConfig,
    config_cache: config.ConfigCache,
    ipaddress: Optional[HostAddress],
    service: ConfiguredService,
    sections: Sequence[ParsedSectionName],
    source_type: Optional[SourceType] = None,
) -> Tuple[Mapping[str, object], ServiceCheckResult]:
    if source_type is None:
        source_type = (
            SourceType.MANAGEMENT
            if service.check_plugin_name.is_management_name()
            else SourceType.HOST
        )

    if host_config.is_cluster:
        nodes = config_cache.get_clustered_service_node_keys(
            host_config,
            source_type,
            service.description,
        )
        return (
            get_section_cluster_kwargs(
                parsed_sections_broker,
                nodes,
                sections,
            ),
            ServiceCheckResult.cluster_received_no_data(nodes),
        )

    return (
        get_section_kwargs(
            parsed_sections_broker,
            HostKey(host_config.hostname, ipaddress, source_type),
            sections,
        ),
        ServiceCheckResult.received_no_data(),
    )