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

MON-111637 Centreon next 23.10 (Jira release #19888#) #1410

Merged
merged 14 commits into from
Jun 17, 2024
Merged
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: 4 additions & 0 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ runs:
case "${{ inputs.major_version }}" in
"22.10"|"23.04"|"23.10")
SRC_PATHS=$(jf rt search --include-dirs $ROOT_REPO_PATH-testing/pool/${{ inputs.module_name }}/*.deb | jq -r '.[].path')
;;
*)
SRC_PATHS=$(jf rt search --include-dirs $ROOT_REPO_PATH-testing/pool/${{ inputs.module_name }}/*${{ inputs.distrib }}*.deb | jq -r '.[].path')
;;
esac

if [[ ${SRC_PATHS[@]} ]]; then
Expand All @@ -152,8 +154,10 @@ runs:
case "${{ inputs.major_version }}" in
"22.10"|"23.04"|"23.10")
ARTIFACT_SEARCH_PATTERN=".+\.deb"
;;
*)
ARTIFACT_SEARCH_PATTERN=".+${{ inputs.distrib }}.+\.deb"
;;
esac

for ARTIFACT_DL in $(dir -1|grep -E $ARTIFACT_SEARCH_PATTERN); do
Expand Down
13 changes: 8 additions & 5 deletions .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ runs:
declare -a PREVIOUS_STABLE_TAGS=()
SCOPE_VERSION="COLLECT"
MINOR_VERSION_FILE_PATH=".version"
RELEASE_CLOUD=0
RELEASE_CLOUD=0 # (0 = not a release cloud, 1 = release cloud)
MAJOR_VERSION=""
MINOR_VERSION=""
CURRENT_STABLE_BRANCH_MAJOR_VERSION=""

# Get current stable branch name
# If MASTER, use root .version
Expand Down Expand Up @@ -138,9 +141,9 @@ runs:
fi

# Rebuild NEW_STABLE_TAGS as an array
for i in ${NEW_STABLE_TAGS[@]}; do
NEW_RELEASE_TAGS+=("$i")
done
# for i in ${NEW_STABLE_TAGS[@]}; do
# NEW_RELEASE_TAGS+=("$i")
# done

# Create GITHUB release for each release components
# Abort if no tags
Expand Down Expand Up @@ -200,7 +203,7 @@ runs:
# Send to JIRA API release
echo "Sending to JIRA API release: $JIRA_RELEASE_DATA"
curl --fail --request POST \
--url 'https://${{ inputs.jira_base_url }}/rest/api/3/version' \
--url "${{ inputs.jira_base_url }}/rest/api/3/version" \
--user '${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/veracode-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on:
jobs:
routing:
name: Check before analysis
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
development_stage: ${{ steps.routing-mode.outputs.development_stage }}

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
password: ${{ secrets.docker_registry_passwd }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Compiling Cpp sources
run: |
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
name: Sandbox scan
needs: [routing, build]
if: needs.routing.outputs.development_stage != 'Development'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Promote latest scan
Expand All @@ -162,13 +162,13 @@ jobs:
delete-on-promote: false

- name: Get build binary
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary.tar.gz"
key: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary"

- name: Sandbox scan
uses: veracode/[email protected]
uses: veracode/veracode-uploadandscan-action@f7e1fbf02c5c899fba9f12e3f537b62f2f1230e1 # master using 0.2.6
continue-on-error: ${{ vars.VERACODE_CONTINUE_ON_ERROR == 'true' }}
with:
appname: "${{ inputs.module_name }}"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ tests/src/config/centreon-engine/config*/*
test/python/*.crt
test/python/*.key
tests/logs/*
**/*_pb2.py
**/*_pb2_grpc.py
tests/resources/grpc_stream.proto
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MAJOR=23.10
MINOR=7
MINOR=8
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ endif()
# Version.
set(COLLECT_MAJOR 23)
set(COLLECT_MINOR 10)
set(COLLECT_PATCH 7)
set(COLLECT_PATCH 8)
set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}")
add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${COLLECT_VERSION}\")

Expand Down
34 changes: 17 additions & 17 deletions bbdo/neb.proto
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 : [email protected]
*/
/**
* 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 : [email protected]
*/

syntax = "proto3";

Expand Down
4 changes: 3 additions & 1 deletion broker/core/inc/com/centreon/broker/file/stream.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright 2011-2015,2017, 2020-2021 Centreon
** Copyright 2011-2015,2017, 2020-2024 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
#include "com/centreon/broker/file/splitter.hh"
#include "com/centreon/broker/io/stream.hh"
#include "com/centreon/broker/namespace.hh"
#include "com/centreon/broker/stats/center.hh"

CCB_BEGIN()

Expand All @@ -44,6 +45,7 @@ class stream : public io::stream {
std::array<std::pair<int64_t, double>, 10> _stats_perc;
size_t _stats_idx;
size_t _stats_size;
std::shared_ptr<com::centreon::broker::stats::center> _center;

void _update_stats();

Expand Down
118 changes: 57 additions & 61 deletions broker/core/inc/com/centreon/broker/stats/center.hh
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/*
** Copyright 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 2020-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 : [email protected]
*/

#ifndef CCB_STATS_CENTER_HH
#define CCB_STATS_CENTER_HH

#include <absl/synchronization/mutex.h>
#include "broker.pb.h"
#include "com/centreon/broker/namespace.hh"

Expand Down Expand Up @@ -50,48 +51,57 @@ namespace stats {
* value value.
*/
class center {
static center* _instance;
BrokerStats _stats;
mutable std::mutex _stats_m;
static std::shared_ptr<center> _instance;
BrokerStats _stats ABSL_GUARDED_BY(_stats_m);
mutable absl::Mutex _stats_m;
int _json_stats_file_creation;

public:
center();
~center();

public:
static center& instance();
static std::shared_ptr<center> instance_ptr();
static void load();
static void unload();
std::string to_string();
std::string to_string() ABSL_LOCKS_EXCLUDED(_stats_m);

EngineStats* register_engine();
ConflictManagerStats* register_conflict_manager();
void unregister_muxer(const std::string& name);
EngineStats* register_engine() ABSL_LOCKS_EXCLUDED(_stats_m);
ConflictManagerStats* register_conflict_manager()
ABSL_LOCKS_EXCLUDED(_stats_m);
void unregister_muxer(const std::string& name) ABSL_LOCKS_EXCLUDED(_stats_m);
void update_muxer(std::string name,
std::string queue_file,
uint32_t size,
uint32_t unack);
uint32_t unack) ABSL_LOCKS_EXCLUDED(_stats_m);
void init_queue_file(std::string muxer,
std::string queue_file,
uint32_t max_file_size);
uint32_t max_file_size) ABSL_LOCKS_EXCLUDED(_stats_m);

bool muxer_stats(const std::string& name, MuxerStats* response);
MuxerStats* muxer_stats(const std::string& name);
void clear_muxer_queue_file(const std::string& name);
bool muxer_stats(const std::string& name, MuxerStats* response)
ABSL_LOCKS_EXCLUDED(_stats_m);
MuxerStats* muxer_stats(const std::string& name)
ABSL_LOCKS_EXCLUDED(_stats_m);
void clear_muxer_queue_file(const std::string& name)
ABSL_LOCKS_EXCLUDED(_stats_m);

bool get_sql_connection_stats(uint32_t index, SqlConnectionStats* response);
bool get_sql_connection_stats(uint32_t index, SqlConnectionStats* response)
ABSL_LOCKS_EXCLUDED(_stats_m);
void get_conflict_manager_stats(ConflictManagerStats* response);
void get_sql_manager_stats(SqlManagerStats* response, int32_t id = -1);
void get_sql_manager_stats(SqlManagerStats* response, int32_t id = -1)
ABSL_LOCKS_EXCLUDED(_stats_m);
SqlConnectionStats* connection(size_t idx);
SqlConnectionStats* add_connection();
void remove_connection(SqlConnectionStats* stats);
SqlConnectionStats* add_connection() ABSL_LOCKS_EXCLUDED(_stats_m);
void remove_connection(SqlConnectionStats* stats)
ABSL_LOCKS_EXCLUDED(_stats_m);

int get_json_stats_file_creation(void);
void get_sql_connection_size(GenericSize* response);
void get_processing_stats(ProcessingStats* response);
void get_sql_connection_size(GenericSize* response)
ABSL_LOCKS_EXCLUDED(_stats_m);
void get_processing_stats(ProcessingStats* response)
ABSL_LOCKS_EXCLUDED(_stats_m);
const BrokerStats& stats() const;
void lock();
void unlock();
void lock() ABSL_EXCLUSIVE_LOCK_FUNCTION(_stats);
void unlock() ABSL_UNLOCK_FUNCTION(_stats);

/**
* @brief Set the value pointed by ptr to the value value.
Expand All @@ -101,25 +111,11 @@ class center {
* @param value The value of type T to set.
*/
template <typename T>
void update(T* ptr, T value) {
std::lock_guard<std::mutex> lck(_stats_m);
void update(T* ptr, T value) ABSL_LOCKS_EXCLUDED(_stats_m) {
absl::MutexLock lck(&_stats_m);
*ptr = std::move(value);
}

/**
* @brief Almost the same function as in the previous case, but with a
* Timestamp object. And we can directly set a time_t value.
*
* @param ptr A pointer to object of type Timestamp.
* @param value The value of type time_t to set.
*/
// void update(google::protobuf::Timestamp* ptr, time_t value) {
// _strand.post([ptr, value] {
// ptr->Clear();
// ptr->set_seconds(value);
// });
//}

/**
* @brief Sometimes with protobuf, we can not access to a mutable pointer.
* For example with int32 values. We have instead a setter member function.
Expand All @@ -132,19 +128,19 @@ class center {
* @param value The value to set.
*/
template <typename U, typename T>
void update(void (U::*f)(T), U* ptr, T value) {
std::lock_guard<std::mutex> lck(_stats_m);
void update(void (U::*f)(T), U* ptr, T value) ABSL_LOCKS_EXCLUDED(_stats_m) {
absl::MutexLock lck(&_stats_m);
(ptr->*f)(value);
}

void execute(std::function<void()>&& f) {
std::lock_guard<std::mutex> lck(_stats_m);
void execute(std::function<void()>&& f) ABSL_LOCKS_EXCLUDED(_stats_m) {
absl::MutexLock lck(&_stats_m);
f();
}

template <typename U, typename T>
const T& get(T (U::*f)() const, const U* ptr) {
std::lock_guard<std::mutex> lck(_stats_m);
const T& get(T (U::*f)() const, const U* ptr) ABSL_LOCKS_EXCLUDED(_stats_m) {
absl::MutexLock lck(&_stats_m);
return (ptr->*f)();
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2012,2015,2019-2021 Centreon
* Copyright 2009-2012,2015,2019-2024 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -85,6 +85,7 @@ class engine {
std::vector<std::weak_ptr<muxer>> _muxers;

// Statistics.
std::shared_ptr<stats::center> _center;
EngineStats* _stats;
uint32_t _unprocessed_events;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright 2009-2017-2021 Centreon
** Copyright 2009-2017-2024 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,6 +72,7 @@ class muxer : public io::stream {
std::list<std::shared_ptr<io::data>> _events;
size_t _events_size;
std::list<std::shared_ptr<io::data>>::iterator _pos;
std::shared_ptr<stats::center> _center;
std::time_t _last_stats;

static std::mutex _running_muxers_m;
Expand Down
Loading
Loading