Skip to content

Commit

Permalink
otl logger, use opentelemetry-proto instead opentelemetry-cpp
Browse files Browse the repository at this point in the history
add extractor, otel connector  and telegraf nagios converter
connect otel to engine conf
add server config
add http(s) telegraf conf server
  • Loading branch information
jean-christophe81 committed May 23, 2024
1 parent 392e8fc commit bfd004e
Show file tree
Hide file tree
Showing 125 changed files with 9,186 additions and 790 deletions.
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma9-test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dnf clean all
echo "install robot and dependencies"

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 robotframework-requests

cd /tmp/collect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ apt-get clean
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

pip3 install --break-system-packages -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install --break-system-packages grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3
pip3 install --break-system-packages grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 robotframework-requests

cd /tmp/collect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ apt-get clean
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 robotframework-requests

cd /tmp/collect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dnf clean all
echo "install robot and dependencies"

pip3 install -U robotframework robotframework-databaselibrary robotframework-httpctrl robotframework-examples pymysql python-dateutil psutil
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3
pip3 install grpcio grpcio_tools py-cpuinfo cython unqlite gitpython boto3 robotframework-requests

cd /tmp/collect

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ find_package(spdlog CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(Protobuf REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(opentelemetry-cpp REQUIRED)
#find_package(opentelemetry-cpp REQUIRED)
find_package(GTest CONFIG REQUIRED)
find_package(CURL REQUIRED)
find_package(Boost REQUIRED)
find_package(Boost REQUIRED COMPONENTS url)
find_package(ryml CONFIG REQUIRED)
add_definitions("-DSPDLOG_FMT_EXTERNAL")

Expand Down
6 changes: 4 additions & 2 deletions broker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ add_custom_target("target_broker_message" DEPENDS "${SRC_DIR}/broker.pb.cc"
"${SRC_DIR}/broker.pb.h")

include_directories(${SRC_DIR} ${CMAKE_SOURCE_DIR}/common/src
${CMAKE_SOURCE_DIR}/common/inc)
${CMAKE_SOURCE_DIR}/common/inc
${CMAKE_SOURCE_DIR}/bbdo)

add_library(berpc STATIC ${SRC_DIR}/broker.grpc.pb.cc ${SRC_DIR}/broker.pb.cc
${SRC_DIR}/broker.grpc.pb.h ${SRC_DIR}/broker.pb.h)
Expand Down Expand Up @@ -451,6 +452,7 @@ target_link_libraries(
bbdo_bbdo
pb_bbdo_lib
pb_extcmd_lib
pb_open_telemetry_lib
berpc
z
spdlog::spdlog
Expand Down Expand Up @@ -506,7 +508,7 @@ add_subdirectory(core/sql)
# Generator module.
add_broker_module(GENERATOR OFF)
add_broker_module(STATS ON)
add_broker_module(STATS_EXPORTER ON)
#add_broker_module(STATS_EXPORTER OFF)
add_broker_module(NEB ON)
add_broker_module(RRD ON)
add_broker_module(UNIFIED_SQL ON)
Expand Down
1 change: 1 addition & 0 deletions broker/bam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ target_link_libraries("${BAM}" bbdo_storage bbdo_bam pb_bam_lib
spdlog::spdlog)
target_precompile_headers(${BAM} PRIVATE precomp_inc/precomp.hpp)
set_target_properties("${BAM}" PROPERTIES PREFIX "")
add_dependencies("${BAM}" pb_open_telemetry_lib)

# Testing.
if(WITH_TESTING)
Expand Down
26 changes: 12 additions & 14 deletions broker/core/multiplexing/src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,20 +402,18 @@ bool engine::_send_to_subscribers(send_to_mux_callback_type&& callback) {
} else {
std::shared_ptr<muxer> mux_to_publish_in_asio = mux.lock();
if (mux_to_publish_in_asio) {
com::centreon::common::pool::io_context().post(
[kiew, mux_to_publish_in_asio, cb]() {
try {
mux_to_publish_in_asio->publish(*kiew);
} // pool threads protection
catch (const std::exception& ex) {
SPDLOG_LOGGER_ERROR(log_v2::core(),
"publish caught exception: {}",
ex.what());
} catch (...) {
SPDLOG_LOGGER_ERROR(log_v2::core(),
"publish caught unknown exception");
}
});
common::pool::io_context().post([kiew, mux_to_publish_in_asio, cb]() {
try {
mux_to_publish_in_asio->publish(*kiew);
} // pool threads protection
catch (const std::exception& ex) {
SPDLOG_LOGGER_ERROR(log_v2::core(),
"publish caught exception: {}", ex.what());
} catch (...) {
SPDLOG_LOGGER_ERROR(log_v2::core(),
"publish caught unknown exception");
}
});
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions broker/core/src/processing/feeder.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Copyright 2011-2012,2015,2017, 2020-2021 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/
* Copyright 2011-2012,2015,2017, 2020-2021 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/

#include "com/centreon/broker/processing/feeder.hh"

Expand Down
8 changes: 0 additions & 8 deletions broker/grpc/inc/com/centreon/broker/grpc/stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ std::ostream& operator<<(std::ostream&, const CentreonEvent&);
namespace grpc {

extern const std::string authorization_header;
constexpr uint32_t calc_accept_all_compression_mask() {
uint32_t ret = 0;
for (size_t algo_ind = 0; algo_ind < GRPC_COMPRESS_ALGORITHMS_COUNT;
algo_ind++) {
ret += (1u << algo_ind);
}
return ret;
}

struct detail_centreon_event;
std::ostream& operator<<(std::ostream&, const detail_centreon_event&);
Expand Down
3 changes: 2 additions & 1 deletion broker/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ add_dependencies(${LUA}
pb_neb_lib
pb_header_lib
pb_storage_lib
pb_bam_lib)
pb_bam_lib
pb_open_telemetry_lib)

target_link_libraries("${LUA}" ${LUA_LIBRARIES} crypto ssl bbdo_storage bbdo_bam spdlog::spdlog pb_storage_lib)
target_precompile_headers(${LUA} PRIVATE precomp_inc/precomp.hpp)
Expand Down
2 changes: 2 additions & 0 deletions broker/neb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ endif()
set_target_properties("${CBMOD}" PROPERTIES PREFIX "")
target_precompile_headers(${CBMOD} PRIVATE precomp_inc/precomp.hpp)

target_include_directories(${CBMOD} PRIVATE ${CMAKE_SOURCE_DIR}/bbdo)

# Testing.
if(WITH_TESTING)
set(TESTS_SOURCES
Expand Down
3 changes: 2 additions & 1 deletion broker/simu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ add_dependencies(${SIMU}
pb_neb_lib
pb_header_lib
pb_storage_lib
pb_bam_lib)
pb_bam_lib
pb_open_telemetry_lib)

target_link_libraries("${SIMU}" ${LUA_LIBRARIES} spdlog::spdlog)
target_precompile_headers(${SIMU} PRIVATE precomp_inc/precomp.hpp)
Expand Down
1 change: 1 addition & 0 deletions broker/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_library("${SQL}" SHARED
add_dependencies(${SQL}
pb_neb_lib
pb_header_lib
pb_open_telemetry_lib
)

set_target_properties("${SQL}" PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions broker/storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ add_dependencies(conflictmgr
pb_neb_lib
pb_header_lib
pb_storage_lib
pb_open_telemetry_lib
)

set_target_properties(conflictmgr PROPERTIES COMPILE_FLAGS "-fPIC")
Expand Down
2 changes: 1 addition & 1 deletion broker/tcp/src/stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ stream::stream(const tcp_config::pointer& conf)
_conf->get_port());
log_v2::tcp()->info(
"{} TCP streams are configured on a thread pool of {} threads",
static_cast<uint32_t>(_total_tcp_count),
static_cast<uint32_t>(_total_tcp_count),
com::centreon::common::pool::instance().get_pool_size());
}

Expand Down
2 changes: 1 addition & 1 deletion broker/test/test_util/src/tcp_relais.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void incomming_outgoing::on_recv(const boost::system::error_code& err,
}

asio::async_write(sender, asio::buffer(*buff, nb_recv),
[me = shared_from_this(), buff, &sender](
[me = shared_from_this(), buff, &sender](
const boost::system::error_code& err, size_t) {
me->on_sent(err, sender);
});
Expand Down
4 changes: 3 additions & 1 deletion broker/unified_sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ add_library(
set_target_properties("${UNIFIED_SQL}" PROPERTIES PREFIX "" COMPILE_FLAGS
"-fPIC")
add_dependencies("${UNIFIED_SQL}" target_rebuild_message
target_remove_graph_message target_neb)
target_remove_graph_message
target_neb
pb_open_telemetry_lib)
target_precompile_headers(${UNIFIED_SQL} PRIVATE precomp_inc/precomp.hpp)
target_link_libraries(
${UNIFIED_SQL}
Expand Down
9 changes: 8 additions & 1 deletion clib/inc/com/centreon/misc/get_options.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class get_options {
void _parse_arguments(std::string const& command_line);
virtual void _parse_arguments(std::vector<std::string> const& args);

void _add_argument(const std::string& long_name,
char name,
const std::string description = "",
bool has_value = false,
bool is_set = false,
const std::string& value = "");

std::map<char, argument> _arguments;
std::vector<std::string> _parameters;

Expand All @@ -75,6 +82,6 @@ class get_options {
};
} // namespace misc

}
} // namespace com::centreon

#endif // !CC_MISC_GET_OPTIONS_HH
51 changes: 35 additions & 16 deletions clib/src/misc/get_options.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Copyright 2011-2013 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/
* Copyright 2011-2013 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/

#include "com/centreon/misc/get_options.hh"
#include <algorithm>
Expand Down Expand Up @@ -346,3 +346,22 @@ bool get_options::_split_short(std::string const& line,
key = key.substr(0, 1);
return true;
}

/**
* @brief Get the options:: add argument object
*
* @param[in] long_name Argument's long name.
* @param[in] name Argument's name.
* @param[in] has_value Argument need a value.
* @param[in] is_set Argument is set by default.
* @param[in] value The default value.
*/
void get_options::_add_argument(const std::string& long_name,
char name,
const std::string description,
bool has_value,
bool is_set,
const std::string& value) {
_arguments.emplace(
name, argument(long_name, name, description, has_value, is_set, value));
}
37 changes: 25 additions & 12 deletions common/grpc/inc/com/centreon/common/grpc/grpc_config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,24 @@ class grpc_config {
* server case: address/port to listen
*
*/
const std::string _hostport;
const bool _crypted = false;
const std::string _certificate, _cert_key, _ca_cert;
const std::string _ca_name;
const bool _compress;
const int _second_keepalive_interval;
std::string _hostport;
bool _crypted = false;
std::string _certificate, _cert_key, _ca_cert;
std::string _ca_name;
bool _compress;
int _second_keepalive_interval;

public:
using pointer = std::shared_ptr<grpc_config>;

grpc_config() : _compress(false), _second_keepalive_interval(30) {}
grpc_config(const std::string& hostp)
: _hostport(hostp), _compress(false), _second_keepalive_interval(30) {}
grpc_config(const std::string& hostp, bool crypted)
: _hostport(hostp),
_crypted(crypted),
_compress(false),
_second_keepalive_interval(30) {}
grpc_config(const std::string& hostp,
bool crypted,
const std::string& certificate,
Expand All @@ -78,16 +83,24 @@ class grpc_config {
_compress(compression),
_second_keepalive_interval(second_keepalive_interval) {}

constexpr const std::string& get_hostport() const { return _hostport; }
constexpr bool is_crypted() const { return _crypted; }
constexpr const std::string& get_cert() const { return _certificate; }
constexpr const std::string& get_key() const { return _cert_key; }
constexpr const std::string& get_ca() const { return _ca_cert; }
const std::string& get_hostport() const { return _hostport; }
bool is_crypted() const { return _crypted; }
const std::string& get_cert() const { return _certificate; }
const std::string& get_key() const { return _cert_key; }
const std::string& get_ca() const { return _ca_cert; }
const std::string& get_ca_name() const { return _ca_name; }
constexpr bool is_compressed() const { return _compress; }
bool is_compressed() const { return _compress; }
int get_second_keepalive_interval() const {
return _second_keepalive_interval;
}

bool operator==(const grpc_config& right) const {
return _hostport == right._hostport && _crypted == right._crypted &&
_certificate == right._certificate && _cert_key == right._cert_key &&
_ca_cert == right._ca_cert && _ca_name == right._ca_name &&
_compress == right._compress &&
_second_keepalive_interval == right._second_keepalive_interval;
}
};
} // namespace com::centreon::common::grpc

Expand Down
2 changes: 2 additions & 0 deletions common/grpc/inc/com/centreon/common/grpc/grpc_server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class grpc_server_base {

virtual ~grpc_server_base();

void shutdown(const std::chrono::system_clock::duration& timeout);

grpc_server_base(const grpc_server_base&) = delete;
grpc_server_base& operator=(const grpc_server_base&) = delete;

Expand Down
Loading

0 comments on commit bfd004e

Please sign in to comment.