Skip to content

Commit

Permalink
enh(engine): new extractor and telegraf nagios converter
Browse files Browse the repository at this point in the history
REFS: MON-35539
  • Loading branch information
jean-christophe81 authored Jun 6, 2024
1 parent 6717e1a commit 5635b92
Show file tree
Hide file tree
Showing 62 changed files with 3,410 additions and 236 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
2 changes: 1 addition & 1 deletion broker/http_tsdb/test/stream_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class connection_send_bagot : public http::connection_base {
}
}

void on_accept(http::connect_callback_type&& callback) override{};
void _on_accept(http::connect_callback_type&& callback) override{};

void answer(const http::response_ptr& response,
http::answer_callback_type&& callback) override {}
Expand Down
1 change: 1 addition & 0 deletions broker/neb/precomp_inc/precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <thread>
#include <unordered_map>

#include <absl/container/btree_map.h>
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>

Expand Down
35 changes: 18 additions & 17 deletions broker/sql/precomp_inc/precomp.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
** Copyright 2022 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 : contact@centreon.com
*/
/**
* Copyright 2022-2024 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 : contact@centreon.com
*/

#ifndef CC_SQL_PRECOMP_HH
#define CC_SQL_PRECOMP_HH
Expand All @@ -30,6 +30,7 @@
#include <unordered_map>
#include <vector>

#include <absl/container/btree_map.h>
#include <absl/container/btree_set.h>
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
Expand Down
35 changes: 18 additions & 17 deletions broker/storage/precomp_inc/precomp.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
** Copyright 2022 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 : contact@centreon.com
*/
/**
* Copyright 2022-2024 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 : contact@centreon.com
*/

#ifndef CC_STATS_PRECOMP_HH
#define CC_STATS_PRECOMP_HH
Expand All @@ -27,6 +27,7 @@
#include <thread>
#include <unordered_map>

#include <absl/container/btree_map.h>
#include <absl/container/btree_set.h>
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
Expand Down
1 change: 1 addition & 0 deletions broker/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ target_link_libraries(
${TESTS_LIBRARIES}
conflictmgr
centreon_common
centreon_grpc
stdc++fs
nlohmann_json::nlohmann_json
fmt::fmt
Expand Down
35 changes: 18 additions & 17 deletions broker/unified_sql/precomp_inc/precomp.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
** Copyright 2022 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 : contact@centreon.com
*/
/**
* Copyright 2022-2024 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 : contact@centreon.com
*/

#ifndef CC_UNIFIED_SQL_PRECOMP_HH
#define CC_UNIFIED_SQL_PRECOMP_HH
Expand All @@ -30,6 +30,7 @@
#include <unordered_map>
#include <vector>

#include <absl/container/btree_map.h>
#include <absl/container/btree_set.h>
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
Expand Down
3 changes: 2 additions & 1 deletion common/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ set_target_properties(centreon_http PROPERTIES COMPILE_FLAGS "-fPIC")
if(WITH_TESTING)
set(TESTS_SOURCES
${TESTS_SOURCES}
${TEST_DIR}/http_connection_test.cc
${TEST_DIR}/http_client_test.cc
${TEST_DIR}/http_connection_test.cc
${TEST_DIR}/http_server_test.cc
PARENT_SCOPE)
endif(WITH_TESTING)
9 changes: 5 additions & 4 deletions common/http/doc/common-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class session_test : public connection_class {

void wait_for_request();

void answer(const std::shared_ptr<request_type>& request);
void answer_to_request(const std::shared_ptr<request_type>& request);

public:
session_test(const std::shared_ptr<asio::io_context>& io_context,
Expand All @@ -142,7 +142,8 @@ class session_test : public connection_class {
*/
template <class connection_class>
void session_test<connection_class>::on_accept() {
connection_class::on_accept(
// lambda will be called once handshake is done
connection_class::_on_accept(
[me = shared_from_this()](const boost::beast::error_code& err,
const std::string&) {
if (!err)
Expand All @@ -167,7 +168,7 @@ void session_test<connection_class>::wait_for_request() {
err.what());
return;
}
me->answer(request);
me->answer_to_request(request);
});
}

Expand All @@ -180,7 +181,7 @@ void session_test<connection_class>::wait_for_request() {
* @param request
*/
template <class connection_class>
void session_test<connection_class>::answer(
void session_test<connection_class>::answer_to_request(
const std::shared_ptr<request_type>& request) {
response_ptr resp(std::make_shared<response_type>());
resp->version(request->version());
Expand Down
13 changes: 8 additions & 5 deletions common/http/inc/com/centreon/common/http/http_connection.hh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class connection_base : public std::enable_shared_from_this<connection_base> {

http_config::pointer _conf;

virtual void _on_accept(connect_callback_type&& callback) = 0;

public:
enum e_state {
e_not_connected,
Expand Down Expand Up @@ -176,14 +178,12 @@ class connection_base : public std::enable_shared_from_this<connection_base> {
// server version
/**
* @brief to override in accepted session objects
* It has to call on_accept(connect_callback_type&& callback) in order to
* It has to call _on_accept(connect_callback_type&& callback) in order to
* receive
*
*/
virtual void on_accept() {}

virtual void on_accept(connect_callback_type&& callback) = 0;

virtual void answer(const response_ptr& response,
answer_callback_type&& callback) = 0;
virtual void receive_request(request_callback_type&& callback) = 0;
Expand All @@ -198,6 +198,9 @@ class connection_base : public std::enable_shared_from_this<connection_base> {

asio::ip::tcp::endpoint& get_peer() { return _peer; }
const asio::ip::tcp::endpoint& get_peer() const { return _peer; }

virtual void add_keep_alive_to_server_response(
const response_ptr& response) const;
};

/**
Expand Down Expand Up @@ -247,6 +250,8 @@ class http_connection : public connection_base {
send_callback_type& callback,
const response_ptr& resp);

void _on_accept(connect_callback_type&& callback) override;

public:
std::shared_ptr<http_connection> shared_from_this() {
return std::static_pointer_cast<http_connection>(
Expand All @@ -266,8 +271,6 @@ class http_connection : public connection_base {

void send(request_ptr request, send_callback_type&& callback) override;

void on_accept(connect_callback_type&& callback) override;

void answer(const response_ptr& response,
answer_callback_type&& callback) override;
void receive_request(request_callback_type&& callback) override;
Expand Down
7 changes: 5 additions & 2 deletions common/http/inc/com/centreon/common/http/https_connection.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class https_connection : public connection_base {
send_callback_type& callback,
const response_ptr& resp);

void _on_accept(connect_callback_type&& callback) override;

public:
std::shared_ptr<https_connection> shared_from_this() {
return std::static_pointer_cast<https_connection>(
Expand All @@ -82,8 +84,6 @@ class https_connection : public connection_base {

void send(request_ptr request, send_callback_type&& callback) override;

void on_accept(connect_callback_type&& callback) override;

void answer(const response_ptr& response,
answer_callback_type&& callback) override;
void receive_request(request_callback_type&& callback) override;
Expand All @@ -92,6 +92,9 @@ class https_connection : public connection_base {

static void load_client_certificate(asio::ssl::context& ctx,
const http_config::pointer& conf);

static void load_server_certificate(asio::ssl::context& ctx,
const http_config::pointer& conf);
};

} // namespace com::centreon::common::http
Expand Down
2 changes: 1 addition & 1 deletion common/http/src/http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,4 @@ void client::_retry(const boost::beast::error_code& error,
});
}
}
}
}
Loading

0 comments on commit 5635b92

Please sign in to comment.