def execute_check( multi_host_sections: MultiHostSections, host_config: config.HostConfig, ipaddress: Optional[HostAddress], service: Service, *, submit_to_core: bool, show_perfdata: bool, ) -> bool: plugin = agent_based_register.get_check_plugin(service.check_plugin_name) # Make a bit of context information globally available, so that functions # called by checks know this context. set_service is needed for predictive levels! # TODO: This should be a context manager, similar to value_store (f.k.a. item_state) # This is used for both legacy and agent_based API. check_api_utils.set_service(str(service.check_plugin_name), service.description) # check if we must use legacy mode. remove this block entirely one day if (plugin is not None and host_config.is_cluster and plugin.cluster_check_function.__name__ == "cluster_legacy_mode_from_hell"): with _service_context(service): return _execute_check_legacy_mode( multi_host_sections, host_config.hostname, ipaddress, service, submit_to_core=submit_to_core, show_perfdata=show_perfdata, ) submit, data_received, result = get_aggregated_result( multi_host_sections, host_config, ipaddress, service, plugin, lambda: determine_check_params(service.parameters), ) if submit: _submit_check_result( host_config.hostname, service.description, result, multi_host_sections.get_cache_info(plugin.sections) if plugin else None, submit_to_core=submit_to_core, show_perfdata=show_perfdata, ) elif data_received: console.verbose("%-20s PEND - %s\n", ensure_str(service.description), result[1]) return data_received
def execute_check( multi_host_sections: MultiHostSections, host_config: config.HostConfig, ipaddress: Optional[HostAddress], service: Service, *, submit_to_core: bool, show_perfdata: bool, ) -> bool: plugin = agent_based_register.get_check_plugin(service.check_plugin_name) # check if we must use legacy mode. remove this block entirely one day if (plugin is not None and host_config.is_cluster and plugin.cluster_check_function.__name__ == "cluster_legacy_mode_from_hell"): with _service_context(service): return _execute_check_legacy_mode( multi_host_sections, host_config.hostname, ipaddress, service, submit_to_core=submit_to_core, show_perfdata=show_perfdata, ) submit, data_received, result = get_aggregated_result( multi_host_sections, host_config, ipaddress, service, plugin, lambda: determine_check_params(service.parameters), ) if submit: _submit_check_result( host_config.hostname, service.description, result, multi_host_sections.get_cache_info(plugin.sections) if plugin else None, submit_to_core=submit_to_core, show_perfdata=show_perfdata, ) elif data_received: console.verbose("%-20s PEND - %s\n", ensure_str(service.description), result[1]) return data_received