diff --git a/.github/scripts/agent_installer_test.ps1 b/.github/scripts/agent_installer_test.ps1 index 8de2f10c33..957ff85e05 100644 --- a/.github/scripts/agent_installer_test.ps1 +++ b/.github/scripts/agent_installer_test.ps1 @@ -49,6 +49,9 @@ function test_args_to_registry { exit 1 } + #let time to windows to flush registry + Start-Sleep -Seconds 2 + foreach ($value_name in $expected_registry_values.Keys) { $expected_value = $($expected_registry_values[$value_name]) $real_value = (Get-ItemProperty -Path HKLM:\Software\Centreon\CentreonMonitoringAgent -Name $value_name).$value_name diff --git a/agent/doc/agent-doc.md b/agent/doc/agent-doc.md index be04edde88..7d051131b1 100644 --- a/agent/doc/agent-doc.md +++ b/agent/doc/agent-doc.md @@ -117,7 +117,7 @@ The second one relies on performance data counters (pdh API), it gives us percen The choice between the two methods is done by 'use-nt-query-system-information' boolean parameter. ### check_drive_size -we have to get free space on server drives. In case of network drives, this call can block in case of network failure. Unfortunately, there is no asynchronous API to do that. So a dedicated thread (drive_size_thread) computes these statistics. In order to be os independent and to test it, drive_size_thread relies on a functor that do the job: drive_size_thread::os_fs_stats. +we have to get free space on server drives. In case of network drives, this call can block in case of network failure. Unfortunately, there is no asynchronous API to do that. So a dedicated thread (drive_size_thread) computes these statistics. In order to be os independent and to test it, drive_size_thread relies on a functor that do the job: drive_size_thread::os_fs_stats. This functor is initialized in main function. drive_size thread is stopped at the end of main function. So it works like that: * check_drive_size post query in drive_size_thread queue diff --git a/agent/inc/com/centreon/agent/drive_size.hh b/agent/inc/com/centreon/agent/drive_size.hh index f176290abe..c47e4ad035 100644 --- a/agent/inc/com/centreon/agent/drive_size.hh +++ b/agent/inc/com/centreon/agent/drive_size.hh @@ -31,6 +31,11 @@ namespace com::centreon::agent { namespace check_drive_size_detail { +/** + * @brief these flags are passed in check parameter:filter-storage-type and + * filter-type + * + */ enum e_drive_fs_type : uint64_t { hr_unknown = 0, hr_storage_ram = 1 << 0, diff --git a/agent/native_windows/src/check_cpu.cc b/agent/native_windows/src/check_cpu.cc index e906ca702b..860f59e7b0 100644 --- a/agent/native_windows/src/check_cpu.cc +++ b/agent/native_windows/src/check_cpu.cc @@ -468,59 +468,60 @@ check_cpu::check_cpu(const std::shared_ptr& io_context, } } } - catch (const std::exception& e) { - SPDLOG_LOGGER_ERROR(_logger, "check_cpu fail to parse check params: {}", - e.what()); - throw; - } + } catch (const std::exception& e) { + SPDLOG_LOGGER_ERROR(_logger, "check_cpu fail to parse check params: {}", + e.what()); + throw; + } - if (_use_nt_query_system_information) { - _ntdll_init(); - } else { - _pdh_counters = std::make_unique(); - } + if (_use_nt_query_system_information) { + _ntdll_init(); + } else { + _pdh_counters = std::make_unique(); } +} - check_cpu::~check_cpu() {} - - std::unique_ptr< - check_cpu_detail::cpu_time_snapshot> - check_cpu::get_cpu_time_snapshot(bool first_measure) { - if (_use_nt_query_system_information) { - return std::make_unique( - _nb_core); - } else { - return std::make_unique( - _nb_core, *_pdh_counters, first_measure); - } +check_cpu::~check_cpu() {} + +std::unique_ptr< + check_cpu_detail::cpu_time_snapshot> +check_cpu::get_cpu_time_snapshot(bool first_measure) { + if (_use_nt_query_system_information) { + return std::make_unique( + _nb_core); + } else { + return std::make_unique( + _nb_core, *_pdh_counters, first_measure); } +} - constexpr std::array - _sz_summary_labels = {", User ", ", System ", ", Idle ", ", Interrupt ", - ", Dpc Interrupt "}; - - constexpr std::array - _sz_perfdata_name = {"user", "system", "idle", "interrupt", - "dpc_interrupt"}; - - /** - * @brief compute the difference between second_measure and first_measure and - * generate status, output and perfdatas - * - * @param first_measure first snapshot of /proc/stat - * @param second_measure second snapshot of /proc/stat - * @param output out plugin output - * @param perfs perfdatas - * @return e_status plugin out status - */ - e_status check_cpu::compute( - const check_cpu_detail::cpu_time_snapshot< - check_cpu_detail::e_proc_stat_index::nb_field>& first_measure, - const check_cpu_detail::cpu_time_snapshot< - check_cpu_detail::e_proc_stat_index::nb_field>& second_measure, - std::string* output, std::list* perfs) { - output->reserve(256 * _nb_core); - - return _compute(first_measure, second_measure, _sz_summary_labels.data(), - _sz_perfdata_name.data(), output, perfs); - } \ No newline at end of file +constexpr std::array + _sz_summary_labels = {", User ", ", System ", ", Idle ", ", Interrupt ", + ", Dpc Interrupt "}; + +constexpr std::array + _sz_perfdata_name = {"user", "system", "idle", "interrupt", + "dpc_interrupt"}; + +/** + * @brief compute the difference between second_measure and first_measure and + * generate status, output and perfdatas + * + * @param first_measure first snapshot of /proc/stat + * @param second_measure second snapshot of /proc/stat + * @param output out plugin output + * @param perfs perfdatas + * @return e_status plugin out status + */ +e_status check_cpu::compute( + const check_cpu_detail::cpu_time_snapshot< + check_cpu_detail::e_proc_stat_index::nb_field>& first_measure, + const check_cpu_detail::cpu_time_snapshot< + check_cpu_detail::e_proc_stat_index::nb_field>& second_measure, + std::string* output, + std::list* perfs) { + output->reserve(256 * _nb_core); + + return _compute(first_measure, second_measure, _sz_summary_labels.data(), + _sz_perfdata_name.data(), output, perfs); +} \ No newline at end of file diff --git a/agent/native_windows/src/check_uptime.cc b/agent/native_windows/src/check_uptime.cc index 0b059c4827..eb8066e440 100644 --- a/agent/native_windows/src/check_uptime.cc +++ b/agent/native_windows/src/check_uptime.cc @@ -18,7 +18,6 @@ #include #include -#include #include "absl/container/flat_hash_map.h" #include "check_uptime.hh" diff --git a/broker/CMakeLists.txt b/broker/CMakeLists.txt index 97012c7fbb..9443f4c549 100644 --- a/broker/CMakeLists.txt +++ b/broker/CMakeLists.txt @@ -465,7 +465,7 @@ target_link_libraries(roker rokerbase crypto ssl pthread dl) # Standalone binary. add_executable(cbd ${SRC_DIR}/main.cc) -add_dependencies(cbd multiplexing centreon_common) +add_dependencies(cbd multiplexing centreon_common pb_neb_lib) # Flags needed to include all symbols in binary. target_link_libraries( diff --git a/tests/broker-engine/cma.robot b/tests/broker-engine/cma.robot index dc8a96ef61..96e3140d9f 100644 --- a/tests/broker-engine/cma.robot +++ b/tests/broker-engine/cma.robot @@ -396,7 +396,7 @@ BEOTEL_CENTREON_AGENT_CHECK_NATIVE_CPU #a small threshold to make service_1 warning Ctn Engine Config Replace Value In Services ${0} service_1 check_command otel_check2 - Ctn Engine Config Add Command ${0} otel_check2 {"check": "cpu_percentage", "args": {"warning-average" : "0.1"}} OTEL connector + Ctn Engine Config Add Command ${0} otel_check2 {"check": "cpu_percentage", "args": {"warning-average" : "0.01"}} OTEL connector Ctn Reload Engine ${result} Ctn Check Service Resource Status With Timeout host_1 service_1 1 60 ANY @@ -405,7 +405,7 @@ BEOTEL_CENTREON_AGENT_CHECK_NATIVE_CPU #a small threshold to make service_1 critical Ctn Engine Config Replace Value In Services ${0} service_1 check_command otel_check3 - Ctn Engine Config Add Command ${0} otel_check3 {"check": "cpu_percentage", "args": {"critical-average" : "0.2", "warning-average" : "0.1"}} OTEL connector + Ctn Engine Config Add Command ${0} otel_check3 {"check": "cpu_percentage", "args": {"critical-average" : "0.02", "warning-average" : "0.01"}} OTEL connector Ctn Reload Engine ${result} Ctn Check Service Resource Status With Timeout host_1 service_1 2 60 ANY @@ -557,11 +557,11 @@ Ctn Create Cert And Init [Documentation] create key and certificates used by agent and engine on linux side ${host_name} Ctn Get Hostname ${run_env} Ctn Run Env - # IF "${run_env}" == "WSL" - # Copy File ../server_grpc.key /tmp/server_grpc.key - # Copy File ../server_grpc.crt /tmp/server_grpc.crt - # ELSE - # Ctn Create Key And Certificate ${host_name} /tmp/server_grpc.key /tmp/server_grpc.crt - # END + IF "${run_env}" == "WSL" + Copy File ../server_grpc.key /tmp/server_grpc.key + Copy File ../server_grpc.crt /tmp/server_grpc.crt + ELSE + Ctn Create Key And Certificate ${host_name} /tmp/server_grpc.key /tmp/server_grpc.crt + END Ctn Clean Before Suite