Skip to content

Commit

Permalink
Merge branch '24.10.x' into sync-release-154332
Browse files Browse the repository at this point in the history
  • Loading branch information
pkippes committed Dec 19, 2024
2 parents 7f2b2ec + 55f0162 commit 9e1e82e
Show file tree
Hide file tree
Showing 89 changed files with 2,097 additions and 1,359 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MAJOR=24.10
MINOR=2
MINOR=3
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ endif()
# Version.
set(COLLECT_MAJOR 24)
set(COLLECT_MINOR 10)
set(COLLECT_PATCH 2)
set(COLLECT_PATCH 3)
set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}")


Expand Down
2 changes: 1 addition & 1 deletion bbdo/bam.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ message BaStatus {
message BaEvent {
uint32 ba_id = 1;
double first_level = 2;
int64 end_time = 3;
uint64 end_time = 3;
bool in_downtime = 4;
uint64 start_time = 5;
State status = 6;
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/ba_status.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_BA_STATUS_HH
#define CCB_BAM_BA_STATUS_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/dimension_ba_bv_relation_event.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_DIMENSION_BA_BV_RELATION_EVENT_HH
#define CCB_BAM_DIMENSION_BA_BV_RELATION_EVENT_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/dimension_ba_event.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_DIMENSION_BA_EVENT_HH
#define CCB_BAM_DIMENSION_BA_EVENT_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/dimension_bv_event.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_DIMENSION_BV_EVENT_HH
#define CCB_BAM_DIMENSION_BV_EVENT_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/dimension_truncate_table_signal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_DIMENSION_TRUNCATE_TABLE_SIGNAL_HH
#define CCB_BAM_DIMENSION_TRUNCATE_TABLE_SIGNAL_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/kpi_status.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_KPI_STATUS_HH
#define CCB_BAM_KPI_STATUS_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"
#include "com/centreon/broker/timestamp.hh"
Expand Down
2 changes: 0 additions & 2 deletions bbdo/bam/rebuild.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#ifndef CCB_BAM_REBUILD_HH
#define CCB_BAM_REBUILD_HH

#include "bbdo/events.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/event_info.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"

Expand Down
4 changes: 3 additions & 1 deletion bbdo/events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ enum data_element {
de_pb_service_group = 51,
de_pb_service_group_member = 52,
de_pb_host_parent = 53,
de_pb_instance_configuration = 54
de_pb_instance_configuration = 54,
de_pb_adaptive_service_status = 55,
de_pb_adaptive_host_status = 56,
};
} // namespace neb
namespace storage {
Expand Down
26 changes: 26 additions & 0 deletions bbdo/neb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ message Service {
uint64 icon_id = 87;
}

/**
* @brief Message sent in BBDO 3.0.0 to update a service status partially
* changed. For example, it is convenient for downtime changed.
*/
/* io::neb, neb::de_pb_adaptive_service_status, 53 */
message AdaptiveServiceStatus {
uint64 host_id = 1;
uint64 service_id = 2;
ServiceType type = 3;
uint64 internal_id = 4;
optional int32 scheduled_downtime_depth = 5;
optional AckType acknowledgement_type = 6;
optional int32 notification_number = 7;
}

/**
* @brief Message sent in BBDO 3.0.0 instead of neb::service_status
*/
Expand Down Expand Up @@ -405,6 +420,17 @@ message HostStatus {
int32 scheduled_downtime_depth = 28;
}

/**
* @brief Message sent in BBDO 3.0.0 to update a host status partially
* changed. For example, it is convenient for downtime changed.
*/
/* io::neb, neb::de_pb_adaptive_host_status, 55 */
message AdaptiveHostStatus {
uint64 host_id = 1;
optional int32 scheduled_downtime_depth = 2;
optional AckType acknowledgement_type = 3;
optional int32 notification_number = 4;
}
/**
* @brief Message used to send adaptive host configuration. When only one
* or two configuration items change, this event is used.
Expand Down
5 changes: 3 additions & 2 deletions broker/bam/inc/com/centreon/broker/bam/bool_service.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "com/centreon/broker/bam/bool_value.hh"
#include "com/centreon/broker/bam/service_listener.hh"
#include "com/centreon/broker/io/stream.hh"
#include "com/centreon/broker/neb/internal.hh"

namespace com::centreon::broker::bam {
/**
Expand Down Expand Up @@ -56,6 +54,9 @@ class bool_service : public bool_value, public service_listener {
io::stream* visitor = nullptr) override;
void service_update(const std::shared_ptr<neb::pb_service_status>& status,
io::stream* visitor = nullptr) override;
void service_update(
const std::shared_ptr<neb::pb_adaptive_service_status>& status,
io::stream* visitor = nullptr) override;
void service_update(const std::shared_ptr<neb::service_status>& status,
io::stream* visitor = nullptr) override;
double value_hard() const override;
Expand Down
2 changes: 2 additions & 0 deletions broker/bam/inc/com/centreon/broker/bam/service_book.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class service_book {
io::stream* visitor = nullptr);
void update(const std::shared_ptr<neb::pb_service_status>& t,
io::stream* visitor = nullptr);
void update(const std::shared_ptr<neb::pb_adaptive_service_status>& t,
io::stream* visitor = nullptr);
void save_to_cache(persistent_cache& cache) const;
void apply_services_state(const ServicesBookState& state);
};
Expand Down
4 changes: 3 additions & 1 deletion broker/bam/inc/com/centreon/broker/bam/service_listener.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef CCB_BAM_SERVICE_LISTENER_HH
#define CCB_BAM_SERVICE_LISTENER_HH

#include "com/centreon/broker/io/stream.hh"
#include "com/centreon/broker/neb/internal.hh"

namespace com::centreon::broker {
Expand Down Expand Up @@ -51,6 +50,9 @@ class service_listener {
virtual void service_update(const service_state& s);
virtual void service_update(std::shared_ptr<neb::pb_service> const& status,
io::stream* visitor = nullptr);
virtual void service_update(
std::shared_ptr<neb::pb_adaptive_service_status> const& status,
io::stream* visitor = nullptr);
virtual void service_update(
std::shared_ptr<neb::pb_service_status> const& status,
io::stream* visitor = nullptr);
Expand Down
27 changes: 27 additions & 0 deletions broker/bam/src/bool_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,33 @@ void bool_service::service_update(
}
}

/**
* @brief Notify of a service status update (usually used for downtimes).
*
* @param status The adaptive status of the service.
* @param visitor The visitor to handle events.
*/
void bool_service::service_update(
const std::shared_ptr<neb::pb_adaptive_service_status>& status,
io::stream* visitor) {
auto& o = status->obj();
if (o.has_scheduled_downtime_depth()) {
SPDLOG_LOGGER_TRACE(_logger,
"bool_service: service ({},{}) updated with "
"neb::pb_adaptive_service_status downtime: {}",
o.host_id(), o.service_id(),
o.scheduled_downtime_depth());
if (o.host_id() == _host_id && o.service_id() == _service_id) {
bool new_in_downtime = o.scheduled_downtime_depth() > 0;
if (_in_downtime != new_in_downtime) {
_in_downtime = new_in_downtime;
_logger->trace("bool_service: updated with downtime: {}", _in_downtime);
notify_parents_of_change(visitor);
}
}
}
}

/**
* Get the hard value.
*
Expand Down
26 changes: 17 additions & 9 deletions broker/bam/src/connector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@
#include "com/centreon/broker/neb/acknowledgement.hh"
#include "com/centreon/broker/neb/downtime.hh"
#include "com/centreon/broker/neb/service.hh"
#include "com/centreon/broker/neb/service_status.hh"

using namespace com::centreon::broker;
using namespace com::centreon::broker::bam;

static constexpr multiplexing::muxer_filter _monitoring_stream_filter = {
neb::service_status::static_type(), neb::pb_service_status::static_type(),
neb::service::static_type(), neb::pb_service::static_type(),
neb::acknowledgement::static_type(), neb::pb_acknowledgement::static_type(),
neb::downtime::static_type(), neb::pb_downtime::static_type(),
bam::ba_status::static_type(), bam::pb_ba_status::static_type(),
bam::kpi_status::static_type(), bam::pb_kpi_status::static_type(),
inherited_downtime::static_type(), pb_inherited_downtime::static_type(),
extcmd::pb_ba_info::static_type(), pb_services_book_state::static_type()};
neb::service_status::static_type(),
neb::pb_service_status::static_type(),
neb::service::static_type(),
neb::pb_service::static_type(),
neb::acknowledgement::static_type(),
neb::pb_acknowledgement::static_type(),
neb::downtime::static_type(),
neb::pb_downtime::static_type(),
neb::pb_adaptive_service_status::static_type(),
bam::ba_status::static_type(),
bam::pb_ba_status::static_type(),
bam::kpi_status::static_type(),
bam::pb_kpi_status::static_type(),
inherited_downtime::static_type(),
pb_inherited_downtime::static_type(),
extcmd::pb_ba_info::static_type(),
pb_services_book_state::static_type()};

static constexpr multiplexing::muxer_filter _monitoring_forbidden_filter =
multiplexing::muxer_filter(_monitoring_stream_filter).reverse();
Expand Down
20 changes: 12 additions & 8 deletions broker/bam/src/monitoring_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,15 @@
#include "bbdo/bam/ba_status.hh"
#include "bbdo/bam/kpi_status.hh"
#include "bbdo/bam/rebuild.hh"
#include "bbdo/events.hh"
#include "com/centreon/broker/bam/configuration/reader_v2.hh"
#include "com/centreon/broker/bam/configuration/state.hh"
#include "com/centreon/broker/bam/event_cache_visitor.hh"
#include "com/centreon/broker/config/applier/state.hh"
#include "com/centreon/broker/exceptions/shutdown.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/misc/fifo_client.hh"
#include "com/centreon/broker/multiplexing/publisher.hh"
#include "com/centreon/broker/neb/acknowledgement.hh"
#include "com/centreon/broker/neb/downtime.hh"
#include "com/centreon/broker/neb/internal.hh"
#include "com/centreon/broker/neb/service.hh"
#include "com/centreon/broker/neb/service_status.hh"
#include "com/centreon/broker/timestamp.hh"
#include "com/centreon/common/pool.hh"
#include "com/centreon/exceptions/msg_fmt.hh"
#include "common/log_v2/log_v2.hh"

using namespace com::centreon::exceptions;
Expand Down Expand Up @@ -410,6 +402,18 @@ int monitoring_stream::write(const std::shared_ptr<io::data>& data) {
_applier.book_service().update(ss, &ev_cache);
ev_cache.commit_to(pblshr);
} break;
case neb::pb_adaptive_service_status::static_type(): {
auto ss = std::static_pointer_cast<neb::pb_adaptive_service_status>(data);
auto& o = ss->obj();
SPDLOG_LOGGER_TRACE(_logger,
"BAM: processing pb adaptive service status (host: "
"{}, service: {})",
o.host_id(), o.service_id());
multiplexing::publisher pblshr;
event_cache_visitor ev_cache;
_applier.book_service().update(ss, &ev_cache);
ev_cache.commit_to(pblshr);
} break;
case neb::pb_service::static_type(): {
auto s = std::static_pointer_cast<neb::pb_service>(data);
auto& o = s->obj();
Expand Down
4 changes: 2 additions & 2 deletions broker/bam/src/reporting_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ void reporting_stream::_process_pb_ba_event(
id_start ba_key = std::make_pair(be.ba_id(), be.start_time());
// event exists?
if (_ba_event_cache.find(ba_key) != _ba_event_cache.end()) {
if (be.end_time() <= 0)
if (static_cast<int64_t>(be.end_time()) <= 0)
_ba_event_update.bind_null_u64(0);
else
_ba_event_update.bind_value_as_u64(0, be.end_time());
Expand All @@ -1135,7 +1135,7 @@ void reporting_stream::_process_pb_ba_event(
_ba_full_event_insert.bind_value_as_i32(1, be.first_level());
_ba_full_event_insert.bind_value_as_u64(2, be.start_time());

if (be.end_time() <= 0)
if (static_cast<int64_t>(be.end_time()) <= 0)
_ba_full_event_insert.bind_null_i64(3);
else
_ba_full_event_insert.bind_value_as_i64(3, be.end_time());
Expand Down
19 changes: 19 additions & 0 deletions broker/bam/src/service_book.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,25 @@ void service_book::update(const std::shared_ptr<neb::service_status>& t,
l->service_update(t, visitor);
}

/**
* @brief Propagate events of type neb::service_status to the concerned services
* and then to the corresponding kpi.
*
* @param t The event to handle.
* @param visitor The stream to write into.
*/
void service_book::update(
const std::shared_ptr<neb::pb_adaptive_service_status>& t,
io::stream* visitor) {
auto obj = t->obj();
auto found = _book.find(std::make_pair(obj.host_id(), obj.service_id()));
if (found == _book.end())
return;

for (auto l : found->second.listeners)
l->service_update(t, visitor);
}

/**
* @brief Propagate events of type pb_service to the
* concerned services and then to the corresponding kpi.
Expand Down
10 changes: 10 additions & 0 deletions broker/bam/src/service_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ void service_listener::service_update(
const std::shared_ptr<neb::pb_service_status>& status [[maybe_unused]],
io::stream* visitor [[maybe_unused]]) {}

/**
* @brief Notify of a service status update (usually used for downtimes).
*
* @param [[maybe_unused]]
* @param [[maybe_unused]]
*/
void service_listener::service_update(
const std::shared_ptr<neb::pb_adaptive_service_status>& status
[[maybe_unused]],
io::stream* visitor [[maybe_unused]]) {}
/**
* Notify of a protobuf acknowledgement.
*
Expand Down
1 change: 0 additions & 1 deletion broker/core/inc/com/centreon/broker/config/parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <absl/types/optional.h>

#include <nlohmann/json.hpp>

#include "com/centreon/broker/config/state.hh"
#include "com/centreon/exceptions/msg_fmt.hh"
Expand Down
1 change: 0 additions & 1 deletion broker/core/inc/com/centreon/broker/config/state.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef CCB_CONFIG_STATE_HH
#define CCB_CONFIG_STATE_HH

#include <fmt/format.h>

#include "bbdo/bbdo/bbdo_version.hh"
#include "com/centreon/broker/config/endpoint.hh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef CCB_MYSQL_CONNECTION_HH
#define CCB_MYSQL_CONNECTION_HH

#include "com/centreon/broker/config/applier/state.hh"
#include "com/centreon/broker/sql/database_config.hh"
#include "com/centreon/broker/sql/mysql_bulk_stmt.hh"
#include "com/centreon/broker/sql/mysql_error.hh"
Expand Down
Loading

0 comments on commit 9e1e82e

Please sign in to comment.