Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20164 centreon-collect-24.04.7 Centreon next 24.04 (Jira release #20211#) #1893

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ jobs:
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

- name: Test ${{ matrix.image }}
uses: ./.github/actions/runner-docker
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ jobs:
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gorgone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
veracode_api_id: ${{ secrets.VERACODE_API_ID_GORG }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_GORG }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }}
docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

package:
needs: [get-environment]
Expand Down Expand Up @@ -85,8 +85,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: package ${{ matrix.distrib }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/libzmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: package ${{ matrix.distrib }}

Expand Down Expand Up @@ -101,8 +101,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: package ${{ matrix.distrib }} ${{ matrix.arch }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lua-curl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.img_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: package ${{ matrix.distrib }} ${{ matrix.arch }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jobs:
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ inputs.img_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

name: package ${{ matrix.distrib }} ${{ matrix.arch }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/robot-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
veracode_api_id: ${{ secrets.VERACODE_API_ID_COLL }}
veracode_api_key: ${{ secrets.VERACODE_API_KEY_COLL }}
veracode_srcclr_token: ${{ secrets.VERACODE_SRCCLR_TOKEN }}
docker_registry_id: ${{ secrets.DOCKER_REGISTRY_ID }}
docker_registry_passwd: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
docker_registry_id: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
docker_registry_passwd: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}

package:
needs: [get-environment]
Expand Down Expand Up @@ -124,8 +124,8 @@ jobs:
tests_params: ${{matrix.tests_params}}
test_group_name: ${{matrix.test_group_name}}
secrets:
registry_username: ${{ secrets.DOCKER_REGISTRY_ID }}
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
registry_username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
registry_password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
collect_s3_access_key: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
collect_s3_secret_key: ${{ secrets.COLLECT_S3_SECRET_KEY }}
xray_client_id: ${{ secrets.XRAY_CLIENT_ID }}
Expand Down
27 changes: 18 additions & 9 deletions broker/core/sql/src/mysql_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* For more information : [email protected]
*/
#include <errmsg.h>
#include <mysqld_error.h>

#include "com/centreon/broker/config/applier/init.hh"
#include "com/centreon/broker/misc/misc.hh"
Expand Down Expand Up @@ -460,18 +461,26 @@ void mysql_connection::_statement(mysql_task* t) {
"mysql_connection {:p}: execute statement {:x} attempt {}: {}",
static_cast<const void*>(this), task->statement_id, attempts, query);
if (mysql_stmt_execute(stmt)) {
std::string err_msg(
fmt::format("{} errno={} {}", mysql_error::msg[task->error_code],
::mysql_errno(_conn), ::mysql_stmt_error(stmt)));
SPDLOG_LOGGER_ERROR(_logger,
"connection fail to execute statement {:p}: {}",
static_cast<const void*>(this), err_msg);
if (_server_error(::mysql_stmt_errno(stmt))) {
int32_t err_code = ::mysql_stmt_errno(stmt);
std::string err_msg(fmt::format("{} errno={} {}",
mysql_error::msg[task->error_code],
err_code, ::mysql_stmt_error(stmt)));
if (err_code == 0) {
SPDLOG_LOGGER_TRACE(_logger,
"mysql_connection: errno=0, so we simulate a "
"server error CR_SERVER_LOST");
err_code = CR_SERVER_LOST;
} else {
SPDLOG_LOGGER_ERROR(_logger,
"connection fail to execute statement {:p}: {}",
static_cast<const void*>(this), err_msg);
}
if (_server_error(err_code)) {
set_error_message(err_msg);
break;
}
if (mysql_stmt_errno(stmt) != 1213 &&
mysql_stmt_errno(stmt) != 1205) // Dead Lock error
if (err_code != ER_LOCK_DEADLOCK &&
err_code != ER_LOCK_WAIT_TIMEOUT) // Dead Lock error
attempts = MAX_ATTEMPTS;

if (mysql_commit(_conn)) {
Expand Down
6 changes: 5 additions & 1 deletion broker/core/sql/src/mysql_multi_insert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ void bulk_or_multi::execute(mysql& connexion,
my_error::code ec,
int thread_id) {
if (_bulk_stmt) {
if (!_bulk_bind->empty()) {
/* If the database connection is lost, we can have this issue */
if (!_bulk_bind) {
_bulk_bind = _bulk_stmt->create_bind();
_bulk_bind->reserve(_bulk_row);
} else if (!_bulk_bind->empty()) {
_bulk_stmt->set_bind(std::move(_bulk_bind));
connexion.run_statement(*_bulk_stmt, ec, thread_id);
_bulk_bind = _bulk_stmt->create_bind();
Expand Down
2 changes: 1 addition & 1 deletion broker/unified_sql/src/stream_sql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ void stream::_process_pb_host_group_member(const std::shared_ptr<io::data>& d) {
}

std::string query = fmt::format(
"DELETE FROM hosts_hostgroup WHERE host_id={} and hostgroup_id = {}",
"DELETE FROM hosts_hostgroups WHERE host_id={} and hostgroup_id = {}",
hgm.host_id(), hgm.hostgroup_id());

_mysql.run_query(query, database::mysql_error::delete_host_group_member,
Expand Down
5 changes: 4 additions & 1 deletion common/src/perfdata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,21 @@ std::list<perfdata> perfdata::parse_perfdata(

/* The label is given by s and finishes at end */
if (*end == ']') {
--end;
if (strncmp(s, "a[", 2) == 0) {
s += 2;
--end;
p._value_type = perfdata::data_type::absolute;
} else if (strncmp(s, "c[", 2) == 0) {
s += 2;
--end;
p._value_type = perfdata::data_type::counter;
} else if (strncmp(s, "d[", 2) == 0) {
s += 2;
--end;
p._value_type = perfdata::data_type::derive;
} else if (strncmp(s, "g[", 2) == 0) {
s += 2;
--end;
p._value_type = perfdata::data_type::gauge;
}
}
Expand Down
15 changes: 15 additions & 0 deletions common/tests/perfdata_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,18 @@ TEST_F(PerfdataParser, BadMetric1) {
++i;
}
}

TEST_F(PerfdataParser, ExtractPerfdataBrackets) {
std::string perfdata(
"'xx[aa a aa]'=2;3;7;1;9 '[a aa]'=12;25;50;0;118 'aa a]'=28;13;54;0;80");
auto lst{common::perfdata::parse_perfdata(0, 0, perfdata.c_str(), _logger)};
auto it = lst.begin();
ASSERT_NE(it, lst.end());
ASSERT_EQ(it->name(), "xx[aa a aa]");
++it;
ASSERT_NE(it, lst.end());
ASSERT_EQ(it->name(), "[a aa]");
++it;
ASSERT_NE(it, lst.end());
ASSERT_EQ(it->name(), "aa a]");
}
21 changes: 11 additions & 10 deletions engine/modules/opentelemetry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ foreach(name IN LISTS service_files)
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
--proto_path=${CMAKE_SOURCE_DIR}/opentelemetry-proto
--proto_path=${CMAKE_SOURCE_DIR}/opentelemetry-proto
--grpc_out=${SRC_DIR} ${proto_file}
VERBATIM
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand All @@ -61,7 +61,7 @@ add_custom_command(
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# mod_externalcmd target.
add_library(opentelemetry SHARED
add_library(opentelemetry SHARED
${SRC_DIR}/centreon_agent/agent.grpc.pb.cc
${SRC_DIR}/centreon_agent/agent.pb.cc
${SRC_DIR}/centreon_agent/agent_check_result_builder.cc
Expand All @@ -86,25 +86,26 @@ ${SRC_DIR}/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc
target_precompile_headers(opentelemetry PRIVATE precomp_inc/precomp.hh)

# set(EXTERNALCMD_MODULE "${EXTERNALCMD_MODULE}" PARENT_SCOPE)
target_link_libraries(opentelemetry
target_link_libraries(opentelemetry
spdlog::spdlog
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options)

add_dependencies(opentelemetry
add_dependencies(opentelemetry
pb_open_telemetry_lib
pb_neb_lib
engine_rpc
pb_tag_lib)

target_include_directories(opentelemetry PRIVATE
"${MODULE_DIR}/inc/com/centreon/engine/modules/opentelemetry"
"${CMAKE_SOURCE_DIR}/bbdo"
target_include_directories(opentelemetry PRIVATE
"${MODULE_DIR}/inc/com/centreon/engine/modules/opentelemetry"
"${CMAKE_SOURCE_DIR}/bbdo"
"${MODULE_DIR}/inc"
${CMAKE_SOURCE_DIR}/common/inc
${CMAKE_SOURCE_DIR}/common/http/inc
${CMAKE_SOURCE_DIR}/common/grpc/inc
${CMAKE_SOURCE_DIR}/common/http/inc
${CMAKE_SOURCE_DIR}/common/grpc/inc
src
${PROJECT_SOURCE_DIR}/enginerpc
${PROJECT_SOURCE_DIR}/enginerpc
${CMAKE_SOURCE_DIR}/common/src
)

Expand Down
11 changes: 11 additions & 0 deletions engine/tests/string/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ TEST(string_utils, extractPerfdataGaugeDiff) {
"d[aa a]=28;13;54;0;80");
}

TEST(string_utils, extractPerfdataBrackets) {
std::string perfdata(
"'xx[aa a aa]'=2;3;7;1;9 '[a aa]'=12;25;50;0;118 'aa a]'=28;13;54;0;80");
ASSERT_EQ(string::extract_perfdata(perfdata, "xx[aa a aa]"),
"'xx[aa a aa]'=2;3;7;1;9");
ASSERT_EQ(string::extract_perfdata(perfdata, "[a aa]"),
"'[a aa]'=12;25;50;0;118");
ASSERT_EQ(string::extract_perfdata(perfdata, "aa a]"),
"'aa a]'=28;13;54;0;80");
}

TEST(string_utils, removeThresholdsWithoutThresholds) {
std::string perfdata("a=2V");
ASSERT_EQ(string::remove_thresholds(perfdata), "a=2V");
Expand Down
Loading
Loading