From 56c8faddce5ffbb0a449bf3055c3899ded853571 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Wed, 7 Feb 2024 12:18:57 +0100 Subject: [PATCH 1/3] fix(engine): semicolon is no more considered as a beginning of comment in engine configuration file. REFS: MON-35108 --- engine/precomp_inc/precomp.hh | 64 ++++++++++++++---------------- engine/src/configuration/object.cc | 38 +++++++++--------- engine/src/string.cc | 2 +- tests/engine/forced_checks.robot | 37 +++++++++++++++++ 4 files changed, 87 insertions(+), 54 deletions(-) diff --git a/engine/precomp_inc/precomp.hh b/engine/precomp_inc/precomp.hh index 844c52ad835..dd2249aa5fd 100644 --- a/engine/precomp_inc/precomp.hh +++ b/engine/precomp_inc/precomp.hh @@ -1,37 +1,46 @@ -/* -** Copyright 2022 Centreon -** -** This file is part of Centreon Engine. -** -** Centreon Engine is free software: you can redistribute it and/or -** modify it under the terms of the GNU General Public License version 2 -** as published by the Free Software Foundation. -** -** Centreon Engine is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Centreon Engine. If not, see -** . -*/ +/** + * Copyright 2022-2024 Centreon + * + * This file is part of Centreon Engine. + * + * Centreon Engine is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * Centreon Engine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Centreon Engine. If not, see + * . + */ #ifndef CCE_PRECOMP_HH #define CCE_PRECOMP_HH +#include +#include +#include +#include +#include #include #include #include +#include #include +#include +#include +#include +#include +#include #include +#include #include #include #include - -#include -#include #include #include #include @@ -57,19 +66,6 @@ #include #include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - #include "com/centreon/engine/namespace.hh" namespace fmt { diff --git a/engine/src/configuration/object.cc b/engine/src/configuration/object.cc index 76fd084e27f..d91448ab78f 100644 --- a/engine/src/configuration/object.cc +++ b/engine/src/configuration/object.cc @@ -1,21 +1,21 @@ -/* -** Copyright 2011-2014 Merethis -** -** This file is part of Centreon Engine. -** -** Centreon Engine is free software: you can redistribute it and/or -** modify it under the terms of the GNU General Public License version 2 -** as published by the Free Software Foundation. -** -** Centreon Engine is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Centreon Engine. If not, see -** . -*/ +/** + * Copyright 2011-2014,2024 Merethis + * + * This file is part of Centreon Engine. + * + * Centreon Engine is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * Centreon Engine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Centreon Engine. If not, see + * . + */ #include "com/centreon/engine/configuration/object.hh" #include "com/centreon/engine/configuration/anomalydetection.hh" @@ -204,7 +204,7 @@ bool object::parse(std::string const& line) { key.assign(line, 0, pos); value.assign(line, pos + 1, std::string::npos); } - string::trim(value); + boost::algorithm::trim(value); if (!parse(key.c_str(), value.c_str())) return object::parse(key.c_str(), value.c_str()); return true; diff --git a/engine/src/string.cc b/engine/src/string.cc index 77fa2765d1b..6ed5c8b10d2 100644 --- a/engine/src/string.cc +++ b/engine/src/string.cc @@ -41,7 +41,7 @@ bool string::get_next_line(std::ifstream& stream, unsigned int& pos) { while (std::getline(stream, line, '\n')) { ++pos; - string::trim(line); + boost::algorithm::trim(line); if (!line.empty()) { char c(line[0]); if (c != '#' && c != ';' && c != '\x0') diff --git a/tests/engine/forced_checks.robot b/tests/engine/forced_checks.robot index 2ba215a2f0a..253034fb543 100644 --- a/tests/engine/forced_checks.robot +++ b/tests/engine/forced_checks.robot @@ -284,3 +284,40 @@ EMACROS_NOTIF Stop Engine Kindly Stop Broker + + +EMACROS_SEMICOLON + [Documentation] Macros with a semicolon are used even if they contain a semicolon + [Tags] engine external_cmd macros + Config Engine ${1} + Config Broker central + Config Broker rrd + Config Broker module ${1} + Engine Config Set Value ${0} log_legacy_enabled ${0} + Engine Config Set Value ${0} log_v2_enabled ${1} + Engine Config Set Value 0 log_level_checks trace True + Engine Config Set Value In Hosts 0 host_1 _KEY2 VAL1;val3; + Engine Config Change Command + ... 0 + ... \\d+ + ... /bin/echo "KEY2=$_HOSTKEY2$" + Clear Retention + ${start} Get Current Date + Start Engine + Start Broker + + ${content} Create List INITIAL HOST STATE: host_1; + ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + Should Be True + ... ${result} + ... An Initial host state on host_1 should be raised before we can start our external commands. + Schedule Forced Svc Check host_1 service_1 + Sleep 5s + + ${content} Create List KEY2=VAL1;val3; + ${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60 + Should Be True ${result} VAL1;val3; not found in log. + + Stop Engine + Kindly Stop Broker + From 3c0d35bfa33b9a5082ab8f3f8ff63a79623c30df Mon Sep 17 00:00:00 2001 From: David Boucher Date: Wed, 7 Feb 2024 12:57:58 +0100 Subject: [PATCH 2/3] enh(conan): version upgraded --- .github/docker/Dockerfile.centreon-collect-alma8 | 2 +- .github/docker/Dockerfile.centreon-collect-alma9 | 2 +- .../Dockerfile.centreon-collect-debian-bullseye | 2 +- .github/workflows/veracode-analysis.yml | 2 +- cmake.sh | 12 +++++++++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/docker/Dockerfile.centreon-collect-alma8 b/.github/docker/Dockerfile.centreon-collect-alma8 index ce4120fe1ad..0d2f11180bb 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma8 +++ b/.github/docker/Dockerfile.centreon-collect-alma8 @@ -46,7 +46,7 @@ dnf install -y cmake \ dnf update libarchive -pip3 install conan==1.57.0 --prefix=/usr --upgrade +pip3 install conan==1.62.0 --prefix=/usr --upgrade rm -rf ~/.conan/profiles/default EOF diff --git a/.github/docker/Dockerfile.centreon-collect-alma9 b/.github/docker/Dockerfile.centreon-collect-alma9 index 129f998dc69..cdac5e7adb7 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma9 +++ b/.github/docker/Dockerfile.centreon-collect-alma9 @@ -43,7 +43,7 @@ dnf --best install -y cmake \ # TEMPORARY PYTHON UPGRADE TO 3.18 TO HELP WITH DATA_FILTER ISSUE dnf upgrade -y python3 -pip3 install conan==1.57.0 --prefix=/usr --upgrade +pip3 install conan==1.62.0 --prefix=/usr --upgrade rm -rf ~/.conan/profiles/default EOF diff --git a/.github/docker/Dockerfile.centreon-collect-debian-bullseye b/.github/docker/Dockerfile.centreon-collect-debian-bullseye index ddd6dbc4544..2e26996dd74 100644 --- a/.github/docker/Dockerfile.centreon-collect-debian-bullseye +++ b/.github/docker/Dockerfile.centreon-collect-debian-bullseye @@ -40,7 +40,7 @@ localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py -pip3 install conan==1.57.0 +pip3 install conan==1.62.0 ln -s /usr/local/bin/conan /usr/bin/conan rm -rf ~/.conan/profiles/default diff --git a/.github/workflows/veracode-analysis.yml b/.github/workflows/veracode-analysis.yml index 45aebe9fbae..18d81598138 100644 --- a/.github/workflows/veracode-analysis.yml +++ b/.github/workflows/veracode-analysis.yml @@ -66,7 +66,7 @@ jobs: mkdir build cd build - sudo pip3 install conan==1.57.0 --prefix=/usr --upgrade + sudo pip3 install conan==1.62.0 --prefix=/usr --upgrade sudo conan install .. -s compiler.cppstd=14 -s compiler.libcxx=libstdc++11 --build=missing sudo cmake \ diff --git a/cmake.sh b/cmake.sh index d5435dd519a..f21774d40fd 100755 --- a/cmake.sh +++ b/cmake.sh @@ -11,6 +11,7 @@ This program build Centreon-broker -fcr|--force-conan-rebuild : rebuild conan data -ng : C++17 standard -clang : Compilation with clang++ + -mold : Link with mold instead of ld -h|--help : help EOF } @@ -33,6 +34,7 @@ CXX=g++ LIBCXX=libstdc++11 WITH_CLANG=OFF EE= +MOLD= for i in "$@" do @@ -55,6 +57,10 @@ do CXX=clang++ shift ;; + -mold) + MOLD="-fuse-ld=mold" + shift + ;; -fcr|--force-conan-rebuild) echo "Forced conan rebuild" CONAN_REBUILD="1" @@ -311,9 +317,9 @@ echo "$conan install .. --build=missing" $conan install .. --build=missing if [[ "$maj" == "Raspbian" ]] ; then - CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF $* .. + CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF $* .. elif [[ "$maj" == "Debian" ]] ; then - CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_PREFIX_LIB_CLIB=/usr/lib64/ -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* .. + CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_PREFIX_LIB_CLIB=/usr/lib64/ -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* .. else - CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* .. + CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* .. fi From de9a0da8daf20a591d1331950ffc86b9315fb8d9 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Wed, 7 Feb 2024 13:27:06 +0100 Subject: [PATCH 3/3] fix(packaging): bad conan version fixed --- README.md | 2 +- packaging/rpm/centreon-collect.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79fbe803664..b02150ed8cb 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ apt install conan If it does not work, conan can be installed with pip3: ```shell -pip3 install conan==1.57.0 +pip3 install conan==1.62.0 ``` > All the dependencies pulled by conan are located in conanfile.txt. If diff --git a/packaging/rpm/centreon-collect.spec b/packaging/rpm/centreon-collect.spec index 93fed84fc70..b609ac22996 100644 --- a/packaging/rpm/centreon-collect.spec +++ b/packaging/rpm/centreon-collect.spec @@ -302,7 +302,7 @@ SELinux context for centreon-broker %setup -q -n %{name}-%{version} %build -pip3 install conan==1.57.0 --upgrade +pip3 install conan==1.62.0 --upgrade conan install . -s compiler.cppstd=14 -s compiler.libcxx=libstdc++11 --build=missing cmake3 \