From 08f10333b8424ec96dab71de11879378dd1f460b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Chapron?= <34628915+sc979@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:44:26 +0200 Subject: [PATCH 01/12] chore(ci): upgrade action to fix dependabot alert (#1417) --- .github/workflows/veracode-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/veracode-analysis.yml b/.github/workflows/veracode-analysis.yml index f1adeafa157..d96fdf4672c 100644 --- a/.github/workflows/veracode-analysis.yml +++ b/.github/workflows/veracode-analysis.yml @@ -168,7 +168,7 @@ jobs: key: "${{ inputs.module_name }}-${{ github.sha }}-${{ github.run_id }}-veracode-binary" - name: Sandbox scan - uses: veracode/veracode-uploadandscan-action@f7e1fbf02c5c899fba9f12e3f537b62f2f1230e1 # master using 0.2.6 + uses: veracode/veracode-uploadandscan-action@f7e1fbf02c5c899fba9f12e3f537b62f2f1230e1 # 0.2.7 continue-on-error: ${{ vars.VERACODE_CONTINUE_ON_ERROR == 'true' }} with: appname: "${{ inputs.module_name }}" From 3cb6ba757e8ff7d3c3c79ab8934cfaacb74330f2 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:18:25 +0200 Subject: [PATCH 02/12] fix(release): add release_id to data sent to JIRA release (#1450) (#1456) --- .github/actions/release/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 1fcb0b03a98..16454153e66 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -185,6 +185,7 @@ runs: JIRA_RELEASE_NAME="" JIRA_PROJECT_ID="${{ inputs.jira_project_id }}" JIRA_RELEASE_RELEASED="false" + JIRA_RELEASE_ID="$(git log |grep -E "^\s+Centreon.*#[0-9]{5,}#)" |grep -Eo "([0-9]{5,})" |head -n 1)" # Create JIRA version for each released component echo "Creating JIRA releases." @@ -194,7 +195,7 @@ runs: # Build JSON with release information for JIRA API JIRA_RELEASE_DATA=$(jq -nc \ --arg archived "$JIRA_RELEASE_ARCHIVED" \ - --arg description "$TAG" \ + --arg description "$JIRA_RELEASE_ID $TAG" \ --arg releaseDate "$JIRA_RELEASE_DATE" \ --arg name "$TAG" \ --arg projectId "$JIRA_PROJECT_ID" \ From d412dc85c9f557934f0f3a02e9cc168998075e62 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:24:49 +0200 Subject: [PATCH 03/12] fix(release): fix checkout depth in release action (#1461) --- .github/actions/release/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 16454153e66..74746c3b447 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -25,6 +25,8 @@ runs: steps: - name: Checkout sources uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Get released versions for components run: | From dc90889ac798eb2d653f34d2e95d3a035b2a4f30 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Fri, 21 Jun 2024 18:28:35 +0200 Subject: [PATCH 04/12] enh(broker): big metrics do not fail anymore when inserted in database * enh(tests): big metrics do not fail anymore when inserted in database * fix(broker): new script to compute database columns max sizes * fix(broker/bam): the good size of float is inserted into the database for bam * fix(broker): perfdata class contains float numbers now. * enh(tests): big metrics do not fail anymore when inserted in database REFS: MON-116619 --- bbdo/bam/dimension_ba_event.cc | 50 +- bbdo/bam/dimension_bv_event.cc | 50 +- bbdo/bam/dimension_kpi_event.cc | 88 ++-- bbdo/bam/dimension_timeperiod.cc | 81 ++-- bbdo/bam/kpi_event.cc | 52 +- bbdo/storage/metric.cc | 37 +- broker/bam/src/availability_thread.cc | 5 +- broker/bam/src/monitoring_stream.cc | 28 +- broker/bam/src/reporting_stream.cc | 363 +++++++------- .../inc/com/centreon/broker/misc/perfdata.hh | 46 +- broker/core/sql/src/table_max_size.py | 121 +++-- broker/core/src/misc/parse_perfdata.cc | 44 +- broker/core/src/misc/perfdata.cc | 81 ++-- broker/core/test/misc/perfdata.cc | 56 +-- broker/grpc/test/acceptor.cc | 2 + broker/lua/test/lua.cc | 6 +- broker/neb/src/acknowledgement.cc | 45 +- broker/neb/src/comment.cc | 44 +- broker/neb/src/custom_variable.cc | 43 +- broker/neb/src/custom_variable_status.cc | 40 +- broker/neb/src/downtime.cc | 40 +- broker/neb/src/host.cc | 119 +++-- broker/neb/src/host_check.cc | 37 +- broker/neb/src/host_dependency.cc | 61 +-- broker/neb/src/host_group.cc | 37 +- broker/neb/src/host_status.cc | 57 ++- broker/neb/src/instance.cc | 43 +- broker/neb/src/instance_status.cc | 40 +- broker/neb/src/log_entry.cc | 60 +-- broker/neb/src/service.cc | 73 +-- broker/neb/src/service_check.cc | 37 +- broker/neb/src/service_dependency.cc | 51 +- broker/neb/src/service_group.cc | 37 +- broker/neb/src/service_status.cc | 49 +- broker/neb/test/service.cc | 3 +- .../broker/storage/conflict_manager.hh | 16 +- .../inc/com/centreon/broker/storage/stream.hh | 16 +- broker/storage/src/conflict_manager_sql.cc | 54 ++- .../storage/src/conflict_manager_storage.cc | 23 +- broker/storage/test/perfdata.cc | 28 +- .../com/centreon/broker/unified_sql/stream.hh | 14 +- broker/unified_sql/src/stream_sql.cc | 444 ++++++++++++------ broker/unified_sql/src/stream_storage.cc | 35 +- broker/unified_sql/test/perfdata.cc | 28 +- tests/broker-engine/big-metrics.robot | 50 ++ tests/resources/Engine.py | 27 ++ 46 files changed, 1581 insertions(+), 1180 deletions(-) create mode 100644 tests/broker-engine/big-metrics.robot diff --git a/bbdo/bam/dimension_ba_event.cc b/bbdo/bam/dimension_ba_event.cc index f6518c5d59f..736444d1cd2 100644 --- a/bbdo/bam/dimension_ba_event.cc +++ b/bbdo/bam/dimension_ba_event.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2014-2015 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 2014-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 + */ #include "bbdo/bam/dimension_ba_event.hh" @@ -102,14 +102,14 @@ mapping::entry const dimension_ba_event::entries[] = { mapping::entry(&bam::dimension_ba_event::ba_id, "ba_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_ba_event::ba_name, - "ba_name", - get_mod_bam_reporting_ba_col_size(mod_bam_reporting_ba_ba_name)), - mapping::entry( - &bam::dimension_ba_event::ba_description, - "ba_description", - get_mod_bam_reporting_ba_col_size(mod_bam_reporting_ba_ba_description)), + mapping::entry(&bam::dimension_ba_event::ba_name, + "ba_name", + get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_name)), + mapping::entry(&bam::dimension_ba_event::ba_description, + "ba_description", + get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_description)), mapping::entry(&bam::dimension_ba_event::sla_month_percent_crit, "sla_month_percent_crit"), mapping::entry(&bam::dimension_ba_event::sla_month_percent_warn, diff --git a/bbdo/bam/dimension_bv_event.cc b/bbdo/bam/dimension_bv_event.cc index d13e2d810e2..2db77006422 100644 --- a/bbdo/bam/dimension_bv_event.cc +++ b/bbdo/bam/dimension_bv_event.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2014-2015 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 2014-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 + */ #include "bbdo/bam/dimension_bv_event.hh" @@ -94,14 +94,14 @@ mapping::entry const dimension_bv_event::entries[] = { mapping::entry(&bam::dimension_bv_event::bv_id, "bv_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_bv_event::bv_name, - "bv_name", - get_mod_bam_reporting_bv_col_size(mod_bam_reporting_bv_bv_name)), - mapping::entry( - &bam::dimension_bv_event::bv_description, - "bv_description", - get_mod_bam_reporting_bv_col_size(mod_bam_reporting_bv_bv_description)), + mapping::entry(&bam::dimension_bv_event::bv_name, + "bv_name", + get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_name)), + mapping::entry(&bam::dimension_bv_event::bv_description, + "bv_description", + get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_description)), mapping::entry()}; // Operations. diff --git a/bbdo/bam/dimension_kpi_event.cc b/bbdo/bam/dimension_kpi_event.cc index 7a48fa6189f..6d9c469dd67 100644 --- a/bbdo/bam/dimension_kpi_event.cc +++ b/bbdo/bam/dimension_kpi_event.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2014-2015,2019-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 : contact@centreon.com -*/ +/** + * Copyright 2014-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. + * 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 + */ #include "bbdo/bam/dimension_kpi_event.hh" @@ -94,47 +94,49 @@ mapping::entry const dimension_kpi_event::entries[] = { mapping::entry(&bam::dimension_kpi_event::ba_id, "ba_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_kpi_event::ba_name, - "ba_name", - get_mod_bam_reporting_kpi_col_size(mod_bam_reporting_kpi_ba_name)), + mapping::entry(&bam::dimension_kpi_event::ba_name, + "ba_name", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_ba_name)), mapping::entry(&bam::dimension_kpi_event::host_id, "host_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_kpi_event::host_name, - "host_name", - get_mod_bam_reporting_kpi_col_size(mod_bam_reporting_kpi_host_name)), + mapping::entry(&bam::dimension_kpi_event::host_name, + "host_name", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_host_name)), mapping::entry(&bam::dimension_kpi_event::service_id, "service_id", mapping::entry::invalid_on_zero), - mapping::entry(&bam::dimension_kpi_event::service_description, - "service_description", - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_service_description)), + mapping::entry( + &bam::dimension_kpi_event::service_description, + "service_description", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_service_description)), mapping::entry(&bam::dimension_kpi_event::kpi_ba_id, "kpi_ba_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_kpi_event::kpi_ba_name, - "kpi_ba_name", - get_mod_bam_reporting_kpi_col_size(mod_bam_reporting_kpi_kpi_ba_name)), + mapping::entry(&bam::dimension_kpi_event::kpi_ba_name, + "kpi_ba_name", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_ba_name)), mapping::entry(&bam::dimension_kpi_event::meta_service_id, "meta_service_id", mapping::entry::invalid_on_zero), - mapping::entry(&bam::dimension_kpi_event::meta_service_name, - "meta_service_name", - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_meta_service_name), - mapping::entry::invalid_on_zero), + mapping::entry( + &bam::dimension_kpi_event::meta_service_name, + "meta_service_name", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_meta_service_name), + mapping::entry::invalid_on_zero), mapping::entry(&bam::dimension_kpi_event::boolean_id, "boolean_id", mapping::entry::invalid_on_zero), - mapping::entry( - &bam::dimension_kpi_event::boolean_name, - "boolean_name", - get_mod_bam_reporting_kpi_col_size(mod_bam_reporting_kpi_boolean_name), - mapping::entry::invalid_on_zero), + mapping::entry(&bam::dimension_kpi_event::boolean_name, + "boolean_name", + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_boolean_name), + mapping::entry::invalid_on_zero), mapping::entry(&bam::dimension_kpi_event::impact_warning, "impact_warning"), mapping::entry(&bam::dimension_kpi_event::impact_critical, "impact_critical"), diff --git a/bbdo/bam/dimension_timeperiod.cc b/bbdo/bam/dimension_timeperiod.cc index 9efdea77897..af77d8966a3 100644 --- a/bbdo/bam/dimension_timeperiod.cc +++ b/bbdo/bam/dimension_timeperiod.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2014-2015 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 2014-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 + */ #include "bbdo/bam/dimension_timeperiod.hh" @@ -36,36 +36,39 @@ mapping::entry const dimension_timeperiod::entries[] = { mapping::entry::invalid_on_zero), mapping::entry(&bam::dimension_timeperiod::name, "name", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_name)), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_name)), mapping::entry(&bam::dimension_timeperiod::monday, "monday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_monday)), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_monday)), mapping::entry(&bam::dimension_timeperiod::tuesday, "tuesday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_tuesday)), - mapping::entry(&bam::dimension_timeperiod::wednesday, - "wednesday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_wednesday)), - mapping::entry(&bam::dimension_timeperiod::thursday, - "thursday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_thursday)), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_tuesday)), + mapping::entry( + &bam::dimension_timeperiod::wednesday, + "wednesday", + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_wednesday)), + mapping::entry( + &bam::dimension_timeperiod::thursday, + "thursday", + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_thursday)), mapping::entry(&bam::dimension_timeperiod::friday, "friday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_friday)), - mapping::entry(&bam::dimension_timeperiod::saturday, - "saturday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_saturday)), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_friday)), + mapping::entry( + &bam::dimension_timeperiod::saturday, + "saturday", + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_saturday)), mapping::entry(&bam::dimension_timeperiod::sunday, "sunday", - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_sunday)), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_sunday)), mapping::entry()}; // Operations. diff --git a/bbdo/bam/kpi_event.cc b/bbdo/bam/kpi_event.cc index 9b61e580f1c..cecc50440f1 100644 --- a/bbdo/bam/kpi_event.cc +++ b/bbdo/bam/kpi_event.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2014-2015, 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 : contact@centreon.com -*/ +/** + * Copyright 2014-2015, 2021-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 + */ #include "bbdo/bam/kpi_event.hh" @@ -99,14 +99,16 @@ mapping::entry const kpi_event::entries[] = { mapping::entry(&bam::kpi_event::end_time, "end_time"), mapping::entry(&bam::kpi_event::impact_level, "impact_level"), mapping::entry(&bam::kpi_event::in_downtime, "in_downtime"), - mapping::entry(&bam::kpi_event::output, - "first_output", - get_mod_bam_reporting_kpi_events_col_size( - mod_bam_reporting_kpi_events_first_output)), - mapping::entry(&bam::kpi_event::perfdata, - "first_perfdata", - get_mod_bam_reporting_kpi_events_col_size( - mod_bam_reporting_kpi_events_first_perfdata)), + mapping::entry( + &bam::kpi_event::output, + "first_output", + get_centreon_storage_mod_bam_reporting_kpi_events_col_size( + centreon_storage_mod_bam_reporting_kpi_events_first_output)), + mapping::entry( + &bam::kpi_event::perfdata, + "first_perfdata", + get_centreon_storage_mod_bam_reporting_kpi_events_col_size( + centreon_storage_mod_bam_reporting_kpi_events_first_perfdata)), mapping::entry(&bam::kpi_event::start_time, "start_time"), mapping::entry(&bam::kpi_event::status, "status"), mapping::entry()}; diff --git a/bbdo/storage/metric.cc b/bbdo/storage/metric.cc index 023d4bde2e2..edf51d32337 100644 --- a/bbdo/storage/metric.cc +++ b/bbdo/storage/metric.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013, 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 2009-2013, 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 + */ #include "bbdo/storage/metric.hh" @@ -95,7 +95,8 @@ mapping::entry const metric::entries[] = { mapping::entry::invalid_on_zero), mapping::entry(&metric::name, "name", - get_metrics_col_size(metrics_metric_name)), + get_centreon_storage_metrics_col_size( + centreon_storage_metrics_metric_name)), mapping::entry(&metric::rrd_len, "rrd_len"), mapping::entry(&metric::value, "value"), mapping::entry(&metric::value_type, "value_type"), diff --git a/broker/bam/src/availability_thread.cc b/broker/bam/src/availability_thread.cc index 2f9e6cd2734..19b5094ec5c 100644 --- a/broker/bam/src/availability_thread.cc +++ b/broker/bam/src/availability_thread.cc @@ -181,8 +181,7 @@ void availability_thread::_build_availabilities(time_t midnight) { if (_should_rebuild_all) { query_str = fmt::format( "SELECT MIN(start_time), MAX(end_time), MIN(IFNULL(end_time, '0'))" - " FROM mod_bam_reporting_ba_events" - " WHERE ba_id IN ({})", + " FROM mod_bam_reporting_ba_events WHERE ba_id IN ({})", _bas_to_rebuild); try { std::promise promise; @@ -197,7 +196,7 @@ void availability_thread::_build_availabilities(time_t midnight) { // If there is opened events, rebuild until midnight of this day. // If not, rebuild until the last closed events. if (res.value_as_i32(2) != 0) - last_day = misc::start_of_day(res.value_as_f64(1)); + last_day = misc::start_of_day(res.value_as_i32(1)); _delete_all_availabilities(); } catch (const std::exception& e) { diff --git a/broker/bam/src/monitoring_stream.cc b/broker/bam/src/monitoring_stream.cc index 7c7d315eae8..446d082d5cc 100644 --- a/broker/bam/src/monitoring_stream.cc +++ b/broker/bam/src/monitoring_stream.cc @@ -189,9 +189,9 @@ struct bulk_ba_binder { void operator()(database::mysql_bulk_bind& binder) const { if (event->type() == ba_status::static_type()) { const ba_status& status = *std::static_pointer_cast(event); - binder.set_value_as_f64(0, status.level_nominal); - binder.set_value_as_f64(1, status.level_acknowledgement); - binder.set_value_as_f64(2, status.level_downtime); + binder.set_value_as_f32(0, status.level_nominal); + binder.set_value_as_f32(1, status.level_acknowledgement); + binder.set_value_as_f32(2, status.level_downtime); binder.set_value_as_u32(7, status.ba_id); if (status.last_state_change.is_null()) binder.set_null_u64(3); @@ -203,9 +203,9 @@ struct bulk_ba_binder { } else { const BaStatus& status = static_cast(event.get())->obj(); - binder.set_value_as_f64(0, status.level_nominal()); - binder.set_value_as_f64(1, status.level_acknowledgement()); - binder.set_value_as_f64(2, status.level_downtime()); + binder.set_value_as_f32(0, status.level_nominal()); + binder.set_value_as_f32(1, status.level_acknowledgement()); + binder.set_value_as_f32(2, status.level_downtime()); binder.set_value_as_u32(7, status.ba_id()); if (status.last_state_change() <= 0) binder.set_null_u64(3); @@ -260,32 +260,32 @@ struct bulk_kpi_binder { void operator()(database::mysql_bulk_bind& binder) const { if (event->type() == kpi_status::static_type()) { const kpi_status& status = *std::static_pointer_cast(event); - binder.set_value_as_f64(0, status.level_acknowledgement_hard); + binder.set_value_as_f32(0, status.level_acknowledgement_hard); binder.set_value_as_i32(1, status.state_hard); - binder.set_value_as_f64(2, status.level_downtime_hard); - binder.set_value_as_f64(3, status.level_nominal_hard); + binder.set_value_as_f32(2, status.level_downtime_hard); + binder.set_value_as_f32(3, status.level_nominal_hard); binder.set_value_as_i32(4, 1 + 1); if (status.last_state_change.is_null()) binder.set_null_u64(5); else binder.set_value_as_u64(5, status.last_state_change.get_time_t()); - binder.set_value_as_f64(6, status.last_impact); + binder.set_value_as_f32(6, status.last_impact); binder.set_value_as_bool(7, status.valid); binder.set_value_as_bool(8, status.in_downtime); binder.set_value_as_u32(9, status.kpi_id); } else { const KpiStatus& status( std::static_pointer_cast(event)->obj()); - binder.set_value_as_f64(0, status.level_acknowledgement_hard()); + binder.set_value_as_f32(0, status.level_acknowledgement_hard()); binder.set_value_as_i32(1, status.state_hard()); - binder.set_value_as_f64(2, status.level_downtime_hard()); - binder.set_value_as_f64(3, status.level_nominal_hard()); + binder.set_value_as_f32(2, status.level_downtime_hard()); + binder.set_value_as_f32(3, status.level_nominal_hard()); binder.set_value_as_i32(4, 1 + 1); if (status.last_state_change() <= 0) binder.set_null_u64(5); else binder.set_value_as_u64(5, status.last_state_change()); - binder.set_value_as_f64(6, status.last_impact()); + binder.set_value_as_f32(6, status.last_impact()); binder.set_value_as_bool(7, status.valid()); binder.set_value_as_bool(8, status.in_downtime()); binder.set_value_as_u32(9, status.kpi_id()); diff --git a/broker/bam/src/reporting_stream.cc b/broker/bam/src/reporting_stream.cc index 251aa4e8a53..877d30679ce 100644 --- a/broker/bam/src/reporting_stream.cc +++ b/broker/bam/src/reporting_stream.cc @@ -537,47 +537,54 @@ struct bulk_dimension_kpi_binder { binder.set_value_as_i32(0, dk.kpi_id); binder.set_value_as_str( - 1, misc::string::truncate(kpi_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_name))); + 1, + misc::string::truncate( + kpi_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_name))); binder.set_value_as_i32(2, dk.ba_id); binder.set_value_as_str( - 3, misc::string::truncate(dk.ba_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_ba_name))); + 3, + misc::string::truncate( + dk.ba_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_ba_name))); binder.set_value_as_i32(4, dk.host_id); binder.set_value_as_str( - 5, misc::string::truncate(dk.host_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_host_name))); + 5, misc::string::truncate( + dk.host_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_host_name))); binder.set_value_as_i32(6, dk.service_id); binder.set_value_as_str( - 7, misc::string::truncate( - dk.service_description, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_service_description))); + 7, + misc::string::truncate( + dk.service_description, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_service_description))); if (dk.kpi_ba_id) binder.set_value_as_i32(8, dk.kpi_ba_id); else binder.set_null_i32(8); binder.set_value_as_str( - 9, misc::string::truncate(dk.kpi_ba_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_ba_name))); + 9, misc::string::truncate( + dk.kpi_ba_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_ba_name))); binder.set_value_as_i32(10, dk.meta_service_id); binder.set_value_as_str( 11, - misc::string::truncate(dk.meta_service_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_meta_service_name))); - binder.set_value_as_f64(12, dk.impact_warning); - binder.set_value_as_f64(13, dk.impact_critical); - binder.set_value_as_f64(14, dk.impact_unknown); + misc::string::truncate( + dk.meta_service_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_meta_service_name))); + binder.set_value_as_f32(12, dk.impact_warning); + binder.set_value_as_f32(13, dk.impact_critical); + binder.set_value_as_f32(14, dk.impact_unknown); binder.set_value_as_i32(15, dk.boolean_id); binder.set_value_as_str( - 16, misc::string::truncate(dk.boolean_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_boolean_name))); + 16, misc::string::truncate( + dk.boolean_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_boolean_name))); } else { const DimensionKpiEvent& dk = std::static_pointer_cast(event) @@ -599,47 +606,54 @@ struct bulk_dimension_kpi_binder { binder.set_value_as_i32(0, dk.kpi_id()); binder.set_value_as_str( - 1, misc::string::truncate(kpi_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_name))); + 1, + misc::string::truncate( + kpi_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_name))); binder.set_value_as_i32(2, dk.ba_id()); binder.set_value_as_str( - 3, misc::string::truncate(dk.ba_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_ba_name))); + 3, misc::string::truncate( + dk.ba_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_ba_name))); binder.set_value_as_i32(4, dk.host_id()); binder.set_value_as_str( - 5, misc::string::truncate(dk.host_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_host_name))); + 5, misc::string::truncate( + dk.host_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_host_name))); binder.set_value_as_i32(6, dk.service_id()); binder.set_value_as_str( - 7, misc::string::truncate( - dk.service_description(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_service_description))); + 7, + misc::string::truncate( + dk.service_description(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_service_description))); if (dk.kpi_ba_id()) binder.set_value_as_i32(8, dk.kpi_ba_id()); else binder.set_null_i32(8); binder.set_value_as_str( - 9, misc::string::truncate(dk.kpi_ba_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_ba_name))); + 9, misc::string::truncate( + dk.kpi_ba_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_ba_name))); binder.set_value_as_i32(10, dk.meta_service_id()); binder.set_value_as_str( 11, - misc::string::truncate(dk.meta_service_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_meta_service_name))); - binder.set_value_as_f64(12, dk.impact_warning()); - binder.set_value_as_f64(13, dk.impact_critical()); - binder.set_value_as_f64(14, dk.impact_unknown()); + misc::string::truncate( + dk.meta_service_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_meta_service_name))); + binder.set_value_as_f32(12, dk.impact_warning()); + binder.set_value_as_f32(13, dk.impact_critical()); + binder.set_value_as_f32(14, dk.impact_unknown()); binder.set_value_as_i32(15, dk.boolean_id()); binder.set_value_as_str( - 16, misc::string::truncate(dk.boolean_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_boolean_name))); + 16, misc::string::truncate( + dk.boolean_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_boolean_name))); } binder.next_row(); } @@ -671,34 +685,39 @@ struct dimension_kpi_binder { return fmt::format( "({},'{}',{},'{}',{},'{}',{},'{}',{},'{}',{},'{}',{},{},{},{},'{}')", dk.kpi_id, - misc::string::truncate(kpi_name, get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_name)), + misc::string::truncate( + kpi_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_name)), dk.ba_id, - misc::string::truncate(dk.ba_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_ba_name)), + misc::string::truncate( + dk.ba_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_ba_name)), dk.host_id, - misc::string::truncate(dk.host_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_host_name)), + misc::string::truncate( + dk.host_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_host_name)), dk.service_id, misc::string::truncate( dk.service_description, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_service_description)), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_service_description)), sz_kpi_ba_id, - misc::string::truncate(dk.kpi_ba_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_ba_name)), + misc::string::truncate( + dk.kpi_ba_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_ba_name)), dk.meta_service_id, - misc::string::truncate(dk.meta_service_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_meta_service_name)), + misc::string::truncate( + dk.meta_service_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_meta_service_name)), dk.impact_warning, dk.impact_critical, dk.impact_unknown, dk.boolean_id, - misc::string::truncate(dk.boolean_name, - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_boolean_name))); + misc::string::truncate( + dk.boolean_name, + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_boolean_name))); } else { const DimensionKpiEvent& dk = std::static_pointer_cast(event) @@ -722,34 +741,40 @@ struct dimension_kpi_binder { return fmt::format( "({},'{}',{},'{}',{},'{}',{},'{}',{},'{}',{},'{}',{},{},{},{},'{}')", dk.kpi_id(), - misc::string::truncate(kpi_name, get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_name)), + misc::string::truncate( + kpi_name, get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_name)), dk.ba_id(), - misc::string::truncate(dk.ba_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_ba_name)), + misc::string::truncate( + dk.ba_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_ba_name)), dk.host_id(), - misc::string::truncate(dk.host_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_host_name)), + misc::string::truncate( + dk.host_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_host_name)), dk.service_id(), misc::string::truncate( dk.service_description(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_service_description)), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_service_description)), sz_kpi_ba_id, - misc::string::truncate(dk.kpi_ba_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_kpi_ba_name)), + misc::string::truncate( + dk.kpi_ba_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_kpi_ba_name)), dk.meta_service_id(), - misc::string::truncate(dk.meta_service_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_meta_service_name)), + misc::string::truncate( + dk.meta_service_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_meta_service_name)), dk.impact_warning(), dk.impact_critical(), dk.impact_unknown(), dk.boolean_id(), - misc::string::truncate(dk.boolean_name(), - get_mod_bam_reporting_kpi_col_size( - mod_bam_reporting_kpi_boolean_name))); + misc::string::truncate( + dk.boolean_name(), + get_centreon_storage_mod_bam_reporting_kpi_col_size( + centreon_storage_mod_bam_reporting_kpi_boolean_name))); } } }; @@ -1428,12 +1453,13 @@ void reporting_stream::_process_dimension_ba( _dimension_ba_insert.bind_value_as_i32(0, dba.ba_id); _dimension_ba_insert.bind_value_as_str( 1, misc::string::truncate( - dba.ba_name, - get_mod_bam_reporting_ba_col_size(mod_bam_reporting_ba_ba_name))); + dba.ba_name, get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_name))); _dimension_ba_insert.bind_value_as_str( - 2, misc::string::truncate(dba.ba_description, - get_mod_bam_reporting_ba_col_size( - mod_bam_reporting_ba_ba_description))); + 2, misc::string::truncate( + dba.ba_description, + get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_description))); _dimension_ba_insert.bind_value_as_f64(3, dba.sla_month_percent_crit); _dimension_ba_insert.bind_value_as_f64(4, dba.sla_month_percent_warn); _dimension_ba_insert.bind_value_as_f64(5, dba.sla_duration_crit); @@ -1455,13 +1481,15 @@ void reporting_stream::_process_pb_dimension_ba( dba.ba_id(), dba.ba_description()); _dimension_ba_insert.bind_value_as_i32(0, dba.ba_id()); _dimension_ba_insert.bind_value_as_str( - 1, misc::string::truncate( - dba.ba_name(), - get_mod_bam_reporting_ba_col_size(mod_bam_reporting_ba_ba_name))); + 1, + misc::string::truncate( + dba.ba_name(), get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_name))); _dimension_ba_insert.bind_value_as_str( - 2, misc::string::truncate(dba.ba_description(), - get_mod_bam_reporting_ba_col_size( - mod_bam_reporting_ba_ba_description))); + 2, misc::string::truncate( + dba.ba_description(), + get_centreon_storage_mod_bam_reporting_ba_col_size( + centreon_storage_mod_bam_reporting_ba_ba_description))); _dimension_ba_insert.bind_value_as_f64(3, dba.sla_month_percent_crit()); _dimension_ba_insert.bind_value_as_f64(4, dba.sla_month_percent_warn()); _dimension_ba_insert.bind_value_as_f64(5, dba.sla_duration_crit()); @@ -1485,12 +1513,13 @@ void reporting_stream::_process_dimension_bv( _dimension_bv_insert.bind_value_as_i32(0, dbv.bv_id); _dimension_bv_insert.bind_value_as_str( 1, misc::string::truncate( - dbv.bv_name, - get_mod_bam_reporting_bv_col_size(mod_bam_reporting_bv_bv_name))); + dbv.bv_name, get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_name))); _dimension_bv_insert.bind_value_as_str( - 2, misc::string::truncate(dbv.bv_description, - get_mod_bam_reporting_bv_col_size( - mod_bam_reporting_bv_bv_description))); + 2, misc::string::truncate( + dbv.bv_description, + get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_description))); _mysql.run_statement(_dimension_bv_insert, database::mysql_error::insert_bv); } @@ -1509,13 +1538,15 @@ void reporting_stream::_process_pb_dimension_bv( _dimension_bv_insert.bind_value_as_i32(0, dbv.bv_id()); _dimension_bv_insert.bind_value_as_str( - 1, misc::string::truncate( - dbv.bv_name(), - get_mod_bam_reporting_bv_col_size(mod_bam_reporting_bv_bv_name))); + 1, + misc::string::truncate( + dbv.bv_name(), get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_name))); _dimension_bv_insert.bind_value_as_str( - 2, misc::string::truncate(dbv.bv_description(), - get_mod_bam_reporting_bv_col_size( - mod_bam_reporting_bv_bv_description))); + 2, misc::string::truncate( + dbv.bv_description(), + get_centreon_storage_mod_bam_reporting_bv_col_size( + centreon_storage_mod_bam_reporting_bv_bv_description))); _mysql.run_statement(_dimension_bv_insert, database::mysql_error::insert_bv); } @@ -1871,37 +1902,45 @@ void reporting_stream::_process_pb_dimension_timeperiod( tp.name()); _dimension_timeperiod_insert.bind_value_as_i32(0, tp.id()); _dimension_timeperiod_insert.bind_value_as_str( - 1, misc::string::truncate(tp.name(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_name))); + 1, misc::string::truncate( + tp.name(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_name))); _dimension_timeperiod_insert.bind_value_as_str( - 2, misc::string::truncate(tp.sunday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_sunday))); + 2, misc::string::truncate( + tp.sunday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_sunday))); _dimension_timeperiod_insert.bind_value_as_str( - 3, misc::string::truncate(tp.monday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_monday))); + 3, misc::string::truncate( + tp.monday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_monday))); _dimension_timeperiod_insert.bind_value_as_str( - 4, misc::string::truncate(tp.tuesday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_tuesday))); + 4, misc::string::truncate( + tp.tuesday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_tuesday))); _dimension_timeperiod_insert.bind_value_as_str( - 5, misc::string::truncate(tp.wednesday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_wednesday))); + 5, misc::string::truncate( + tp.wednesday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_wednesday))); _dimension_timeperiod_insert.bind_value_as_str( - 6, misc::string::truncate(tp.thursday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_thursday))); + 6, misc::string::truncate( + tp.thursday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_thursday))); _dimension_timeperiod_insert.bind_value_as_str( - 7, misc::string::truncate(tp.friday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_friday))); + 7, misc::string::truncate( + tp.friday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_friday))); _dimension_timeperiod_insert.bind_value_as_str( - 8, misc::string::truncate(tp.saturday(), - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_saturday))); + 8, misc::string::truncate( + tp.saturday(), + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_saturday))); _mysql.run_statement(_dimension_timeperiod_insert, database::mysql_error::insert_timeperiod); @@ -1924,37 +1963,45 @@ void reporting_stream::_process_dimension_timeperiod( _dimension_timeperiod_insert.bind_value_as_i32(0, tp.id); _dimension_timeperiod_insert.bind_value_as_str( - 1, misc::string::truncate(tp.name, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_name))); + 1, + misc::string::truncate( + tp.name, get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_name))); _dimension_timeperiod_insert.bind_value_as_str( - 2, misc::string::truncate(tp.sunday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_sunday))); + 2, misc::string::truncate( + tp.sunday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_sunday))); _dimension_timeperiod_insert.bind_value_as_str( - 3, misc::string::truncate(tp.monday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_monday))); + 3, misc::string::truncate( + tp.monday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_monday))); _dimension_timeperiod_insert.bind_value_as_str( - 4, misc::string::truncate(tp.tuesday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_tuesday))); + 4, misc::string::truncate( + tp.tuesday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_tuesday))); _dimension_timeperiod_insert.bind_value_as_str( - 5, misc::string::truncate(tp.wednesday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_wednesday))); + 5, misc::string::truncate( + tp.wednesday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_wednesday))); _dimension_timeperiod_insert.bind_value_as_str( - 6, misc::string::truncate(tp.thursday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_thursday))); + 6, misc::string::truncate( + tp.thursday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_thursday))); _dimension_timeperiod_insert.bind_value_as_str( - 7, misc::string::truncate(tp.friday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_friday))); + 7, misc::string::truncate( + tp.friday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_friday))); _dimension_timeperiod_insert.bind_value_as_str( - 8, misc::string::truncate(tp.saturday, - get_mod_bam_reporting_timeperiods_col_size( - mod_bam_reporting_timeperiods_saturday))); + 8, misc::string::truncate( + tp.saturday, + get_centreon_storage_mod_bam_reporting_timeperiods_col_size( + centreon_storage_mod_bam_reporting_timeperiods_saturday))); _mysql.run_statement(_dimension_timeperiod_insert, database::mysql_error::insert_timeperiod); DimensionTimeperiod convert; diff --git a/broker/core/inc/com/centreon/broker/misc/perfdata.hh b/broker/core/inc/com/centreon/broker/misc/perfdata.hh index 65a9922ff58..eb27bd73f4a 100644 --- a/broker/core/inc/com/centreon/broker/misc/perfdata.hh +++ b/broker/core/inc/com/centreon/broker/misc/perfdata.hh @@ -35,50 +35,50 @@ class perfdata { enum data_type { gauge = 0, counter, derive, absolute, automatic }; private: - double _critical; - double _critical_low; + float _critical; + float _critical_low; bool _critical_mode; - double _max; - double _min; + float _max; + float _min; std::string _name; std::string _unit; - double _value; + float _value; int16_t _value_type; - double _warning; - double _warning_low; + float _warning; + float _warning_low; bool _warning_mode; public: perfdata(); perfdata(const perfdata&) = default; perfdata(perfdata&&) = default; - ~perfdata() noexcept; + ~perfdata() noexcept = default; perfdata& operator=(perfdata const& pd); perfdata& operator=(perfdata&& pd); - double critical() const noexcept; - void critical(double c) noexcept; - double critical_low() const noexcept; - void critical_low(double c) noexcept; + float critical() const noexcept; + void critical(float c) noexcept; + float critical_low() const noexcept; + void critical_low(float c) noexcept; bool critical_mode() const noexcept; void critical_mode(bool m) noexcept; - double max() const noexcept; - void max(double m) noexcept; - double min() const noexcept; - void min(double m) noexcept; + float max() const noexcept; + void max(float m) noexcept; + float min() const noexcept; + void min(float m) noexcept; std::string const& name() const noexcept; void name(std::string const& n); void name(std::string&& n); std::string const& unit() const noexcept; void unit(std::string const& u); void unit(std::string&& u); - double value() const noexcept; - void value(double v) noexcept; + float value() const noexcept; + void value(float v) noexcept; int16_t value_type() const noexcept; void value_type(int16_t t) noexcept; - double warning() const noexcept; - void warning(double w) noexcept; - double warning_low() const noexcept; - void warning_low(double w) noexcept; + float warning() const noexcept; + void warning(float w) noexcept; + float warning_low() const noexcept; + void warning_low(float w) noexcept; bool warning_mode() const noexcept; void warning_mode(bool m) noexcept; }; @@ -89,7 +89,7 @@ class perfdata { * @return Metric value. */ // Inlined after profiling for performance. -inline double perfdata::value() const noexcept { +inline float perfdata::value() const noexcept { return _value; } } // namespace misc diff --git a/broker/core/sql/src/table_max_size.py b/broker/core/sql/src/table_max_size.py index 08a887fe775..76bac8e18c8 100644 --- a/broker/core/sql/src/table_max_size.py +++ b/broker/core/sql/src/table_max_size.py @@ -1,29 +1,32 @@ #!/usr/bin/python3 """ -** Copyright 2019-2020 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 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. +* 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 """ import sys import re +from datetime import datetime +import os dico = {} pattern_ct = re.compile( 'CREATE TABLE( IF NOT EXISTS)? (centreon_storage\.)?`?([^`]*)`? \(') column_ct = re.compile('\s*`?([^`]*)`? (varchar\(([0-9]*)\)|text)') +column_ct_nb = re.compile('\s*`?([^`]*)`? (float|double)') end_ct = re.compile('^\)') debug = False @@ -37,6 +40,7 @@ def print_dbg(s): header_file = sys.argv[1] for sql_file in sys.argv[2:]: with open(sql_file, encoding='utf-8') as fp: + database = os.path.basename(sql_file).split('.')[0] line = fp.readline() in_block = False @@ -45,7 +49,7 @@ def print_dbg(s): m = pattern_ct.match(line) if m: print_dbg("New table {}".format(m.group(3))) - current_table = m.group(3) + current_table = f"{database}_{m.group(3)}" in_block = True else: if end_ct.match(line): @@ -57,13 +61,19 @@ def print_dbg(s): print_dbg("New text column {} of size {}".format( m.group(1), m.group(3))) dico.setdefault(current_table, []).append( - (m.group(1), m.group(3))) + (m.group(1), 'TEXT', m.group(3))) else: print_dbg("New text column {} of 65534".format( m.group(1), m.group(2))) dico.setdefault(current_table, []).append( - (m.group(1), 65534)) - + (m.group(1), 'TEXT', 65534)) + else: + m = column_ct_nb.match(line) + if m: + print_dbg(f"New number column {m.group(1)} of type {m.group(2)}") + dico.setdefault(current_table, []).append( + (m.group(1), 'NUMBER', m.group(2))) + line = fp.readline() fp.close() @@ -72,39 +82,52 @@ def print_dbg(s): for t, content in dico.items(): cols += "enum {}_cols {{\n".format(t) - sizes = "constexpr static uint32_t {}_size[] {{\n".format(t) + sizes = "constexpr static pair_type_size {}_size[] {{\n".format(t) for c in content: - cols += " {}_{},\n".format(t, c[0]) - sizes += " {},\n".format(c[1]) + cols += f" {t}_{c[0]},\n" + if c[1] == 'TEXT': + sizes += f" {{{c[1]}, {c[2]}}}, // {c[0]}\n" + else: + if c[2] == 'double': + s = 8 + else: + s = 4 + sizes += f" {{{c[1]}, {s}}}, // {c[0]}\n" cols += "};\n" sizes += "};\n" cols += sizes - cols += """constexpr uint32_t get_{}_col_size( - {}_cols const& col) {{ - return {}_size[col]; + cols += f"""constexpr uint32_t get_{t}_col_size( + {t}_cols const& col) {{ + return {t}_size[col].size; }} -""".format(t, t, t) +constexpr col_type get_{t}_col_type( + {t}_cols const& col) {{ + return {t}_size[col].type; +}} + +""" with open(header_file, 'w', encoding="utf-8") as fp: - fp.write("""/* -** Copyright 2020 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 -*/ + year = datetime.now().year + fp.write(f"""/** + * Copyright 2020-{year} 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 __TABLE_MAX_SIZE_HH__ #define __TABLE_MAX_SIZE_HH__ @@ -113,8 +136,18 @@ def print_dbg(s): CCB_BEGIN() +enum col_type {{ + TEXT, + NUMBER +}}; + +struct pair_type_size {{ + col_type type; + uint32_t size; +}}; + + """) - # fp.write(enum) fp.write(cols) fp.write("\n\nCCB_END()\n\n#endif /* __TABLE_MAX_SIZE_HH__ */") diff --git a/broker/core/src/misc/parse_perfdata.cc b/broker/core/src/misc/parse_perfdata.cc index 24eb62e9247..28226f5fc24 100644 --- a/broker/core/src/misc/parse_perfdata.cc +++ b/broker/core/src/misc/parse_perfdata.cc @@ -37,8 +37,8 @@ using namespace com::centreon::broker::misc; * * @return Extracted real value if successful, NaN otherwise. */ -static inline double extract_double(char const** str, bool skip = true) { - double retval; +static inline float extract_float(char const** str, bool skip = true) { + float retval; char* tmp; if (isspace(**str)) retval = NAN; @@ -50,13 +50,13 @@ static inline double extract_double(char const** str, bool skip = true) { size_t t = strcspn(comma, " \t\n\r;"); char* nb = strndup(*str, (comma - *str) + t); nb[comma - *str] = '.'; - retval = strtod(nb, &tmp); + retval = strtof(nb, &tmp); if (nb == tmp) retval = NAN; *str = *str + (tmp - nb); free(nb); } else { - retval = strtod(*str, &tmp); + retval = strtof(*str, &tmp); if (*str == tmp) retval = NAN; *str = tmp; @@ -76,8 +76,8 @@ static inline double extract_double(char const** str, bool skip = true) { * otherwise. * @param[in,out] str Pointer to a perfdata string. */ -static inline void extract_range(double* low, - double* high, +static inline void extract_range(float* low, + float* high, bool* inclusive, char const** str) { // Exclusive range ? @@ -88,15 +88,15 @@ static inline void extract_range(double* low, *inclusive = false; // Low threshold value. - double low_value; + float low_value; if ('~' == **str) { - low_value = -std::numeric_limits::infinity(); + low_value = -std::numeric_limits::infinity(); ++*str; } else - low_value = extract_double(str); + low_value = extract_float(str); // High threshold value. - double high_value; + float high_value; if (**str != ':') { high_value = low_value; if (!std::isnan(low_value)) @@ -104,9 +104,9 @@ static inline void extract_range(double* low, } else { ++*str; char const* ptr(*str); - high_value = extract_double(str); + high_value = extract_float(str); if (std::isnan(high_value) && ((*str == ptr) || (*str == (ptr + 1)))) - high_value = std::numeric_limits::infinity(); + high_value = std::numeric_limits::infinity(); } // Set values. @@ -205,7 +205,8 @@ std::list misc::parse_perfdata(uint32_t host_id, if (end - s + 1 > 0) { std::string name(s, end - s + 1); name.resize(misc::string::adjust_size_utf8( - name, get_metrics_col_size(metrics_metric_name))); + name, get_centreon_storage_metrics_col_size( + centreon_storage_metrics_metric_name))); p.name(std::move(name)); } else { log_v2::perfdata()->error( @@ -233,7 +234,7 @@ std::list misc::parse_perfdata(uint32_t host_id, } // Extract value. - p.value(extract_double(const_cast(&tmp), false)); + p.value(extract_float(const_cast(&tmp), false)); if (std::isnan(p.value())) { int i; for (i = 0; i < 10 && tmp[i]; i++) @@ -253,7 +254,8 @@ std::list misc::parse_perfdata(uint32_t host_id, { std::string unit(tmp, t); unit.resize(misc::string::adjust_size_utf8( - unit, get_metrics_col_size(metrics_unit_name))); + unit, get_centreon_storage_metrics_col_size( + centreon_storage_metrics_unit_name))); p.unit(std::move(unit)); } tmp += t; @@ -262,8 +264,8 @@ std::list misc::parse_perfdata(uint32_t host_id, // Extract warning. { - double warning_high; - double warning_low; + float warning_high; + float warning_low; bool warning_mode; extract_range(&warning_low, &warning_high, &warning_mode, const_cast(&tmp)); @@ -274,8 +276,8 @@ std::list misc::parse_perfdata(uint32_t host_id, // Extract critical. { - double critical_high; - double critical_low; + float critical_high; + float critical_low; bool critical_mode; extract_range(&critical_low, &critical_high, &critical_mode, const_cast(&tmp)); @@ -285,10 +287,10 @@ std::list misc::parse_perfdata(uint32_t host_id, } // Extract minimum. - p.min(extract_double(const_cast(&tmp))); + p.min(extract_float(const_cast(&tmp))); // Extract maximum. - p.max(extract_double(const_cast(&tmp))); + p.max(extract_float(const_cast(&tmp))); // Log new perfdata. log_v2::perfdata()->debug( diff --git a/broker/core/src/misc/perfdata.cc b/broker/core/src/misc/perfdata.cc index 0d384663a01..cfec4238df0 100644 --- a/broker/core/src/misc/perfdata.cc +++ b/broker/core/src/misc/perfdata.cc @@ -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 : contact@centreon.com -*/ +/** + * Copyright 2011-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 + */ #include "com/centreon/broker/misc/perfdata.hh" @@ -37,11 +37,6 @@ perfdata::perfdata() _warning_low(NAN), _warning_mode(false) {} -/** - * Destructor. - */ -perfdata::~perfdata() noexcept {} - /** * Move operator. * @@ -97,7 +92,7 @@ perfdata& perfdata::operator=(perfdata const& other) { * * @return Critical value. */ -double perfdata::critical() const noexcept { +float perfdata::critical() const noexcept { return _critical; } @@ -106,7 +101,7 @@ double perfdata::critical() const noexcept { * * @param[in] c New critical value. */ -void perfdata::critical(double c) noexcept { +void perfdata::critical(float c) noexcept { _critical = c; } @@ -115,7 +110,7 @@ void perfdata::critical(double c) noexcept { * * @return Low critical value. */ -double perfdata::critical_low() const noexcept { +float perfdata::critical_low() const noexcept { return _critical_low; } @@ -124,7 +119,7 @@ double perfdata::critical_low() const noexcept { * * @param[in] c Low critical value. */ -void perfdata::critical_low(double c) noexcept { +void perfdata::critical_low(float c) noexcept { _critical_low = c; } @@ -153,7 +148,7 @@ void perfdata::critical_mode(bool m) noexcept { * * @return Maximum value. */ -double perfdata::max() const noexcept { +float perfdata::max() const noexcept { return _max; } @@ -162,7 +157,7 @@ double perfdata::max() const noexcept { * * @param[in] m New maximum value. */ -void perfdata::max(double m) noexcept { +void perfdata::max(float m) noexcept { _max = m; } @@ -171,7 +166,7 @@ void perfdata::max(double m) noexcept { * * @return Minimum value. */ -double perfdata::min() const noexcept { +float perfdata::min() const noexcept { return _min; } @@ -180,7 +175,7 @@ double perfdata::min() const noexcept { * * @param[in] m New minimum value. */ -void perfdata::min(double m) noexcept { +void perfdata::min(float m) noexcept { _min = m; } @@ -233,7 +228,7 @@ void perfdata::unit(std::string&& u) { * * @param[in] v New value. */ -void perfdata::value(double v) noexcept { +void perfdata::value(float v) noexcept { _value = v; } @@ -260,7 +255,7 @@ void perfdata::value_type(int16_t t) noexcept { * * @return Warning value. */ -double perfdata::warning() const noexcept { +float perfdata::warning() const noexcept { return _warning; } @@ -269,7 +264,7 @@ double perfdata::warning() const noexcept { * * @param[in] v New warning value. */ -void perfdata::warning(double w) noexcept { +void perfdata::warning(float w) noexcept { _warning = w; } @@ -278,7 +273,7 @@ void perfdata::warning(double w) noexcept { * * @return Low warning value. */ -double perfdata::warning_low() const noexcept { +float perfdata::warning_low() const noexcept { return _warning_low; } @@ -287,7 +282,7 @@ double perfdata::warning_low() const noexcept { * * @param[in] w Low warning value. */ -void perfdata::warning_low(double w) noexcept { +void perfdata::warning_low(float w) noexcept { _warning_low = w; } @@ -325,7 +320,7 @@ void perfdata::warning_mode(bool m) noexcept { * * @return true if a and b are equal. */ -static inline bool double_equal(double a, double b) { +static inline bool float_equal(float a, float b) { return (std::isnan(a) && std::isnan(b)) || (std::isinf(a) && std::isinf(b) && std::signbit(a) == std::signbit(b)) || @@ -342,16 +337,16 @@ static inline bool double_equal(double a, double b) { * @return true if both objects are equal. */ bool operator==(perfdata const& left, perfdata const& right) { - return double_equal(left.critical(), right.critical()) && - double_equal(left.critical_low(), right.critical_low()) && + return float_equal(left.critical(), right.critical()) && + float_equal(left.critical_low(), right.critical_low()) && left.critical_mode() == right.critical_mode() && - double_equal(left.max(), right.max()) && - double_equal(left.min(), right.min()) && left.name() == right.name() && + float_equal(left.max(), right.max()) && + float_equal(left.min(), right.min()) && left.name() == right.name() && left.unit() == right.unit() && - double_equal(left.value(), right.value()) && + float_equal(left.value(), right.value()) && left.value_type() == right.value_type() && - double_equal(left.warning(), right.warning()) && - double_equal(left.warning_low(), right.warning_low()) && + float_equal(left.warning(), right.warning()) && + float_equal(left.warning_low(), right.warning_low()) && left.warning_mode() == right.warning_mode(); } diff --git a/broker/core/test/misc/perfdata.cc b/broker/core/test/misc/perfdata.cc index 4f77a2ad6d5..61b679d608a 100644 --- a/broker/core/test/misc/perfdata.cc +++ b/broker/core/test/misc/perfdata.cc @@ -81,29 +81,29 @@ TEST(MiscPerfdata, Assign) { p1.warning_mode(false); // Check objects properties values. - ASSERT_FALSE(fabs(p1.critical() - 9432.5) > 0.00001); - ASSERT_FALSE(fabs(p1.critical_low() - 1000.0001) > 0.00001); + ASSERT_FALSE(fabs(p1.critical() - 9432.5f) > 0.00001f); + ASSERT_TRUE(fabs(p1.critical_low() - 1000.0001f) < 0.0001f); ASSERT_FALSE(!p1.critical_mode()); - ASSERT_FALSE(fabs(p1.max() - 123.0) > 0.00001); - ASSERT_FALSE(fabs(p1.min() - 843.876) > 0.00001); + ASSERT_FALSE(fabs(p1.max() - 123.0f) > 0.00001f); + ASSERT_TRUE(fabs(p1.min() - 843.876f) < 0.0001f); ASSERT_FALSE(p1.name() != "baz"); ASSERT_FALSE(p1.unit() != "qux"); - ASSERT_FALSE(fabs(p1.value() - 3485.9) > 0.00001); + ASSERT_TRUE(fabs(p1.value() - 3485.9f) < 0.0001f); ASSERT_FALSE(p1.value_type() != misc::perfdata::derive); - ASSERT_FALSE(fabs(p1.warning() - 3612.0) > 0.00001); - ASSERT_FALSE(fabs(p1.warning_low() + 987579.0) > 0.01); + ASSERT_FALSE(fabs(p1.warning() - 3612.0f) > 0.00001f); + ASSERT_FALSE(fabs(p1.warning_low() + 987579.0f) > 0.01f); ASSERT_FALSE(p1.warning_mode()); - ASSERT_FALSE(fabs(p2.critical() - 42.0) > 0.00001); - ASSERT_FALSE(fabs(p2.critical_low() + 456.032) > 0.00001); + ASSERT_FALSE(fabs(p2.critical() - 42.0f) > 0.00001f); + ASSERT_FALSE(fabs(p2.critical_low() + 456.032f) > 0.00001f); ASSERT_FALSE(p2.critical_mode()); - ASSERT_FALSE(fabs(p2.max() - 76.3) > 0.00001); - ASSERT_FALSE(fabs(p2.min() - 567.2) > 0.00001); + ASSERT_FALSE(fabs(p2.max() - 76.3f) > 0.00001f); + ASSERT_FALSE(fabs(p2.min() - 567.2f) > 0.00001f); ASSERT_FALSE(p2.name() != "foo"); ASSERT_FALSE(p2.unit() != "bar"); - ASSERT_FALSE(fabs(p2.value() - 52189.912) > 0.00001); + ASSERT_FALSE(fabs(p2.value() - 52189.912f) > 0.00001f); ASSERT_FALSE(p2.value_type() != misc::perfdata::counter); - ASSERT_FALSE(fabs(p2.warning() - 4548.0) > 0.00001); - ASSERT_FALSE(fabs(p2.warning_low() - 42.42) > 0.00001); + ASSERT_FALSE(fabs(p2.warning() - 4548.0f) > 0.00001f); + ASSERT_FALSE(fabs(p2.warning_low() - 42.42f) > 0.00001f); ASSERT_FALSE(!p2.warning_mode()); } @@ -144,29 +144,29 @@ TEST(MiscPerfdata, CopyCtor) { p1.warning_mode(false); // Check objects properties values. - ASSERT_FALSE(fabs(p1.critical() - 9432.5) > 0.00001); - ASSERT_FALSE(fabs(p1.critical_low() - 1000.0001) > 0.00001); + ASSERT_FALSE(fabs(p1.critical() - 9432.5f) > 0.00001f); + ASSERT_FALSE(fabs(p1.critical_low() - 1000.0001f) > 0.00001f); ASSERT_FALSE(!p1.critical_mode()); - ASSERT_FALSE(fabs(p1.max() - 123.0) > 0.00001); - ASSERT_FALSE(fabs(p1.min() - 843.876) > 0.00001); + ASSERT_FALSE(fabs(p1.max() - 123.0f) > 0.00001f); + ASSERT_FALSE(fabs(p1.min() - 843.876f) > 0.00001f); ASSERT_FALSE(p1.name() != "baz"); ASSERT_FALSE(p1.unit() != "qux"); - ASSERT_FALSE(fabs(p1.value() - 3485.9) > 0.00001); + ASSERT_FALSE(fabs(p1.value() - 3485.9f) > 0.00001f); ASSERT_FALSE(p1.value_type() != misc::perfdata::derive); - ASSERT_FALSE(fabs(p1.warning() - 3612.0) > 0.00001); - ASSERT_FALSE(fabs(p1.warning_low() + 987579.0) > 0.01); + ASSERT_FALSE(fabs(p1.warning() - 3612.0f) > 0.00001f); + ASSERT_FALSE(fabs(p1.warning_low() + 987579.0f) > 0.01f); ASSERT_FALSE(p1.warning_mode()); - ASSERT_FALSE(fabs(p2.critical() - 42.0) > 0.00001); - ASSERT_FALSE(fabs(p2.critical_low() + 456.032) > 0.00001); + ASSERT_FALSE(fabs(p2.critical() - 42.0f) > 0.00001f); + ASSERT_FALSE(fabs(p2.critical_low() + 456.032f) > 0.00001f); ASSERT_FALSE(p2.critical_mode()); - ASSERT_FALSE(fabs(p2.max() - 76.3) > 0.00001); - ASSERT_FALSE(fabs(p2.min() - 567.2) > 0.00001); + ASSERT_FALSE(fabs(p2.max() - 76.3f) > 0.00001f); + ASSERT_FALSE(fabs(p2.min() - 567.2f) > 0.00001f); ASSERT_FALSE(p2.name() != "foo"); ASSERT_FALSE(p2.unit() != "bar"); - ASSERT_FALSE(fabs(p2.value() - 52189.912) > 0.00001); + ASSERT_FALSE(fabs(p2.value() - 52189.912f) > 0.00001f); ASSERT_FALSE(p2.value_type() != misc::perfdata::counter); - ASSERT_FALSE(fabs(p2.warning() - 4548.0) > 0.00001); - ASSERT_FALSE(fabs(p2.warning_low() - 42.42) > 0.00001); + ASSERT_FALSE(fabs(p2.warning() - 4548.0f) > 0.00001f); + ASSERT_FALSE(fabs(p2.warning_low() - 42.42f) > 0.00001f); ASSERT_FALSE(!p2.warning_mode()); } diff --git a/broker/grpc/test/acceptor.cc b/broker/grpc/test/acceptor.cc index 2ec5f12a608..83cd775878a 100644 --- a/broker/grpc/test/acceptor.cc +++ b/broker/grpc/test/acceptor.cc @@ -62,6 +62,8 @@ static auto read_file = [](const std::string& path) { TEST_F(GrpcTlsTest, TlsStream) { /* Let's prepare certificates */ std::string hostname = misc::exec("hostname --fqdn"); + if (hostname.empty()) + hostname = "localhost"; hostname = misc::string::trim(hostname); std::string server_cmd( fmt::format("openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 " diff --git a/broker/lua/test/lua.cc b/broker/lua/test/lua.cc index bf247594aaf..8e87a730498 100644 --- a/broker/lua/test/lua.cc +++ b/broker/lua/test/lua.cc @@ -1936,7 +1936,7 @@ TEST_F(LuaTest, ParsePerfdata2) { size_t pos10 = lst.find("\"critical_high\":nan", pos1 + 1); size_t pos11 = lst.find("\"warning_high\":nan", pos1 + 1); size_t pos12 = lst.find("\"critical_low\":nan", pos1 + 1); - size_t pos13 = lst.find("\"value\":94.82", pos1 + 1); + size_t pos13 = lst.find("\"value\":94.8", pos1 + 1); size_t pos14 = lst.find("\"max\":100", pos1 + 1); size_t pos15 = lst.find( "\"metric_fields\":[\"azure\",\"insights\",\"logicaldisk\",\"free\"," @@ -2002,7 +2002,7 @@ TEST_F(LuaTest, ParsePerfdata3) { size_t pos10 = lst.find("\"critical_high\":nan", pos1 + 1); size_t pos11 = lst.find("\"warning_high\":nan", pos1 + 1); size_t pos12 = lst.find("\"critical_low\":nan", pos1 + 1); - size_t pos13 = lst.find("\"value\":94.82", pos1 + 1); + size_t pos13 = lst.find("\"value\":94.8", pos1 + 1); size_t pos14 = lst.find("\"max\":100", pos1 + 1); size_t pos15 = lst.find( "metric_fields\":[\"PingSDWanvdomifName\",\"azure\",\"insights\"," @@ -2067,7 +2067,7 @@ TEST_F(LuaTest, ParsePerfdata4) { size_t pos10 = lst.find("\"critical_high\":nan", pos1 + 1); size_t pos11 = lst.find("\"warning_high\":nan", pos1 + 1); size_t pos12 = lst.find("\"critical_low\":nan", pos1 + 1); - size_t pos13 = lst.find("\"value\":94.82", pos1 + 1); + size_t pos13 = lst.find("\"value\":94.8", pos1 + 1); size_t pos14 = lst.find("\"max\":100", pos1 + 1); size_t pos15 = lst.find( "\"metric_fields\":[\"azure\",\"insights#logicaldisk~free\"," diff --git a/broker/neb/src/acknowledgement.cc b/broker/neb/src/acknowledgement.cc index c88dacdce05..2571f12fb79 100644 --- a/broker/neb/src/acknowledgement.cc +++ b/broker/neb/src/acknowledgement.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-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 : contact@centreon.com -*/ +/** + * Copyright 2009-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 + */ #include "com/centreon/broker/neb/acknowledgement.hh" @@ -122,11 +122,12 @@ mapping::entry const acknowledgement::entries[] = { mapping::entry(&acknowledgement::acknowledgement_type, "type"), mapping::entry(&acknowledgement::author, "author", - get_acknowledgements_col_size(acknowledgements_author)), - mapping::entry( - &acknowledgement::comment, - "comment_data", - get_acknowledgements_col_size(acknowledgements_comment_data)), + get_centreon_storage_acknowledgements_col_size( + centreon_storage_acknowledgements_author)), + mapping::entry(&acknowledgement::comment, + "comment_data", + get_centreon_storage_acknowledgements_col_size( + centreon_storage_acknowledgements_comment_data)), mapping::entry(&acknowledgement::deletion_time, "deletion_time", mapping::entry::invalid_on_minus_one), diff --git a/broker/neb/src/comment.cc b/broker/neb/src/comment.cc index d9c427f7e93..a3a3969f81c 100644 --- a/broker/neb/src/comment.cc +++ b/broker/neb/src/comment.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015,2019-2020 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 2009-2013,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. + * 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 + */ #include "com/centreon/broker/neb/comment.hh" @@ -123,11 +123,13 @@ void comment::_internal_copy(comment const& other) { mapping::entry const comment::entries[] = { mapping::entry(&comment::author, "author", - get_comments_col_size(comments_author)), + get_centreon_storage_comments_col_size( + centreon_storage_comments_author)), mapping::entry(&comment::comment_type, "type"), - mapping::entry(&comment::data, - "data", - get_comments_col_size(comments_data)), + mapping::entry( + &comment::data, + "data", + get_centreon_storage_comments_col_size(centreon_storage_comments_data)), mapping::entry(&comment::deletion_time, "deletion_time", mapping::entry::invalid_on_zero), diff --git a/broker/neb/src/custom_variable.cc b/broker/neb/src/custom_variable.cc index fe69437e314..cc3968f9365 100644 --- a/broker/neb/src/custom_variable.cc +++ b/broker/neb/src/custom_variable.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2015 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 2009-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 + */ #include "com/centreon/broker/neb/custom_variable.hh" @@ -95,7 +95,8 @@ mapping::entry const custom_variable::entries[] = { mapping::entry(&custom_variable::modified, "modified"), mapping::entry(&custom_variable::name, "name", - get_customvariables_col_size(customvariables_name)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), mapping::entry(&custom_variable::service_id, "service_id", mapping::entry::invalid_on_zero), @@ -105,10 +106,12 @@ mapping::entry const custom_variable::entries[] = { mapping::entry(&custom_variable::var_type, "type"), mapping::entry(&custom_variable::value, "value", - get_customvariables_col_size(customvariables_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)), mapping::entry(&custom_variable::default_value, "default_value", - get_customvariables_col_size(customvariables_default_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_default_value)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/custom_variable_status.cc b/broker/neb/src/custom_variable_status.cc index 686665dd6d7..1aa72508232 100644 --- a/broker/neb/src/custom_variable_status.cc +++ b/broker/neb/src/custom_variable_status.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-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 : contact@centreon.com -*/ +/** + * Copyright 2009-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 + */ #include "com/centreon/broker/neb/custom_variable_status.hh" @@ -100,7 +100,8 @@ mapping::entry const custom_variable_status::entries[] = { mapping::entry(&custom_variable_status::modified, "modified"), mapping::entry(&custom_variable_status::name, "name", - get_customvariables_col_size(customvariables_name)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), mapping::entry(&custom_variable_status::service_id, "service_id", mapping::entry::invalid_on_zero), @@ -109,7 +110,8 @@ mapping::entry const custom_variable_status::entries[] = { mapping::entry::invalid_on_minus_one), mapping::entry(&custom_variable_status::value, "value", - get_customvariables_col_size(customvariables_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/downtime.cc b/broker/neb/src/downtime.cc index 71b7c54e950..317f4b1d747 100644 --- a/broker/neb/src/downtime.cc +++ b/broker/neb/src/downtime.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-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 : contact@centreon.com -*/ +/** + * Copyright 2009-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 + */ #include "com/centreon/broker/neb/downtime.hh" @@ -158,7 +158,8 @@ mapping::entry const downtime::entries[] = { mapping::entry::invalid_on_minus_one), mapping::entry(&downtime::author, "author", - get_downtimes_col_size(downtimes_author)), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author)), mapping::entry(&downtime::downtime_type, "type"), mapping::entry(&downtime::deletion_time, "deletion_time", @@ -191,7 +192,8 @@ mapping::entry const downtime::entries[] = { mapping::entry(&downtime::was_started, "started"), mapping::entry(&downtime::comment, "comment_data", - get_downtimes_col_size(downtimes_comment_data)), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data)), mapping::entry(&downtime::come_from, ""), mapping::entry()}; diff --git a/broker/neb/src/host.cc b/broker/neb/src/host.cc index b9e82d98919..c07ca756a9c 100644 --- a/broker/neb/src/host.cc +++ b/broker/neb/src/host.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/host.hh" @@ -139,20 +139,26 @@ void host::_zero_initialize() { mapping::entry const host::entries[] = { mapping::entry(&host::acknowledged, "acknowledged"), mapping::entry(&host::acknowledgement_type, "acknowledgement_type"), - mapping::entry(static_cast(&host::action_url), - "action_url", - get_hosts_col_size(hosts_action_url)), + mapping::entry( + static_cast(&host::action_url), + "action_url", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_action_url)), mapping::entry(&host::active_checks_enabled, "active_checks"), - mapping::entry(&host::address, - "address", - get_hosts_col_size(hosts_address)), - mapping::entry(&host::alias, "alias", get_hosts_col_size(hosts_alias)), + mapping::entry( + &host::address, + "address", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_address)), + mapping::entry( + &host::alias, + "alias", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_alias)), mapping::entry(static_cast(&host::check_freshness), "check_freshness"), mapping::entry(&host::check_interval, "check_interval"), mapping::entry(&host::check_period, "check_period", - get_hosts_col_size(hosts_check_period)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_period)), mapping::entry(&host::check_type, "check_type"), mapping::entry(&host::current_check_attempt, "check_attempt"), mapping::entry(&host::current_state, "state"), @@ -174,11 +180,13 @@ mapping::entry const host::entries[] = { mapping::entry(&host::downtime_depth, "scheduled_downtime_depth"), mapping::entry(static_cast(&host::display_name), "display_name", - get_hosts_col_size(hosts_display_name)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_display_name)), mapping::entry(&host::enabled, "enabled"), mapping::entry(&host::event_handler, "event_handler", - get_hosts_col_size(hosts_event_handler)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_event_handler)), mapping::entry(&host::event_handler_enabled, "event_handler_enabled"), mapping::entry(&host::execution_time, "execution_time"), mapping::entry( @@ -194,14 +202,19 @@ mapping::entry const host::entries[] = { mapping::entry(&host::has_been_checked, "checked"), mapping::entry(static_cast(&host::high_flap_threshold), "high_flap_threshold"), - mapping::entry(&host::host_name, "name", get_hosts_col_size(hosts_name)), + mapping::entry( + &host::host_name, + "name", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_name)), mapping::entry(&host::host_id, "host_id", mapping::entry::invalid_on_zero), - mapping::entry(static_cast(&host::icon_image), - "icon_image", - get_hosts_col_size(hosts_icon_image)), + mapping::entry( + static_cast(&host::icon_image), + "icon_image", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_icon_image)), mapping::entry(static_cast(&host::icon_image_alt), "icon_image_alt", - get_hosts_col_size(hosts_icon_image_alt)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_icon_image_alt)), mapping::entry(&host::poller_id, "instance_id", mapping::entry::invalid_on_zero), @@ -242,12 +255,14 @@ mapping::entry const host::entries[] = { "next_host_notification", mapping::entry::invalid_on_zero), mapping::entry(&host::no_more_notifications, "no_more_notifications"), - mapping::entry(static_cast(&host::notes), - "notes", - get_hosts_col_size(hosts_notes)), - mapping::entry(static_cast(&host::notes_url), - "notes_url", - get_hosts_col_size(hosts_notes_url)), + mapping::entry( + static_cast(&host::notes), + "notes", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_notes)), + mapping::entry( + static_cast(&host::notes_url), + "notes_url", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_notes_url)), mapping::entry(static_cast(&host::notification_interval), "notification_interval"), mapping::entry(&host::notification_number, @@ -256,7 +271,8 @@ mapping::entry const host::entries[] = { mapping::entry( static_cast(&host::notification_period), "notification_period", - get_hosts_col_size(hosts_notification_period)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_notification_period)), mapping::entry(&host::notifications_enabled, "notify"), mapping::entry(&host::notify_on_down, "notify_on_down"), mapping::entry(static_cast(&host::notify_on_downtime), @@ -276,23 +292,30 @@ mapping::entry const host::entries[] = { mapping::entry(&host::stalk_on_up, "stalk_on_up"), mapping::entry(&host::statusmap_image, "statusmap_image", - get_hosts_col_size(hosts_statusmap_image)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_statusmap_image)), mapping::entry(&host::state_type, "state_type"), mapping::entry(&host::check_command, "check_command", - get_hosts_col_size(hosts_check_command)), - mapping::entry(&host::output, "output", get_hosts_col_size(hosts_output)), - mapping::entry(&host::perf_data, - "perfdata", - get_hosts_col_size(hosts_perfdata)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_command)), + mapping::entry( + &host::output, + "output", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_output)), + mapping::entry( + &host::perf_data, + "perfdata", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_perfdata)), mapping::entry( static_cast(&host::retain_nonstatus_information), "retain_nonstatus_information"), mapping::entry(static_cast(&host::retain_status_information), "retain_status_information"), - mapping::entry(&host::timezone, - "timezone", - get_hosts_col_size(hosts_timezone)), + mapping::entry( + &host::timezone, + "timezone", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_timezone)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/host_check.cc b/broker/neb/src/host_check.cc index 0a872865af9..e590cbf3aad 100644 --- a/broker/neb/src/host_check.cc +++ b/broker/neb/src/host_check.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-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 : contact@centreon.com -*/ +/** + * Copyright 2009-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 + */ #include "com/centreon/broker/neb/host_check.hh" @@ -68,7 +68,8 @@ mapping::entry const host_check::entries[] = { mapping::entry(&host_check::next_check, ""), mapping::entry(&host_check::command_line, "command_line", - get_hosts_col_size(hosts_command_line)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_command_line)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/host_dependency.cc b/broker/neb/src/host_dependency.cc index 16269ebc353..b5d85026d80 100644 --- a/broker/neb/src/host_dependency.cc +++ b/broker/neb/src/host_dependency.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/host_dependency.hh" @@ -68,26 +68,29 @@ host_dependency& host_dependency::operator=(host_dependency const& other) { // Mapping. mapping::entry const host_dependency::entries[] = { - mapping::entry(&host_dependency::dependency_period, - "dependency_period", - get_hosts_hosts_dependencies_col_size( - hosts_hosts_dependencies_dependency_period)), + mapping::entry( + &host_dependency::dependency_period, + "dependency_period", + get_centreon_storage_hosts_hosts_dependencies_col_size( + centreon_storage_hosts_hosts_dependencies_dependency_period)), mapping::entry(&host_dependency::dependent_host_id, "dependent_host_id", mapping::entry::invalid_on_zero), mapping::entry(&host_dependency::enabled, ""), - mapping::entry(&host_dependency::execution_failure_options, - "execution_failure_options", - get_hosts_hosts_dependencies_col_size( - hosts_hosts_dependencies_execution_failure_options)), + mapping::entry( + &host_dependency::execution_failure_options, + "execution_failure_options", + get_centreon_storage_hosts_hosts_dependencies_col_size( + centreon_storage_hosts_hosts_dependencies_execution_failure_options)), mapping::entry(&host_dependency::inherits_parent, "inherits_parent"), mapping::entry(&host_dependency::host_id, "host_id", mapping::entry::invalid_on_zero), - mapping::entry(&host_dependency::notification_failure_options, - "notification_failure_options", - get_hosts_hosts_dependencies_col_size( - hosts_hosts_dependencies_notification_failure_options)), + mapping::entry( + &host_dependency::notification_failure_options, + "notification_failure_options", + get_centreon_storage_hosts_hosts_dependencies_col_size( + centreon_storage_hosts_hosts_dependencies_notification_failure_options)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/host_group.cc b/broker/neb/src/host_group.cc index 4a39779be7e..acffd51acc8 100644 --- a/broker/neb/src/host_group.cc +++ b/broker/neb/src/host_group.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/host_group.hh" @@ -71,7 +71,8 @@ mapping::entry const host_group::entries[] = { mapping::entry::invalid_on_zero), mapping::entry(&host_group::name, "name", - get_hostgroups_col_size(hostgroups_name)), + get_centreon_storage_hostgroups_col_size( + centreon_storage_hostgroups_name)), mapping::entry(&host_group::enabled, nullptr), mapping::entry(&host_group::poller_id, nullptr, diff --git a/broker/neb/src/host_status.cc b/broker/neb/src/host_status.cc index c75526ed539..85e13682652 100644 --- a/broker/neb/src/host_status.cc +++ b/broker/neb/src/host_status.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/host_status.hh" @@ -104,7 +104,8 @@ mapping::entry const host_status::entries[] = { mapping::entry(&host_status::check_interval, "check_interval"), mapping::entry(&host_status::check_period, "check_period", - get_hosts_col_size(hosts_check_period)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_period)), mapping::entry(&host_status::check_type, "check_type"), mapping::entry(&host_status::current_check_attempt, "check_attempt"), mapping::entry(&host_status::current_state, "state"), @@ -112,7 +113,8 @@ mapping::entry const host_status::entries[] = { mapping::entry(&host_status::enabled, "enabled"), mapping::entry(&host_status::event_handler, "event_handler", - get_hosts_col_size(hosts_event_handler)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_event_handler)), mapping::entry(&host_status::event_handler_enabled, "event_handler_enabled"), mapping::entry(&host_status::execution_time, "execution_time"), @@ -171,13 +173,16 @@ mapping::entry const host_status::entries[] = { mapping::entry(&host_status::state_type, "state_type"), mapping::entry(&host_status::check_command, "check_command", - get_hosts_col_size(hosts_check_command)), - mapping::entry(&host_status::output, - "output", - get_hosts_col_size(hosts_output)), - mapping::entry(&host_status::perf_data, - "perfdata", - get_hosts_col_size(hosts_perfdata)), + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_command)), + mapping::entry( + &host_status::output, + "output", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_output)), + mapping::entry( + &host_status::perf_data, + "perfdata", + get_centreon_storage_hosts_col_size(centreon_storage_hosts_perfdata)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/instance.cc b/broker/neb/src/instance.cc index 84bdfb66d5e..e49b33916d1 100644 --- a/broker/neb/src/instance.cc +++ b/broker/neb/src/instance.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/instance.hh" @@ -103,13 +103,15 @@ void instance::_internal_copy(instance const& other) { mapping::entry const instance::entries[] = { mapping::entry(&instance::engine, "engine", - get_instances_col_size(instances_engine)), + get_centreon_storage_instances_col_size( + centreon_storage_instances_engine)), mapping::entry(&instance::poller_id, "instance_id", mapping::entry::invalid_on_zero), mapping::entry(&instance::name, "name", - get_instances_col_size(instances_name)), + get_centreon_storage_instances_col_size( + centreon_storage_instances_name)), mapping::entry(&instance::is_running, "running"), mapping::entry(&instance::pid, "pid"), mapping::entry(&instance::program_end, @@ -120,7 +122,8 @@ mapping::entry const instance::entries[] = { mapping::entry::invalid_on_minus_one), mapping::entry(&instance::version, "version", - get_instances_col_size(instances_version)), + get_centreon_storage_instances_col_size( + centreon_storage_instances_version)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/instance_status.cc b/broker/neb/src/instance_status.cc index e3addbe6bf9..d6e58d14780 100644 --- a/broker/neb/src/instance_status.cc +++ b/broker/neb/src/instance_status.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/instance_status.hh" @@ -141,11 +141,13 @@ mapping::entry const instance_status::entries[] = { "passive_service_checks"), mapping::entry(&instance_status::global_host_event_handler, "global_host_event_handler", - get_instances_col_size(instances_global_host_event_handler)), + get_centreon_storage_instances_col_size( + centreon_storage_instances_global_host_event_handler)), mapping::entry( &instance_status::global_service_event_handler, "global_service_event_handler", - get_instances_col_size(instances_global_service_event_handler)), + get_centreon_storage_instances_col_size( + centreon_storage_instances_global_service_event_handler)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/log_entry.cc b/broker/neb/src/log_entry.cc index d8906565535..80ffdd595ec 100644 --- a/broker/neb/src/log_entry.cc +++ b/broker/neb/src/log_entry.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/log_entry.hh" @@ -114,12 +114,14 @@ mapping::entry const log_entry::entries[] = { mapping::entry(&log_entry::host_id, "host_id", mapping::entry::invalid_on_zero), - mapping::entry(&log_entry::host_name, - "host_name", - get_logs_col_size(logs_host_name)), + mapping::entry( + &log_entry::host_name, + "host_name", + get_centreon_storage_logs_col_size(centreon_storage_logs_host_name)), mapping::entry(&log_entry::poller_name, "instance_name", - get_logs_col_size(logs_instance_name)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name)), mapping::entry(&log_entry::issue_start_time, "", mapping::entry::invalid_on_minus_one), @@ -127,22 +129,26 @@ mapping::entry const log_entry::entries[] = { mapping::entry(&log_entry::msg_type, "msg_type"), mapping::entry(&log_entry::notification_cmd, "notification_cmd", - get_logs_col_size(logs_notification_cmd)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd)), mapping::entry(&log_entry::notification_contact, "notification_contact", - get_logs_col_size(logs_notification_contact)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact)), mapping::entry(&log_entry::retry, "retry"), mapping::entry(&log_entry::service_description, "service_description", - get_logs_col_size(logs_service_description), + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description), mapping::entry::invalid_on_zero), mapping::entry(&log_entry::service_id, "service_id", mapping::entry::invalid_on_zero), mapping::entry(&log_entry::status, "status"), - mapping::entry(&log_entry::output, - "output", - get_logs_col_size(logs_output)), + mapping::entry( + &log_entry::output, + "output", + get_centreon_storage_logs_col_size(centreon_storage_logs_output)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/service.cc b/broker/neb/src/service.cc index 4440f945bb9..4a0ec5acf55 100644 --- a/broker/neb/src/service.cc +++ b/broker/neb/src/service.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/service.hh" @@ -144,14 +144,16 @@ mapping::entry const service::entries[] = { mapping::entry(&service::acknowledgement_type, "acknowledgement_type"), mapping::entry(static_cast(&service::action_url), "action_url", - get_services_col_size(services_action_url)), + get_centreon_storage_services_col_size( + centreon_storage_services_action_url)), mapping::entry(&service::active_checks_enabled, "active_checks"), mapping::entry(static_cast(&service::check_freshness), "check_freshness"), mapping::entry(&service::check_interval, "check_interval"), mapping::entry(&service::check_period, "check_period", - get_services_col_size(services_check_period)), + get_centreon_storage_services_col_size( + centreon_storage_services_check_period)), mapping::entry(&service::check_type, "check_type"), mapping::entry(&service::current_check_attempt, "check_attempt"), mapping::entry(&service::current_state, "state"), @@ -173,11 +175,13 @@ mapping::entry const service::entries[] = { mapping::entry(&service::downtime_depth, "scheduled_downtime_depth"), mapping::entry(static_cast(&service::display_name), "display_name", - get_services_col_size(services_display_name)), + get_centreon_storage_services_col_size( + centreon_storage_services_display_name)), mapping::entry(&service::enabled, "enabled"), mapping::entry(&service::event_handler, "event_handler", - get_services_col_size(services_event_handler)), + get_centreon_storage_services_col_size( + centreon_storage_services_event_handler)), mapping::entry(&service::event_handler_enabled, "event_handler_enabled"), mapping::entry(&service::execution_time, "execution_time"), mapping::entry( @@ -204,11 +208,13 @@ mapping::entry const service::entries[] = { mapping::entry(&service::host_name, nullptr, 0), mapping::entry(static_cast(&service::icon_image), "icon_image", - get_services_col_size(services_icon_image)), + get_centreon_storage_services_col_size( + centreon_storage_services_icon_image)), mapping::entry( static_cast(&service::icon_image_alt), "icon_image_alt", - get_services_col_size(services_icon_image_alt)), + get_centreon_storage_services_col_size( + centreon_storage_services_icon_image_alt)), mapping::entry(&service::service_id, "service_id", mapping::entry::invalid_on_zero), @@ -256,10 +262,12 @@ mapping::entry const service::entries[] = { mapping::entry(&service::no_more_notifications, "no_more_notifications"), mapping::entry(static_cast(&service::notes), "notes", - get_services_col_size(services_notes)), + get_centreon_storage_services_col_size( + centreon_storage_services_notes)), mapping::entry(static_cast(&service::notes_url), "notes_url", - get_services_col_size(services_notes_url)), + get_centreon_storage_services_col_size( + centreon_storage_services_notes_url)), mapping::entry( static_cast(&service::notification_interval), "notification_interval"), @@ -269,7 +277,8 @@ mapping::entry const service::entries[] = { mapping::entry( static_cast(&service::notification_period), "notification_period", - get_services_col_size(services_notification_period)), + get_centreon_storage_services_col_size( + centreon_storage_services_notification_period)), mapping::entry(&service_status::notifications_enabled, "notify"), mapping::entry(&service::notify_on_critical, "notify_on_critical"), mapping::entry(static_cast(&service::notify_on_downtime), @@ -286,7 +295,8 @@ mapping::entry const service::entries[] = { mapping::entry(&service::retry_interval, "retry_interval"), mapping::entry(&service::service_description, "description", - get_services_col_size(services_description)), + get_centreon_storage_services_col_size( + centreon_storage_services_description)), mapping::entry(&service::should_be_scheduled, "should_be_scheduled"), mapping::entry(&service::stalk_on_critical, "stalk_on_critical"), mapping::entry(&service::stalk_on_ok, "stalk_on_ok"), @@ -295,13 +305,16 @@ mapping::entry const service::entries[] = { mapping::entry(&service::state_type, "state_type"), mapping::entry(&service::check_command, "check_command", - get_services_col_size(services_check_command)), + get_centreon_storage_services_col_size( + centreon_storage_services_check_command)), mapping::entry(&service::output, "output", - get_services_col_size(services_output)), + get_centreon_storage_services_col_size( + centreon_storage_services_output)), mapping::entry(&service::perf_data, "perfdata", - get_services_col_size(services_perfdata)), + get_centreon_storage_services_col_size( + centreon_storage_services_perfdata)), mapping::entry( static_cast(&service::retain_nonstatus_information), "retain_nonstatus_information"), diff --git a/broker/neb/src/service_check.cc b/broker/neb/src/service_check.cc index dc9f8ecee2d..0a6a1bd1d4d 100644 --- a/broker/neb/src/service_check.cc +++ b/broker/neb/src/service_check.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-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 : contact@centreon.com -*/ +/** + * Copyright 2009-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 + */ #include "com/centreon/broker/neb/service_check.hh" @@ -74,7 +74,8 @@ mapping::entry const service_check::entries[] = { mapping::entry::invalid_on_zero), mapping::entry(&service_check::command_line, "command_line", - get_services_col_size(services_command_line)), + get_centreon_storage_services_col_size( + centreon_storage_services_command_line)), mapping::entry()}; // Operations. diff --git a/broker/neb/src/service_dependency.cc b/broker/neb/src/service_dependency.cc index 94c69d81d08..cf88c2be51a 100644 --- a/broker/neb/src/service_dependency.cc +++ b/broker/neb/src/service_dependency.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/service_dependency.hh" @@ -86,10 +86,11 @@ void service_dependency::_internal_copy(service_dependency const& sd) { // Mapping. mapping::entry const service_dependency::entries[] = { - mapping::entry(&service_dependency::dependency_period, - "dependency_period", - get_services_services_dependencies_col_size( - services_services_dependencies_dependency_period)), + mapping::entry( + &service_dependency::dependency_period, + "dependency_period", + get_centreon_storage_services_services_dependencies_col_size( + centreon_storage_services_services_dependencies_dependency_period)), mapping::entry(&service_dependency::dependent_host_id, "dependent_host_id", mapping::entry::invalid_on_zero), @@ -100,8 +101,8 @@ mapping::entry const service_dependency::entries[] = { mapping::entry( &service_dependency::execution_failure_options, "execution_failure_options", - get_services_services_dependencies_col_size( - services_services_dependencies_execution_failure_options)), + get_centreon_storage_services_services_dependencies_col_size( + centreon_storage_services_services_dependencies_execution_failure_options)), mapping::entry(&service_dependency::host_id, "host_id", mapping::entry::invalid_on_zero), @@ -109,8 +110,8 @@ mapping::entry const service_dependency::entries[] = { mapping::entry( &service_dependency::notification_failure_options, "notification_failure_options", - get_services_services_dependencies_col_size( - services_services_dependencies_notification_failure_options)), + get_centreon_storage_services_services_dependencies_col_size( + centreon_storage_services_services_dependencies_notification_failure_options)), mapping::entry(&service_dependency::service_id, "service_id", mapping::entry::invalid_on_zero), diff --git a/broker/neb/src/service_group.cc b/broker/neb/src/service_group.cc index 37b4da3d9d3..4ecd23db843 100644 --- a/broker/neb/src/service_group.cc +++ b/broker/neb/src/service_group.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015 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 2009-2013,2015-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 + */ #include "com/centreon/broker/neb/service_group.hh" @@ -73,7 +73,8 @@ mapping::entry const service_group::entries[] = { mapping::entry::invalid_on_zero), mapping::entry(&service_group::name, "name", - get_servicegroups_col_size(servicegroups_name)), + get_centreon_storage_servicegroups_col_size( + centreon_storage_servicegroups_name)), mapping::entry(&service_group::enabled, nullptr), mapping::entry(&service_group::poller_id, nullptr, diff --git a/broker/neb/src/service_status.cc b/broker/neb/src/service_status.cc index bb2aab56801..f58499e1a87 100644 --- a/broker/neb/src/service_status.cc +++ b/broker/neb/src/service_status.cc @@ -1,20 +1,20 @@ -/* -** Copyright 2009-2013,2015,2019-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 : contact@centreon.com -*/ +/** + * Copyright 2009-2013,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. + * 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 + */ #include "com/centreon/broker/neb/service_status.hh" @@ -99,7 +99,8 @@ mapping::entry const service_status::entries[] = { mapping::entry(&service_status::check_interval, "check_interval"), mapping::entry(&service_status::check_period, "check_period", - get_services_col_size(services_check_period)), + get_centreon_storage_services_col_size( + centreon_storage_services_check_period)), mapping::entry(&service_status::check_type, "check_type"), mapping::entry(&service_status::current_check_attempt, "check_attempt"), mapping::entry(&service_status::current_state, "state"), @@ -107,7 +108,8 @@ mapping::entry const service_status::entries[] = { mapping::entry(&service_status::enabled, "enabled"), mapping::entry(&service_status::event_handler, "event_handler", - get_services_col_size(services_event_handler)), + get_centreon_storage_services_col_size( + centreon_storage_services_event_handler)), mapping::entry(&service_status::event_handler_enabled, "event_handler_enabled"), mapping::entry(&service_status::execution_time, "execution_time"), @@ -173,13 +175,16 @@ mapping::entry const service_status::entries[] = { mapping::entry(&service_status::state_type, "state_type"), mapping::entry(&service_status::check_command, "check_command", - get_services_col_size(services_check_command)), + get_centreon_storage_services_col_size( + centreon_storage_services_check_command)), mapping::entry(&service_status::output, "output", - get_services_col_size(services_output)), + get_centreon_storage_services_col_size( + centreon_storage_services_output)), mapping::entry(&service_status::perf_data, "perfdata", - get_services_col_size(services_perfdata)), + get_centreon_storage_services_col_size( + centreon_storage_services_perfdata)), mapping::entry()}; // Operations. diff --git a/broker/neb/test/service.cc b/broker/neb/test/service.cc index 6b759c55931..c61b113fe13 100644 --- a/broker/neb/test/service.cc +++ b/broker/neb/test/service.cc @@ -177,6 +177,7 @@ TEST_F(ServiceTest, DefaultCtor) { ASSERT_EQ(entry.get_type(), mapping::source::STRING); size_t max_len; std::string str(entry.get_string(s, &max_len)); - ASSERT_EQ(max_len, get_services_col_size(services_action_url)); + ASSERT_EQ(max_len, get_centreon_storage_services_col_size( + centreon_storage_services_action_url)); ASSERT_TRUE(str.empty()); } diff --git a/broker/storage/inc/com/centreon/broker/storage/conflict_manager.hh b/broker/storage/inc/com/centreon/broker/storage/conflict_manager.hh index a7b13a4696f..48bd3c3cb49 100644 --- a/broker/storage/inc/com/centreon/broker/storage/conflict_manager.hh +++ b/broker/storage/inc/com/centreon/broker/storage/conflict_manager.hh @@ -126,23 +126,23 @@ class conflict_manager { bool locked; uint32_t metric_id; int16_t type; - double value; + float value; std::string unit_name; - double warn; - double warn_low; + float warn; + float warn_low; bool warn_mode; - double crit; - double crit_low; + float crit; + float crit_low; bool crit_mode; - double min; - double max; + float min; + float max; bool metric_mapping_sent; }; struct metric_value { time_t c_time; uint32_t metric_id; short status; - double value; + float value; }; static void (conflict_manager::*const _neb_processing_table[])( diff --git a/broker/storage/inc/com/centreon/broker/storage/stream.hh b/broker/storage/inc/com/centreon/broker/storage/stream.hh index 63d4946877f..7006e6e27b1 100644 --- a/broker/storage/inc/com/centreon/broker/storage/stream.hh +++ b/broker/storage/inc/com/centreon/broker/storage/stream.hh @@ -49,22 +49,22 @@ class stream : public io::stream { bool locked; uint32_t metric_id; uint16_t type; - double value; + float value; std::string unit_name; - double warn; - double warn_low; + float warn; + float warn_low; bool warn_mode; - double crit; - double crit_low; + float crit; + float crit_low; bool crit_mode; - double min; - double max; + float min; + float max; }; struct metric_value { time_t c_time; uint32_t metric_id; short status; - double value; + float value; }; int32_t _pending_events; diff --git a/broker/storage/src/conflict_manager_sql.cc b/broker/storage/src/conflict_manager_sql.cc index 4fa1608ac73..fb2ca600d6d 100644 --- a/broker/storage/src/conflict_manager_sql.cc +++ b/broker/storage/src/conflict_manager_sql.cc @@ -462,15 +462,18 @@ void conflict_manager::_process_custom_variable( std::get<2>(t), fmt::format( "('{}',{},{},'{}',{},{},{},'{}')", - misc::string::escape( - cv.name, get_customvariables_col_size(customvariables_name)), + misc::string::escape(cv.name, + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), cv.host_id, cv.service_id, misc::string::escape( cv.default_value, - get_customvariables_col_size(customvariables_default_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_default_value)), cv.modified ? 1 : 0, cv.var_type, cv.update_time, - misc::string::escape(cv.value, get_customvariables_col_size( - customvariables_value)))); + misc::string::escape(cv.value, + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); /* Here, we do not update the custom variable boolean ack flag, because * it will be updated later when the bulk query will be done: * conflict_manager::_update_customvariables() */ @@ -508,13 +511,15 @@ void conflict_manager::_process_custom_variable_status( _cvs_queue.emplace_back( std::get<2>(t), - fmt::format( - "('{}',{},{},{},{},'{}')", - misc::string::escape( - cv.name, get_customvariables_col_size(customvariables_name)), - cv.host_id, cv.service_id, cv.modified ? 1 : 0, cv.update_time, - misc::string::escape( - cv.value, get_customvariables_col_size(customvariables_value)))); + fmt::format("('{}',{},{},{},{},'{}')", + misc::string::escape( + cv.name, get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), + cv.host_id, cv.service_id, cv.modified ? 1 : 0, + cv.update_time, + misc::string::escape( + cv.value, get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); log_v2::sql()->info("SQL: updating custom variable '{}' of ({}, {})", cv.name, cv.host_id, cv.service_id); @@ -558,7 +563,8 @@ void conflict_manager::_process_downtime( ? "NULL" : fmt::format("{}", dd.actual_start_time), misc::string::escape(dd.author, - get_downtimes_col_size(downtimes_author)), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author)), dd.downtime_type, dd.deletion_time.is_null() ? "NULL" : fmt::format("{}", dd.deletion_time), @@ -570,7 +576,8 @@ void conflict_manager::_process_downtime( dd.triggered_by == 0 ? "NULL" : fmt::format("{}", dd.triggered_by), dd.was_cancelled, dd.was_started, misc::string::escape( - dd.comment, get_downtimes_col_size(downtimes_comment_data)))); + dd.comment, get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data)))); } } @@ -1109,19 +1116,26 @@ void conflict_manager::_process_log( fmt::format( "({},{},{},'{}','{}',{},{},'{}','{}',{},'{}',{},'{}')", le.c_time, le.host_id, le.service_id, - misc::string::escape(le.host_name, get_logs_col_size(logs_host_name)), + misc::string::escape(le.host_name, + get_centreon_storage_logs_col_size( + centreon_storage_logs_host_name)), misc::string::escape(le.poller_name, - get_logs_col_size(logs_instance_name)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name)), le.log_type, le.msg_type, misc::string::escape(le.notification_cmd, - get_logs_col_size(logs_notification_cmd)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd)), misc::string::escape(le.notification_contact, - get_logs_col_size(logs_notification_contact)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact)), le.retry, misc::string::escape(le.service_description, - get_logs_col_size(logs_service_description)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description)), le.status, - misc::string::escape(le.output, get_logs_col_size(logs_output))))); + misc::string::escape(le.output, get_centreon_storage_logs_col_size( + centreon_storage_logs_output))))); } /** diff --git a/broker/storage/src/conflict_manager_storage.cc b/broker/storage/src/conflict_manager_storage.cc index 3128ec96b38..fd033f0581f 100644 --- a/broker/storage/src/conflict_manager_storage.cc +++ b/broker/storage/src/conflict_manager_storage.cc @@ -50,8 +50,8 @@ using namespace com::centreon::broker::storage; * * @return true if they are equal, false otherwise. */ -static inline bool check_equality(double a, double b) { - static const double eps = 0.000001; +static inline bool check_equality(float a, float b) { + static const float eps = 0.00001; if (a == b) return true; if (std::isnan(a) && std::isnan(b)) @@ -137,10 +137,12 @@ void conflict_manager::_storage_process_service_status( "special) VALUES (?,?,?,?,?,?)"); fmt::string_view hv(misc::string::truncate( - ss.host_name, get_index_data_col_size(index_data_host_name))); + ss.host_name, get_centreon_storage_index_data_col_size( + centreon_storage_index_data_host_name))); fmt::string_view sv(misc::string::truncate( ss.service_description, - get_index_data_col_size(index_data_service_description))); + get_centreon_storage_index_data_col_size( + centreon_storage_index_data_service_description))); _index_data_insert.bind_value_as_i32(0, host_id); _index_data_insert.bind_value_as_str(1, hv); _index_data_insert.bind_value_as_i32(2, service_id); @@ -327,16 +329,14 @@ void conflict_manager::_storage_process_service_status( _metric_cache[{index_id, pd.name()}] = info; } catch (const std::exception& e) { log_v2::perfdata()->error( - "conflict_manager: failed to create metric {} with type {}, " + "conflict_manager: failed to create metric '{}' with type {}, " "value {}, unit_name {}, warn {}, warn_low {}, warn_mode {}, " "crit {}, crit_low {}, crit_mode {}, min {} and max {}", - metric_id, type, pd.value(), pd.unit(), pd.warning(), + pd.name(), type, pd.value(), pd.unit(), pd.warning(), pd.warning_low(), pd.warning_mode(), pd.critical(), pd.critical_low(), pd.critical_mode(), pd.min(), pd.max()); - throw msg_fmt( - "storage: insertion of metric '{}" - "' of index {} failed: {}", - pd.name(), index_id, e.what()); + // The metric creation failed, we pass to the next metric. + continue; } } else { std::lock_guard lock(_metric_cache_m); @@ -435,7 +435,8 @@ void conflict_manager::_update_metrics() { m.emplace_back(fmt::format( "({},'{}',{},{},'{}',{},{},'{}',{},{},{})", metric->metric_id, misc::string::escape(metric->unit_name, - get_metrics_col_size(metrics_unit_name)), + get_centreon_storage_metrics_col_size( + centreon_storage_metrics_unit_name)), std::isnan(metric->warn) || std::isinf(metric->warn) ? "NULL" : fmt::format("{}", metric->warn), diff --git a/broker/storage/test/perfdata.cc b/broker/storage/test/perfdata.cc index 9bd2f953e20..58ab988a722 100644 --- a/broker/storage/test/perfdata.cc +++ b/broker/storage/test/perfdata.cc @@ -243,9 +243,9 @@ TEST_F(StorageParserParsePerfdata, Simple2) { expected.value_type(misc::perfdata::gauge); expected.value(18.0); expected.unit("%"); - expected.warning(std::numeric_limits::infinity()); + expected.warning(std::numeric_limits::infinity()); expected.warning_low(15.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(10.0); expected.min(0.0); expected.max(100.0); @@ -270,7 +270,7 @@ TEST_F(StorageParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::gauge); expected.value(2.45698); expected.unit("s"); - expected.max(std::numeric_limits::infinity()); + expected.max(std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ++it; @@ -282,7 +282,7 @@ TEST_F(StorageParserParsePerfdata, Complex1) { expected.unit("B/s"); expected.warning(5.0); expected.warning_low(0.0); - expected.min(-std::numeric_limits::infinity()); + expected.min(-std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ++it; @@ -302,7 +302,7 @@ TEST_F(StorageParserParsePerfdata, Complex1) { expected.value(1234.0); expected.warning(10.0); expected.warning_low(0.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(11.0); ASSERT_TRUE(expected == *it); ++it; @@ -313,7 +313,7 @@ TEST_F(StorageParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::counter); expected.value(1234.0); expected.warning(10.0); - expected.warning_low(-std::numeric_limits::infinity()); + expected.warning_low(-std::numeric_limits::infinity()); expected.critical(30.0); expected.critical_low(20.0); ASSERT_TRUE(expected == *it); @@ -336,10 +336,10 @@ TEST_F(StorageParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::gauge); expected.value(9.0); expected.unit("queries_per_second"); - expected.warning(std::numeric_limits::infinity()); + expected.warning(std::numeric_limits::infinity()); expected.warning_low(10.0); expected.warning_mode(true); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(5.0); expected.critical_mode(true); expected.min(0.0); @@ -454,7 +454,7 @@ TEST_F(StorageParserParsePerfdata, Complex2) { expected.value_type(misc::perfdata::gauge); expected.value(2.45698); expected.unit("s"); - expected.max(std::numeric_limits::infinity()); + expected.max(std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); ++it; @@ -467,7 +467,7 @@ TEST_F(StorageParserParsePerfdata, Complex2) { expected.unit("B/s"); expected.warning(5.0); expected.warning_low(0.0); - expected.min(-std::numeric_limits::infinity()); + expected.min(-std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); ++it; @@ -499,7 +499,7 @@ TEST_F(StorageParserParsePerfdata, Complex2) { expected.value(1234.17); expected.warning(10.0); expected.warning_low(0.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(11.0); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); @@ -511,7 +511,7 @@ TEST_F(StorageParserParsePerfdata, Complex2) { expected.value_type(misc::perfdata::counter); expected.value(1234.147); expected.warning(10.0); - expected.warning_low(-std::numeric_limits::infinity()); + expected.warning_low(-std::numeric_limits::infinity()); expected.critical(30.0); expected.critical_low(20.0); ASSERT_TRUE(expected == *it); @@ -553,7 +553,7 @@ TEST_F(StorageParserParsePerfdata, BadMetric) { int i = 1; for (auto& p : lst) { ASSERT_EQ(p.name(), fmt::format("user{}", i)); - ASSERT_EQ(p.value(), static_cast(i)); + ASSERT_EQ(p.value(), static_cast(i)); ++i; } } @@ -566,7 +566,7 @@ TEST_F(StorageParserParsePerfdata, BadMetric1) { int i = 1; for (auto& p : lst) { ASSERT_EQ(p.name(), fmt::format("user{}", i)); - ASSERT_EQ(p.value(), static_cast(i)); + ASSERT_EQ(p.value(), static_cast(i)); ++i; } } diff --git a/broker/unified_sql/inc/com/centreon/broker/unified_sql/stream.hh b/broker/unified_sql/inc/com/centreon/broker/unified_sql/stream.hh index fb11702288e..5060c41e34b 100644 --- a/broker/unified_sql/inc/com/centreon/broker/unified_sql/stream.hh +++ b/broker/unified_sql/inc/com/centreon/broker/unified_sql/stream.hh @@ -224,16 +224,16 @@ class stream : public io::stream { bool locked; uint32_t metric_id; uint32_t type; - double value; + float value; std::string unit_name; - double warn; - double warn_low; + float warn; + float warn_low; bool warn_mode; - double crit; - double crit_low; + float crit; + float crit_low; bool crit_mode; - double min; - double max; + float min; + float max; bool metric_mapping_sent; }; diff --git a/broker/unified_sql/src/stream_sql.cc b/broker/unified_sql/src/stream_sql.cc index fff816d9aad..4a2757354db 100644 --- a/broker/unified_sql/src/stream_sql.cc +++ b/broker/unified_sql/src/stream_sql.cc @@ -501,9 +501,11 @@ void stream::_process_pb_acknowledgement(const std::shared_ptr& d) { {3, "instance_id", io::protobuf_base::invalid_on_zero, 0}, {4, "type", 0, 0}, {5, "author", 0, - get_acknowledgements_col_size(acknowledgements_author)}, + get_centreon_storage_acknowledgements_col_size( + centreon_storage_acknowledgements_author)}, {6, "comment_data", 0, - get_acknowledgements_col_size(acknowledgements_comment_data)}, + get_centreon_storage_acknowledgements_col_size( + centreon_storage_acknowledgements_comment_data)}, {7, "sticky", 0, 0}, {8, "notify_contacts", 0, 0}, {9, "entry_time", 0, 0}, @@ -548,11 +550,13 @@ void stream::_process_comment(const std::shared_ptr& d) { auto binder = [&](database::mysql_bulk_bind& b) { b.set_value_as_str( 0, misc::string::escape(cmmnt.author, - get_comments_col_size(comments_author))); + get_centreon_storage_comments_col_size( + centreon_storage_comments_author))); b.set_value_as_i32(1, cmmnt.comment_type); b.set_value_as_str( 2, misc::string::escape(cmmnt.data, - get_comments_col_size(comments_data))); + get_centreon_storage_comments_col_size( + centreon_storage_comments_data))); if (cmmnt.deletion_time.is_null()) b.set_null_i64(3); else @@ -580,9 +584,11 @@ void stream::_process_comment(const std::shared_ptr& d) { _comments->add_multi_row(fmt::format( "('{}',{},'{}',{},{},{},{},{},{},{},{},{},{},{})", misc::string::escape(cmmnt.author, - get_comments_col_size(comments_author)), + get_centreon_storage_comments_col_size( + centreon_storage_comments_author)), cmmnt.comment_type, - misc::string::escape(cmmnt.data, get_comments_col_size(comments_data)), + misc::string::escape(cmmnt.data, get_centreon_storage_comments_col_size( + centreon_storage_comments_data)), cmmnt.deletion_time, cmmnt.entry_time, cmmnt.entry_type, cmmnt.expire_time, cmmnt.expires, int64_not_minus_one{cmmnt.host_id}, cmmnt.internal_id, int(cmmnt.persistent), @@ -619,15 +625,18 @@ void stream::_process_pb_custom_variable(const std::shared_ptr& d) { std::lock_guard lck(_queues_m); _cv.push_query(fmt::format( "('{}',{},{},'{}',{},{},{},'{}')", - misc::string::escape( - cv.name(), get_customvariables_col_size(customvariables_name)), + misc::string::escape(cv.name(), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), cv.host_id(), cv.service_id(), misc::string::escape( cv.default_value(), - get_customvariables_col_size(customvariables_default_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_default_value)), cv.modified() ? 1 : 0, cv.type(), cv.update_time(), - misc::string::escape( - cv.value(), get_customvariables_col_size(customvariables_value)))); + misc::string::escape(cv.value(), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); } else { int conn = special_conn::custom_variable % _mysql.connections_count(); _finish_action(-1, actions::custom_variables); @@ -666,11 +675,13 @@ void stream::_process_pb_comment(const std::shared_ptr& d) { auto binder = [&](database::mysql_bulk_bind& b) { b.set_value_as_str( 0, misc::string::escape(cmmnt.author(), - get_comments_col_size(comments_author))); + get_centreon_storage_comments_col_size( + centreon_storage_comments_author))); b.set_value_as_i32(1, int(cmmnt.type())); b.set_value_as_str( 2, misc::string::escape(cmmnt.data(), - get_comments_col_size(comments_data))); + get_centreon_storage_comments_col_size( + centreon_storage_comments_data))); b.set_value_as_i64(3, cmmnt.deletion_time(), mapping::entry::invalid_on_minus_one | mapping::entry::invalid_on_zero); @@ -695,10 +706,12 @@ void stream::_process_pb_comment(const std::shared_ptr& d) { _comments->add_multi_row(fmt::format( "('{}',{},'{}',{},{},{},{},{},{},{},{},{},{},{})", misc::string::escape(cmmnt.author(), - get_comments_col_size(comments_author)), + get_centreon_storage_comments_col_size( + centreon_storage_comments_author)), cmmnt.type(), misc::string::escape(cmmnt.data(), - get_comments_col_size(comments_data)), + get_centreon_storage_comments_col_size( + centreon_storage_comments_data)), uint64_not_null_not_neg_1{cmmnt.deletion_time()}, uint64_not_null_not_neg_1{cmmnt.entry_time()}, cmmnt.entry_type(), uint64_not_null_not_neg_1{cmmnt.expire_time()}, cmmnt.expires(), @@ -735,15 +748,18 @@ void stream::_process_custom_variable(const std::shared_ptr& d) { std::lock_guard lck(_queues_m); _cv.push_query(fmt::format( "('{}',{},{},'{}',{},{},{},'{}')", - misc::string::escape( - cv.name, get_customvariables_col_size(customvariables_name)), + misc::string::escape(cv.name, + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), cv.host_id, cv.service_id, misc::string::escape( cv.default_value, - get_customvariables_col_size(customvariables_default_value)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_default_value)), cv.modified ? 1 : 0, cv.var_type, cv.update_time, - misc::string::escape( - cv.value, get_customvariables_col_size(customvariables_value)))); + misc::string::escape(cv.value, + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); /* Here, we do not update the custom variable boolean ack flag, * because it will be updated later when the bulk query will be * done: stream::_update_customvariables() */ @@ -780,10 +796,12 @@ void stream::_process_custom_variable_status( _cvs.push_query(fmt::format( "('{}',{},{},{},{},'{}')", misc::string::escape(cv.name, - get_customvariables_col_size(customvariables_name)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), cv.host_id, cv.service_id, cv.modified ? 1 : 0, cv.update_time, - misc::string::escape( - cv.value, get_customvariables_col_size(customvariables_value)))); + misc::string::escape(cv.value, + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); SPDLOG_LOGGER_INFO(log_v2::sql(), "SQL: updating custom variable '{}' of ({}, {})", cv.name, @@ -807,11 +825,13 @@ void stream::_process_pb_custom_variable_status( _cvs.push_query(fmt::format( "('{}',{},{},{},{},'{}')", misc::string::escape(data.name(), - get_customvariables_col_size(customvariables_name)), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_name)), data.host_id(), data.service_id(), data.modified() ? 1 : 0, data.update_time(), - misc::string::escape( - data.value(), get_customvariables_col_size(customvariables_value)))); + misc::string::escape(data.value(), + get_centreon_storage_customvariables_col_size( + centreon_storage_customvariables_value)))); SPDLOG_LOGGER_INFO(log_v2::sql(), "SQL: updating custom variable '{}' of ({}, {})", @@ -855,7 +875,8 @@ void stream::_process_downtime(const std::shared_ptr& d) { b.set_value_as_i64(1, dd.actual_start_time.get_time_t()); b.set_value_as_str( 2, misc::string::escape(dd.author, - get_downtimes_col_size(downtimes_author))); + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author))); b.set_value_as_i32(3, dd.downtime_type); if (dd.deletion_time.is_null()) b.set_null_i64(4); @@ -886,8 +907,9 @@ void stream::_process_downtime(const std::shared_ptr& d) { b.set_value_as_tiny(15, int(dd.was_cancelled)); b.set_value_as_tiny(16, int(dd.was_started)); b.set_value_as_str( - 17, misc::string::escape(dd.comment, get_downtimes_col_size( - downtimes_comment_data))); + 17, misc::string::escape( + dd.comment, get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data))); b.next_row(); }; _downtimes->add_bulk_row(binder); @@ -896,13 +918,16 @@ void stream::_process_downtime(const std::shared_ptr& d) { "({},{},'{}',{},{},{},{},{},{},{},{},{},{},{},{},{},{},'{}')", dd.actual_end_time, dd.actual_start_time, misc::string::escape(dd.author, - get_downtimes_col_size(downtimes_author)), - dd.downtime_type, dd.deletion_time, dd.duration, dd.end_time, - dd.entry_time, dd.fixed, dd.host_id, dd.poller_id, dd.internal_id, - dd.service_id, dd.start_time, int64_not_minus_one{dd.triggered_by}, - dd.was_cancelled, dd.was_started, - misc::string::escape( - dd.comment, get_downtimes_col_size(downtimes_comment_data)))); + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author)), + dd.downtime_type, dd.deletion_time, dd.duration, + dd.end_time, dd.entry_time, dd.fixed, + dd.host_id, dd.poller_id, dd.internal_id, dd.service_id, + dd.start_time, int64_not_minus_one{dd.triggered_by}, dd.was_cancelled, + dd.was_started, + misc::string::escape(dd.comment, + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data)))); } } } @@ -943,7 +968,8 @@ void stream::_process_pb_downtime(const std::shared_ptr& d) { mapping::entry::invalid_on_minus_one); b.set_value_as_str( 2, misc::string::escape(dt_obj.author(), - get_downtimes_col_size(downtimes_author))); + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author))); b.set_value_as_i32(3, int(dt_obj.type())); b.set_value_as_i64(4, dt_obj.deletion_time(), mapping::entry::invalid_on_minus_one); @@ -965,10 +991,11 @@ void stream::_process_pb_downtime(const std::shared_ptr& d) { b.set_value_as_i32(14, dt_obj.triggered_by()); b.set_value_as_tiny(15, int(dt_obj.cancelled())); b.set_value_as_tiny(16, int(dt_obj.started())); - b.set_value_as_str(17, - misc::string::escape( - dt_obj.comment_data(), - get_downtimes_col_size(downtimes_comment_data))); + b.set_value_as_str( + 17, + misc::string::escape(dt_obj.comment_data(), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data))); b.next_row(); }; _downtimes->add_bulk_row(binder); @@ -978,7 +1005,8 @@ void stream::_process_pb_downtime(const std::shared_ptr& d) { uint64_not_null_not_neg_1{dt_obj.actual_end_time()}, uint64_not_null_not_neg_1{dt_obj.actual_start_time()}, misc::string::escape(dt_obj.author(), - get_downtimes_col_size(downtimes_author)), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_author)), dt_obj.type(), uint64_not_null_not_neg_1{dt_obj.deletion_time()}, dt_obj.duration(), uint64_not_null_not_neg_1{dt_obj.end_time()}, int64_not_minus_one{dt_obj.entry_time()}, dt_obj.fixed(), @@ -986,9 +1014,9 @@ void stream::_process_pb_downtime(const std::shared_ptr& d) { dt_obj.service_id(), uint64_not_null_not_neg_1{dt_obj.start_time()}, uint64_not_null{dt_obj.triggered_by()}, dt_obj.cancelled(), dt_obj.started(), - misc::string::escape( - dt_obj.comment_data(), - get_downtimes_col_size(downtimes_comment_data)))); + misc::string::escape(dt_obj.comment_data(), + get_centreon_storage_downtimes_col_size( + centreon_storage_downtimes_comment_data)))); } } } @@ -1119,7 +1147,9 @@ void stream::_process_pb_host_check(const std::shared_ptr& d) { _mysql, "hosts ", /*space is mandatory to avoid conflict with _process_host_check request*/ {{5, "host_id", io::protobuf_base::invalid_on_zero, 0}, - {4, "command_line", 0, get_hosts_col_size(hosts_command_line)}}); + {4, "command_line", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_command_line)}}); } // Processing. @@ -1590,15 +1620,19 @@ void stream::_process_pb_host(const std::shared_ptr& d) { {5, "enabled", 0, 0}, {6, "scheduled_downtime_depth", 0, 0}, {7, "check_command", 0, - get_hosts_col_size(hosts_check_command)}, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_command)}, {8, "check_interval", 0, 0}, - {9, "check_period", 0, get_hosts_col_size(hosts_check_period)}, + {9, "check_period", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_period)}, {10, "check_type", 0, 0}, {11, "check_attempt", 0, 0}, {12, "state", 0, 0}, {13, "event_handler_enabled", 0, 0}, {14, "event_handler", 0, - get_hosts_col_size(hosts_event_handler)}, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_event_handler)}, {15, "execution_time", 0, 0}, {16, "flap_detection", 0, 0}, {17, "checked", 0, 0}, @@ -1624,41 +1658,63 @@ void stream::_process_pb_host(const std::shared_ptr& d) { io::protobuf_base::invalid_on_zero, 0}, {33, "no_more_notifications", 0, 0}, {34, "notify", 0, 0}, - {35, "output", 0, get_hosts_col_size(hosts_output)}, + {35, "output", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_output)}, {36, "passive_checks", 0, 0}, {37, "percent_state_change", 0, 0}, - {38, "perfdata", 0, get_hosts_col_size(hosts_perfdata)}, + {38, "perfdata", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_perfdata)}, {39, "retry_interval", 0, 0}, {40, "should_be_scheduled", 0, 0}, {41, "obsess_over_host", 0, 0}, {42, "state_type", 0, 0}, - {43, "action_url", 0, get_hosts_col_size(hosts_action_url)}, - {44, "address", 0, get_hosts_col_size(hosts_address)}, - {45, "alias", 0, get_hosts_col_size(hosts_alias)}, + {43, "action_url", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_action_url)}, + {44, "address", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_address)}, + {45, "alias", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_alias)}, {46, "check_freshness", 0, 0}, {47, "default_active_checks", 0, 0}, {48, "default_event_handler_enabled", 0, 0}, {49, "default_flap_detection", 0, 0}, {50, "default_notify", 0, 0}, {51, "default_passive_checks", 0, 0}, - {52, "display_name", 0, get_hosts_col_size(hosts_display_name)}, + {52, "display_name", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_display_name)}, {53, "first_notification_delay", 0, 0}, {54, "flap_detection_on_down", 0, 0}, {55, "flap_detection_on_unreachable", 0, 0}, {56, "flap_detection_on_up", 0, 0}, {57, "freshness_threshold", 0, 0}, {58, "high_flap_threshold", 0, 0}, - {59, "name", 0, get_hosts_col_size(hosts_name)}, - {60, "icon_image", 0, get_hosts_col_size(hosts_icon_image)}, + {59, "name", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_name)}, + {60, "icon_image", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_icon_image)}, {61, "icon_image_alt", 0, - get_hosts_col_size(hosts_icon_image_alt)}, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_icon_image_alt)}, {62, "instance_id", mapping::entry::invalid_on_zero, 0}, {63, "low_flap_threshold", 0, 0}, - {64, "notes", 0, get_hosts_col_size(hosts_notes)}, - {65, "notes_url", 0, get_hosts_col_size(hosts_notes_url)}, + {64, "notes", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_notes)}, + {65, "notes_url", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_notes_url)}, {66, "notification_interval", 0, 0}, {67, "notification_period", 0, - get_hosts_col_size(hosts_notification_period)}, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_notification_period)}, {68, "notify_on_down", 0, 0}, {69, "notify_on_downtime", 0, 0}, {70, "notify_on_flapping", 0, 0}, @@ -1668,10 +1724,13 @@ void stream::_process_pb_host(const std::shared_ptr& d) { {74, "stalk_on_unreachable", 0, 0}, {75, "stalk_on_up", 0, 0}, {76, "statusmap_image", 0, - get_hosts_col_size(hosts_statusmap_image)}, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_statusmap_image)}, {77, "retain_nonstatus_information", 0, 0}, {78, "retain_status_information", 0, 0}, - {79, "timezone", 0, get_hosts_col_size(hosts_timezone)}, + {79, "timezone", 0, + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_timezone)}, }); if (_store_in_resources) { _resources_host_insert = _mysql.prepare_query( @@ -1749,19 +1808,26 @@ uint64_t stream::_process_pb_host_in_resources(const Host& h, int32_t conn) { if (h.enabled()) { uint64_t sid = 0; fmt::string_view name{misc::string::truncate( - h.name(), get_resources_col_size(resources_name))}; + h.name(), get_centreon_storage_resources_col_size( + centreon_storage_resources_name))}; fmt::string_view address{misc::string::truncate( - h.address(), get_resources_col_size(resources_address))}; + h.address(), get_centreon_storage_resources_col_size( + centreon_storage_resources_address))}; fmt::string_view alias{misc::string::truncate( - h.alias(), get_resources_col_size(resources_alias))}; + h.alias(), get_centreon_storage_resources_col_size( + centreon_storage_resources_alias))}; fmt::string_view parent_name{misc::string::truncate( - h.name(), get_resources_col_size(resources_parent_name))}; + h.name(), get_centreon_storage_resources_col_size( + centreon_storage_resources_parent_name))}; fmt::string_view notes_url{misc::string::truncate( - h.notes_url(), get_resources_col_size(resources_notes_url))}; + h.notes_url(), get_centreon_storage_resources_col_size( + centreon_storage_resources_notes_url))}; fmt::string_view notes{misc::string::truncate( - h.notes(), get_resources_col_size(resources_notes))}; + h.notes(), get_centreon_storage_resources_col_size( + centreon_storage_resources_notes))}; fmt::string_view action_url{misc::string::truncate( - h.action_url(), get_resources_col_size(resources_action_url))}; + h.action_url(), get_centreon_storage_resources_col_size( + centreon_storage_resources_action_url))}; // INSERT if (found == _resource_cache.end()) { @@ -2033,12 +2099,14 @@ void stream::_process_pb_adaptive_host(const std::shared_ptr& d) { query += fmt::format( " event_handler='{}',", misc::string::escape(ah.event_handler(), - get_hosts_col_size(hosts_event_handler))); + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_event_handler))); if (ah.has_check_command()) query += fmt::format( " check_command='{}',", misc::string::escape(ah.check_command(), - get_hosts_col_size(hosts_check_command))); + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_command))); if (ah.has_check_interval()) query += fmt::format(" check_interval={},", ah.check_interval()); if (ah.has_retry_interval()) @@ -2052,13 +2120,15 @@ void stream::_process_pb_adaptive_host(const std::shared_ptr& d) { query += fmt::format( " check_period='{}',", misc::string::escape(ah.check_period(), - get_hosts_col_size(hosts_check_period))); + get_centreon_storage_hosts_col_size( + centreon_storage_hosts_check_period))); if (ah.has_notification_period()) query += fmt::format(" notification_period='{}',", misc::string::escape( ah.notification_period(), - get_services_col_size(services_notification_period))); + get_centreon_storage_services_col_size( + centreon_storage_services_notification_period))); // If nothing was added to query, we can exit immediately. if (query.size() > buf.size()) { @@ -2162,10 +2232,12 @@ void stream::_process_pb_host_status(const std::shared_ptr& d) { std::string full_output{ fmt::format("{}\n{}", hscr.output(), hscr.long_output())}; size_t size = misc::string::adjust_size_utf8( - full_output, get_hosts_col_size(hosts_output)); + full_output, + get_centreon_storage_hosts_col_size(centreon_storage_hosts_output)); b->set_value_as_str(10, fmt::string_view(full_output.data(), size)); size = misc::string::adjust_size_utf8( - hscr.perfdata(), get_hosts_col_size(hosts_perfdata)); + hscr.perfdata(), get_centreon_storage_hosts_col_size( + centreon_storage_hosts_perfdata)); b->set_value_as_str(11, fmt::string_view(hscr.perfdata().data(), size)); b->set_value_as_bool(12, hscr.flapping()); b->set_value_as_f64(13, hscr.percent_state_change()); @@ -2211,11 +2283,13 @@ void stream::_process_pb_host_status(const std::shared_ptr& d) { std::string full_output{ fmt::format("{}\n{}", hscr.output(), hscr.long_output())}; size_t size = misc::string::adjust_size_utf8( - full_output, get_hosts_col_size(hosts_output)); + full_output, + get_centreon_storage_hosts_col_size(centreon_storage_hosts_output)); _hscr_update->bind_value_as_str( 10, fmt::string_view(full_output.data(), size)); size = misc::string::adjust_size_utf8( - hscr.perfdata(), get_hosts_col_size(hosts_perfdata)); + hscr.perfdata(), get_centreon_storage_hosts_col_size( + centreon_storage_hosts_perfdata)); _hscr_update->bind_value_as_str( 11, fmt::string_view(hscr.perfdata().data(), size)); _hscr_update->bind_value_as_bool(12, hscr.flapping()); @@ -2400,14 +2474,20 @@ void stream::_process_pb_instance(const std::shared_ptr& d) { query_preparator qp(neb::pb_instance::static_type(), unique); _pb_instance_insupdate = qp.prepare_insert_or_update_table( _mysql, "instances ", - {{2, "engine", 0, get_instances_col_size(instances_engine)}, + {{2, "engine", 0, + get_centreon_storage_instances_col_size( + centreon_storage_instances_engine)}, {3, "running", 0, 0}, - {4, "name", 0, get_instances_col_size(instances_name)}, + {4, "name", 0, + get_centreon_storage_instances_col_size( + centreon_storage_instances_name)}, {5, "pid", io::protobuf_base::invalid_on_zero, 0}, {6, "instance_id", io::protobuf_base::invalid_on_zero, 0}, {7, "end_time", 0, 0}, {8, "start_time", 0, 0}, - {9, "version", 0, get_instances_col_size(instances_version)}}); + {9, "version", 0, + get_centreon_storage_instances_col_size( + centreon_storage_instances_version)}}); } // Process object. @@ -2503,9 +2583,11 @@ void stream::_process_pb_instance_status(const std::shared_ptr& d) { {7, "check_hosts_freshness", 0, 0}, {8, "check_services_freshness", 0, 0}, {9, "global_host_event_handler", 0, - get_instances_col_size(instances_global_host_event_handler)}, + get_centreon_storage_instances_col_size( + centreon_storage_instances_global_host_event_handler)}, {10, "global_service_event_handler", 0, - get_instances_col_size(instances_global_service_event_handler)}, + get_centreon_storage_instances_col_size( + centreon_storage_instances_global_service_event_handler)}, {11, "last_alive", 0, 0}, {12, "last_command_check", 0, 0}, {13, "obsess_over_hosts", 0, 0}, @@ -2547,25 +2629,33 @@ void stream::_process_log(const std::shared_ptr& d) { b.set_value_as_i64(2, le.service_id); b.set_value_as_str( 3, misc::string::escape(le.host_name, - get_logs_col_size(logs_host_name))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_host_name))); b.set_value_as_str( 4, misc::string::escape(le.poller_name, - get_logs_col_size(logs_instance_name))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name))); b.set_value_as_i32(5, le.log_type); b.set_value_as_i32(6, le.msg_type); b.set_value_as_str( 7, misc::string::escape(le.notification_cmd, - get_logs_col_size(logs_notification_cmd))); - b.set_value_as_str(8, misc::string::escape( - le.notification_contact, - get_logs_col_size(logs_notification_contact))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd))); + b.set_value_as_str(8, + misc::string::escape( + le.notification_contact, + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact))); b.set_value_as_i32(9, le.retry); - b.set_value_as_str(10, misc::string::escape( - le.service_description, - get_logs_col_size(logs_service_description))); - b.set_value_as_tiny(11, le.status); b.set_value_as_str( - 12, misc::string::escape(le.output, get_logs_col_size(logs_output))); + 10, + misc::string::escape(le.service_description, + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description))); + b.set_value_as_tiny(11, le.status); + b.set_value_as_str(12, misc::string::escape( + le.output, get_centreon_storage_logs_col_size( + centreon_storage_logs_output))); b.next_row(); }; _logs->add_bulk_row(binder); @@ -2573,19 +2663,26 @@ void stream::_process_log(const std::shared_ptr& d) { _logs->add_multi_row(fmt::format( "({},{},{},'{}','{}',{},{},'{}','{}',{},'{}',{},'{}')", le.c_time, le.host_id, le.service_id, - misc::string::escape(le.host_name, get_logs_col_size(logs_host_name)), + misc::string::escape(le.host_name, + get_centreon_storage_logs_col_size( + centreon_storage_logs_host_name)), misc::string::escape(le.poller_name, - get_logs_col_size(logs_instance_name)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name)), le.log_type, le.msg_type, misc::string::escape(le.notification_cmd, - get_logs_col_size(logs_notification_cmd)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd)), misc::string::escape(le.notification_contact, - get_logs_col_size(logs_notification_contact)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact)), le.retry, misc::string::escape(le.service_description, - get_logs_col_size(logs_service_description)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description)), le.status, - misc::string::escape(le.output, get_logs_col_size(logs_output)))); + misc::string::escape(le.output, get_centreon_storage_logs_col_size( + centreon_storage_logs_output)))); } } @@ -2614,26 +2711,34 @@ void stream::_process_pb_log(const std::shared_ptr& d) { b.set_value_as_i64(2, le_obj.service_id()); b.set_value_as_str( 3, misc::string::escape(le_obj.host_name(), - get_logs_col_size(logs_host_name))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_host_name))); b.set_value_as_str( 4, misc::string::escape(le_obj.instance_name(), - get_logs_col_size(logs_instance_name))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name))); b.set_value_as_i32(5, le_obj.type()); b.set_value_as_i32(6, le_obj.msg_type()); b.set_value_as_str( 7, misc::string::escape(le_obj.notification_cmd(), - get_logs_col_size(logs_notification_cmd))); - b.set_value_as_str(8, misc::string::escape( - le_obj.notification_contact(), - get_logs_col_size(logs_notification_contact))); + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd))); + b.set_value_as_str(8, + misc::string::escape( + le_obj.notification_contact(), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact))); b.set_value_as_i32(9, le_obj.retry()); - b.set_value_as_str(10, misc::string::escape( - le_obj.service_description(), - get_logs_col_size(logs_service_description))); + b.set_value_as_str( + 10, + misc::string::escape(le_obj.service_description(), + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description))); b.set_value_as_tiny(11, le_obj.status()); - b.set_value_as_str(12, - misc::string::escape(le_obj.output(), - get_logs_col_size(logs_output))); + b.set_value_as_str( + 12, misc::string::escape(le_obj.output(), + get_centreon_storage_logs_col_size( + centreon_storage_logs_output))); b.next_row(); }; _logs->add_bulk_row(binder); @@ -2642,19 +2747,26 @@ void stream::_process_pb_log(const std::shared_ptr& d) { "({},{},{},'{}','{}',{},{},'{}','{}',{},'{}',{},'{}')", le_obj.ctime(), le_obj.host_id(), le_obj.service_id(), misc::string::escape(le_obj.host_name(), - get_logs_col_size(logs_host_name)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_host_name)), misc::string::escape(le_obj.instance_name(), - get_logs_col_size(logs_instance_name)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_instance_name)), le_obj.type(), le_obj.msg_type(), misc::string::escape(le_obj.notification_cmd(), - get_logs_col_size(logs_notification_cmd)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_cmd)), misc::string::escape(le_obj.notification_contact(), - get_logs_col_size(logs_notification_contact)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_notification_contact)), le_obj.retry(), misc::string::escape(le_obj.service_description(), - get_logs_col_size(logs_service_description)), + get_centreon_storage_logs_col_size( + centreon_storage_logs_service_description)), le_obj.status(), - misc::string::escape(le_obj.output(), get_logs_col_size(logs_output)))); + misc::string::escape( + le_obj.output(), + get_centreon_storage_logs_col_size(centreon_storage_logs_output)))); } } @@ -2784,7 +2896,8 @@ void stream::_process_pb_service_check(const std::shared_ptr& d) { {{5, "host_id", io::protobuf_base::invalid_on_zero, 0}, {7, "service_id", io::protobuf_base::invalid_on_zero, 0}, {4, "command_line", 0, - get_services_col_size(services_command_line)}}); + get_centreon_storage_services_col_size( + centreon_storage_services_command_line)}}); } // Processing. @@ -3143,16 +3256,19 @@ void stream::_process_pb_service(const std::shared_ptr& d) { {6, "enabled", 0, 0}, {7, "scheduled_downtime_depth", 0, 0}, {8, "check_command", 0, - get_services_col_size(services_check_command)}, + get_centreon_storage_services_col_size( + centreon_storage_services_check_command)}, {9, "check_interval", 0, 0}, {10, "check_period", 0, - get_services_col_size(services_check_period)}, + get_centreon_storage_services_col_size( + centreon_storage_services_check_period)}, {11, "check_type", 0, 0}, {12, "check_attempt", 0, 0}, {13, "state", 0, 0}, {14, "event_handler_enabled", 0, 0}, {15, "event_handler", 0, - get_services_col_size(services_event_handler)}, + get_centreon_storage_services_col_size( + centreon_storage_services_event_handler)}, {16, "execution_time", 0, 0}, {17, "flap_detection", 0, 0}, {18, "checked", 0, 0}, @@ -3175,19 +3291,26 @@ void stream::_process_pb_service(const std::shared_ptr& d) { {34, "next_notification", io::protobuf_base::invalid_on_zero, 0}, {35, "no_more_notifications", 0, 0}, {36, "notify", 0, 0}, - {37, "output", 0, get_services_col_size(services_output)}, + {37, "output", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_output)}, {39, "passive_checks", 0, 0}, {40, "percent_state_change", 0, 0}, - {41, "perfdata", 0, get_services_col_size(services_perfdata)}, + {41, "perfdata", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_perfdata)}, {42, "retry_interval", 0, 0}, {44, "description", 0, - get_services_col_size(services_description)}, + get_centreon_storage_services_col_size( + centreon_storage_services_description)}, {45, "should_be_scheduled", 0, 0}, {46, "obsess_over_service", 0, 0}, {47, "state_type", 0, 0}, - {48, "action_url", 0, get_services_col_size(services_action_url)}, + {48, "action_url", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_action_url)}, {49, "check_freshness", 0, 0}, {50, "default_active_checks", 0, 0}, {51, "default_event_handler_enabled", 0, 0}, @@ -3195,7 +3318,8 @@ void stream::_process_pb_service(const std::shared_ptr& d) { {53, "default_notify", 0, 0}, {54, "default_passive_checks", 0, 0}, {55, "display_name", 0, - get_services_col_size(services_display_name)}, + get_centreon_storage_services_col_size( + centreon_storage_services_display_name)}, {56, "first_notification_delay", 0, 0}, {57, "flap_detection_on_critical", 0, 0}, {58, "flap_detection_on_ok", 0, 0}, @@ -3203,16 +3327,24 @@ void stream::_process_pb_service(const std::shared_ptr& d) { {60, "flap_detection_on_warning", 0, 0}, {61, "freshness_threshold", 0, 0}, {62, "high_flap_threshold", 0, 0}, - {63, "icon_image", 0, get_services_col_size(services_icon_image)}, + {63, "icon_image", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_icon_image)}, {64, "icon_image_alt", 0, - get_services_col_size(services_icon_image_alt)}, + get_centreon_storage_services_col_size( + centreon_storage_services_icon_image_alt)}, {65, "volatile", 0, 0}, {66, "low_flap_threshold", 0, 0}, - {67, "notes", 0, get_services_col_size(services_notes)}, - {68, "notes_url", 0, get_services_col_size(services_notes_url)}, + {67, "notes", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_notes)}, + {68, "notes_url", 0, + get_centreon_storage_services_col_size( + centreon_storage_services_notes_url)}, {69, "notification_interval", 0, 0}, {70, "notification_period", 0, - get_services_col_size(services_notification_period)}, + get_centreon_storage_services_col_size( + centreon_storage_services_notification_period)}, {71, "notify_on_critical", 0, 0}, {72, "notify_on_downtime", 0, 0}, {73, "notify_on_flapping", 0, 0}, @@ -3299,15 +3431,20 @@ uint64_t stream::_process_pb_service_in_resources(const Service& s, if (s.enabled()) { uint64_t sid = 0; fmt::string_view name{misc::string::truncate( - s.display_name(), get_resources_col_size(resources_name))}; + s.display_name(), get_centreon_storage_resources_col_size( + centreon_storage_resources_name))}; fmt::string_view parent_name{misc::string::truncate( - s.host_name(), get_resources_col_size(resources_parent_name))}; + s.host_name(), get_centreon_storage_resources_col_size( + centreon_storage_resources_parent_name))}; fmt::string_view notes_url{misc::string::truncate( - s.notes_url(), get_resources_col_size(resources_notes_url))}; + s.notes_url(), get_centreon_storage_resources_col_size( + centreon_storage_resources_notes_url))}; fmt::string_view notes{misc::string::truncate( - s.notes(), get_resources_col_size(resources_notes))}; + s.notes(), get_centreon_storage_resources_col_size( + centreon_storage_resources_notes))}; fmt::string_view action_url{misc::string::truncate( - s.action_url(), get_resources_col_size(resources_action_url))}; + s.action_url(), get_centreon_storage_resources_col_size( + centreon_storage_resources_action_url))}; // INSERT if (found == _resource_cache.end()) { @@ -3581,12 +3718,14 @@ void stream::_process_pb_adaptive_service(const std::shared_ptr& d) { query += fmt::format( " event_handler='{}',", misc::string::escape(as.event_handler(), - get_services_col_size(services_event_handler))); + get_centreon_storage_services_col_size( + centreon_storage_services_event_handler))); if (as.has_check_command()) query += fmt::format( " check_command='{}',", misc::string::escape(as.check_command(), - get_services_col_size(services_check_command))); + get_centreon_storage_services_col_size( + centreon_storage_services_check_command))); if (as.has_check_interval()) query += fmt::format(" check_interval={},", as.check_interval()); if (as.has_retry_interval()) @@ -3600,13 +3739,15 @@ void stream::_process_pb_adaptive_service(const std::shared_ptr& d) { query += fmt::format( " check_period='{}',", misc::string::escape(as.check_period(), - get_services_col_size(services_check_period))); + get_centreon_storage_services_col_size( + centreon_storage_services_check_period))); if (as.has_notification_period()) query += fmt::format(" notification_period='{}',", misc::string::escape( as.notification_period(), - get_services_col_size(services_notification_period))); + get_centreon_storage_services_col_size( + centreon_storage_services_notification_period))); // If nothing was added to query, we can exit immediately. if (query.size() > buf.size()) { @@ -3659,10 +3800,11 @@ void stream::_check_and_update_index_cache(const Service& ss) { auto it_index_cache = _index_cache.find({ss.host_id(), ss.service_id()}); fmt::string_view hv(misc::string::truncate( - ss.host_name(), get_index_data_col_size(index_data_host_name))); + ss.host_name(), get_centreon_storage_index_data_col_size( + centreon_storage_index_data_host_name))); fmt::string_view sv(misc::string::truncate( - ss.description(), - get_index_data_col_size(index_data_service_description))); + ss.description(), get_centreon_storage_index_data_col_size( + centreon_storage_index_data_service_description))); bool special = ss.type() == BA; int32_t conn = @@ -3911,10 +4053,12 @@ void stream::_process_pb_service_status(const std::shared_ptr& d) { std::string full_output{ fmt::format("{}\n{}", sscr.output(), sscr.long_output())}; size_t size = misc::string::adjust_size_utf8( - full_output, get_services_col_size(services_output)); + full_output, get_centreon_storage_services_col_size( + centreon_storage_services_output)); b->set_value_as_str(11, fmt::string_view(full_output.data(), size)); size = misc::string::adjust_size_utf8( - sscr.perfdata(), get_services_col_size(services_perfdata)); + sscr.perfdata(), get_centreon_storage_services_col_size( + centreon_storage_services_perfdata)); b->set_value_as_str(12, fmt::string_view(sscr.perfdata().data(), size)); b->set_value_as_bool(13, sscr.flapping()); b->set_value_as_f64(14, sscr.percent_state_change()); @@ -3963,11 +4107,13 @@ void stream::_process_pb_service_status(const std::shared_ptr& d) { std::string full_output{ fmt::format("{}\n{}", sscr.output(), sscr.long_output())}; size_t size = misc::string::adjust_size_utf8( - full_output, get_services_col_size(services_output)); + full_output, get_centreon_storage_services_col_size( + centreon_storage_services_output)); _sscr_update->bind_value_as_str( 11, fmt::string_view(full_output.data(), size)); size = misc::string::adjust_size_utf8( - sscr.perfdata(), get_services_col_size(services_perfdata)); + sscr.perfdata(), get_centreon_storage_services_col_size( + centreon_storage_services_perfdata)); _sscr_update->bind_value_as_str( 12, fmt::string_view(sscr.perfdata().data(), size)); _sscr_update->bind_value_as_bool(13, sscr.flapping()); @@ -4003,7 +4149,7 @@ void stream::_process_pb_service_status(const std::shared_ptr& d) { int32_t conn = _mysql.choose_connection_by_instance( _cache_host_instance[static_cast(sscr.host_id())]); size_t output_size = misc::string::adjust_size_utf8( - sscr.output(), get_resources_col_size(resources_output)); + sscr.output(), get_centreon_storage_resources_col_size(centreon_storage_resources_output)); if (_bulk_prepared_statement) { std::lock_guard lck(*_sscr_resources_bind); if (!_sscr_resources_bind->bind(conn)) diff --git a/broker/unified_sql/src/stream_storage.cc b/broker/unified_sql/src/stream_storage.cc index f8c316bbb17..309176deb84 100644 --- a/broker/unified_sql/src/stream_storage.cc +++ b/broker/unified_sql/src/stream_storage.cc @@ -56,8 +56,8 @@ constexpr int32_t queue_timer_duration = 10; * * @return true if they are equal, false otherwise. */ -static inline bool check_equality(double a, double b) { - static const double eps = 0.000001; +static inline bool check_equality(float a, float b) { + static const float eps = 0.00001; if (a == b) return true; if (std::isnan(a) && std::isnan(b)) @@ -222,16 +222,15 @@ void stream::_unified_sql_process_pb_service_status( _metric_cache[{index_id, pd.name()}] = info; } catch (std::exception const& e) { log_v2::perfdata()->error( - "unified sql: failed to create metric {} with type {}, " + "unified sql: failed to create metric '{}' with type {}, " "value {}, unit_name {}, warn {}, warn_low {}, warn_mode {}, " "crit {}, crit_low {}, crit_mode {}, min {} and max {}", - metric_id, type, pd.value(), pd.unit(), pd.warning(), + pd.name(), type, pd.value(), pd.unit(), pd.warning(), pd.warning_low(), pd.warning_mode(), pd.critical(), pd.critical_low(), pd.critical_mode(), pd.min(), pd.max()); - throw msg_fmt( - "unified_sql: insertion of metric '{}" - "' of index {} failed: {}", - pd.name(), index_id, e.what()); + + // The metric creation failed, we pass to the next metric. + continue; } } else { rlck.unlock(); @@ -456,10 +455,12 @@ void stream::_unified_sql_process_service_status( _index_data_insert = _mysql.prepare_query(_index_data_insert_request); fmt::string_view hv(misc::string::truncate( - ss.host_name, get_index_data_col_size(index_data_host_name))); + ss.host_name, get_centreon_storage_index_data_col_size( + centreon_storage_index_data_host_name))); fmt::string_view sv(misc::string::truncate( ss.service_description, - get_index_data_col_size(index_data_service_description))); + get_centreon_storage_index_data_col_size( + centreon_storage_index_data_service_description))); _index_data_insert.bind_value_as_i32(0, host_id); _index_data_insert.bind_value_as_str(1, hv); _index_data_insert.bind_value_as_i32(2, service_id); @@ -592,16 +593,15 @@ void stream::_unified_sql_process_service_status( _metric_cache[{index_id, pd.name()}] = info; } catch (std::exception const& e) { log_v2::perfdata()->error( - "unified sql: failed to create metric {} with type {}, " + "unified sql: failed to create metric '{}' with type {}, " "value {}, unit_name {}, warn {}, warn_low {}, warn_mode {}, " "crit {}, crit_low {}, crit_mode {}, min {} and max {}", - metric_id, type, pd.value(), pd.unit(), pd.warning(), + pd.name(), type, pd.value(), pd.unit(), pd.warning(), pd.warning_low(), pd.warning_mode(), pd.critical(), pd.critical_low(), pd.critical_mode(), pd.min(), pd.max()); - throw msg_fmt( - "unified_sql: insertion of metric '{}" - "' of index {} failed: {}", - pd.name(), index_id, e.what()); + + // The metric creation failed, we pass to the next metric. + continue; } } else { rlck.unlock(); @@ -742,7 +742,8 @@ void stream::_update_metrics() { m.emplace_back(fmt::format( "({},'{}',{},{},'{}',{},{},'{}',{},{},{})", metric.metric_id, misc::string::escape(metric.unit_name, - get_metrics_col_size(metrics_unit_name)), + get_centreon_storage_metrics_col_size( + centreon_storage_metrics_unit_name)), std::isnan(metric.warn) || std::isinf(metric.warn) ? "NULL" : fmt::format("{}", metric.warn), diff --git a/broker/unified_sql/test/perfdata.cc b/broker/unified_sql/test/perfdata.cc index 4f117f07450..17caaec17cf 100644 --- a/broker/unified_sql/test/perfdata.cc +++ b/broker/unified_sql/test/perfdata.cc @@ -240,9 +240,9 @@ TEST_F(UnifiedSqlParserParsePerfdata, Simple2) { expected.value_type(misc::perfdata::gauge); expected.value(18.0); expected.unit("%"); - expected.warning(std::numeric_limits::infinity()); + expected.warning(std::numeric_limits::infinity()); expected.warning_low(15.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(10.0); expected.min(0.0); expected.max(100.0); @@ -266,7 +266,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::gauge); expected.value(2.45698); expected.unit("s"); - expected.max(std::numeric_limits::infinity()); + expected.max(std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ++it; @@ -278,7 +278,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex1) { expected.unit("B/s"); expected.warning(5.0); expected.warning_low(0.0); - expected.min(-std::numeric_limits::infinity()); + expected.min(-std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ++it; @@ -298,7 +298,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex1) { expected.value(1234.0); expected.warning(10.0); expected.warning_low(0.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(11.0); ASSERT_TRUE(expected == *it); ++it; @@ -309,7 +309,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::counter); expected.value(1234.0); expected.warning(10.0); - expected.warning_low(-std::numeric_limits::infinity()); + expected.warning_low(-std::numeric_limits::infinity()); expected.critical(30.0); expected.critical_low(20.0); ASSERT_TRUE(expected == *it); @@ -332,10 +332,10 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex1) { expected.value_type(misc::perfdata::gauge); expected.value(9.0); expected.unit("queries_per_second"); - expected.warning(std::numeric_limits::infinity()); + expected.warning(std::numeric_limits::infinity()); expected.warning_low(10.0); expected.warning_mode(true); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(5.0); expected.critical_mode(true); expected.min(0.0); @@ -447,7 +447,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex2) { expected.value_type(misc::perfdata::gauge); expected.value(2.45698); expected.unit("s"); - expected.max(std::numeric_limits::infinity()); + expected.max(std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); ++it; @@ -460,7 +460,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex2) { expected.unit("B/s"); expected.warning(5.0); expected.warning_low(0.0); - expected.min(-std::numeric_limits::infinity()); + expected.min(-std::numeric_limits::infinity()); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); ++it; @@ -492,7 +492,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex2) { expected.value(1234.17); expected.warning(10.0); expected.warning_low(0.0); - expected.critical(std::numeric_limits::infinity()); + expected.critical(std::numeric_limits::infinity()); expected.critical_low(11.0); ASSERT_TRUE(expected == *it); ASSERT_FALSE(expected != *it); @@ -504,7 +504,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, Complex2) { expected.value_type(misc::perfdata::counter); expected.value(1234.147); expected.warning(10.0); - expected.warning_low(-std::numeric_limits::infinity()); + expected.warning_low(-std::numeric_limits::infinity()); expected.critical(30.0); expected.critical_low(20.0); ASSERT_TRUE(expected == *it); @@ -546,7 +546,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, BadMetric) { int i = 1; for (auto& p : lst) { ASSERT_EQ(p.name(), fmt::format("user{}", i)); - ASSERT_EQ(p.value(), static_cast(i)); + ASSERT_EQ(p.value(), static_cast(i)); ++i; } } @@ -559,7 +559,7 @@ TEST_F(UnifiedSqlParserParsePerfdata, BadMetric1) { int i = 1; for (auto& p : lst) { ASSERT_EQ(p.name(), fmt::format("user{}", i)); - ASSERT_EQ(p.value(), static_cast(i)); + ASSERT_EQ(p.value(), static_cast(i)); ++i; } } diff --git a/tests/broker-engine/big-metrics.robot b/tests/broker-engine/big-metrics.robot new file mode 100644 index 00000000000..84e3176550b --- /dev/null +++ b/tests/broker-engine/big-metrics.robot @@ -0,0 +1,50 @@ +*** Settings *** +Documentation There tests are about big metric values + +Resource ../resources/import.resource + +Suite Setup Ctn Clean Before Suite +Suite Teardown Ctn Clean After Suite +Test Setup Ctn Stop Processes +Test Teardown Ctn Test Clean + + +*** Test Cases *** +EBBM1 + [Documentation] A service status contains metrics that do not fit in a float number. + [Tags] broker engine services unified_sql + Ctn Config Engine ${1} ${1} ${1} + # We want all the services to be passive to avoid parasite checks during our test. + Ctn Set Services Passive ${0} service_.* + Ctn Config Broker rrd + Ctn Config Broker central + Ctn Config Broker module ${1} + Ctn Config BBDO3 1 + Ctn Broker Config Log central core info + Ctn Broker Config Log central tcp error + Ctn Broker Config Log central sql trace + Ctn Broker Config Log central perfdata trace + Ctn Config Broker Sql Output central unified_sql + Ctn Clear Retention + ${start} Get Current Date + ${start_broker} Get Current Date + Ctn Start Broker + Ctn Start engine + Ctn Wait For Engine To Be Ready ${1} + + FOR ${i} IN RANGE ${10} + Ctn Process Service Check Result With Big Metrics + ... host_1 service_1 1 + ... Big Metrics ${10} + END + ${content} Create List + ... Out of range value for column 'current_value' + ${result} Ctn Find In Log With Timeout ${centralLog} ${start} ${content} 30 + Should Be True not ${result} It shouldn't be forbidden to store big metrics in the database. + + +*** Keywords *** +Ctn Test Clean + Ctn Stop Engine + Ctn Kindly Stop Broker + Ctn Save Logs If Failed diff --git a/tests/resources/Engine.py b/tests/resources/Engine.py index aab92662b48..ddeef2a003d 100755 --- a/tests/resources/Engine.py +++ b/tests/resources/Engine.py @@ -2769,6 +2769,33 @@ def ctn_process_service_check_result_with_metrics(hst: str, svc: str, state: int ctn_process_service_check_result(hst, svc, state, full_output, config) +def ctn_process_service_check_result_with_big_metrics(hst: str, svc: str, state: int, output: str, metrics: int, config='config0', metric_name='metric'): + """ + Send a service check result with metrics but their values are to big to fit into a float. + + Args: + hst (str): Host name of the service. + svc (str): Service description of the service. + state (int): State of the check to set. + output (str): An output message for the check. + metrics (int): The number of metrics that should appear in the result. + config (str, optional): Defaults to 'config0' (useful in case of several Engine running). + metric_name (str): The base name of metrics. They will appear followed by an integer (for example metric0, metric1, metric2, ...). + + Returns: + 0 on success. + """ + now = int(time.time()) + pd = [output + " | "] + for m in range(metrics): + mx = 3.40282e+039 + v = mx + abs(math.sin((now + m) / 1000) * 5) + pd.append(f"{metric_name}{m}={v}") + logger.trace(f"{metric_name}{m}={v}") + full_output = " ".join(pd) + ctn_process_service_check_result(hst, svc, state, full_output, config) + + def ctn_process_service_check_result(hst: str, svc: str, state: int, output: str, config='config0', use_grpc=0, nb_check=1): """ Send a service check result. From b8b21346d9d3ea01e8bb5aed89c0b8cc227526df Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:21:44 +0200 Subject: [PATCH 05/12] fix(release): use pcre to get jira_release_id (#1471) (#1475) --- .github/actions/release/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 74746c3b447..205bc442042 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -187,7 +187,7 @@ runs: JIRA_RELEASE_NAME="" JIRA_PROJECT_ID="${{ inputs.jira_project_id }}" JIRA_RELEASE_RELEASED="false" - JIRA_RELEASE_ID="$(git log |grep -E "^\s+Centreon.*#[0-9]{5,}#)" |grep -Eo "([0-9]{5,})" |head -n 1)" + JIRA_RELEASE_ID="$(git log |grep -E "Centreon\ next.*\#[0-9]{5,}\#\)" |grep -o -P "(?<=#)[0-9]{5,}(?=#)" |head -n 1)" # Create JIRA version for each released component echo "Creating JIRA releases." From 47137a6757414822400e0ac94764aea6367ce293 Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Fri, 28 Jun 2024 13:48:46 +0200 Subject: [PATCH 06/12] MON-120715-mysql-non-native-authent-and-mysql-dynamic-link-backport-23.10 (#1467) * * no native mysql authent * default mariadb plugins directory is configurable and set by default according to the os * no lib mariadb static link REFS: MON-120715 * we embed mariadb connector and caching_sha2_password.so in centreon packages --- .../docker/Dockerfile.centreon-collect-alma8 | 2 +- .../docker/Dockerfile.centreon-collect-alma9 | 2 +- ...ockerfile.centreon-collect-debian-bullseye | 2 +- .../Dockerfile.centreon-collect-mysql-alma9 | 2 +- ...ckerfile.centreon-collect-mysql-alma9-test | 2 +- .github/scripts/collect-prepare-test-robot.sh | 4 ++-- .github/scripts/collect-unit-tests.sh | 1 + .github/workflows/package-collect.yml | 2 +- broker/CMakeLists.txt | 9 ++++++++- .../centreon/broker/sql/database_config.hh | 8 ++++++++ .../centreon/broker/sql/mysql_connection.hh | 1 + broker/core/sql/src/database_config.cc | 20 ++++++++++++++----- broker/core/sql/src/mysql_connection.cc | 10 +++++++++- cmake.sh | 4 ++-- packaging/centreon-broker-core.yaml | 8 ++++++++ tests/broker-engine/big-metrics.robot | 8 +++++++- tests/mysql_docker_conf/centreon16.cnf | 1 - 17 files changed, 67 insertions(+), 19 deletions(-) diff --git a/.github/docker/Dockerfile.centreon-collect-alma8 b/.github/docker/Dockerfile.centreon-collect-alma8 index 214d7e4b353..d005048a58f 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma8 +++ b/.github/docker/Dockerfile.centreon-collect-alma8 @@ -56,7 +56,7 @@ dnf --best install -y cmake \ dnf update libarchive -pip3 install conan==1.62.0 --prefix=/usr --upgrade +pip3 install conan==1.64.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 cf4ae4073c4..09076dd7879 100644 --- a/.github/docker/Dockerfile.centreon-collect-alma9 +++ b/.github/docker/Dockerfile.centreon-collect-alma9 @@ -48,7 +48,7 @@ dnf --best install -y cmake \ nfpm \ sudo -pip3 install conan==1.62.0 --prefix=/usr --upgrade +pip3 install conan==1.64.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 ad84b3a0211..def8c861329 100644 --- a/.github/docker/Dockerfile.centreon-collect-debian-bullseye +++ b/.github/docker/Dockerfile.centreon-collect-debian-bullseye @@ -50,7 +50,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.62.0 +pip3 install conan==1.64.0 ln -s /usr/local/bin/conan /usr/bin/conan rm -rf ~/.conan/profiles/default diff --git a/.github/docker/Dockerfile.centreon-collect-mysql-alma9 b/.github/docker/Dockerfile.centreon-collect-mysql-alma9 index d548fe9c41f..068e0f781f1 100644 --- a/.github/docker/Dockerfile.centreon-collect-mysql-alma9 +++ b/.github/docker/Dockerfile.centreon-collect-mysql-alma9 @@ -48,7 +48,7 @@ dnf --best install -y cmake \ nfpm \ sudo -pip3 install conan==1.62.0 --prefix=/usr --upgrade +pip3 install conan==1.64.0 --prefix=/usr --upgrade rm -rf ~/.conan/profiles/default EOF diff --git a/.github/docker/Dockerfile.centreon-collect-mysql-alma9-test b/.github/docker/Dockerfile.centreon-collect-mysql-alma9-test index 1f8b2678089..fb460cebb36 100644 --- a/.github/docker/Dockerfile.centreon-collect-mysql-alma9-test +++ b/.github/docker/Dockerfile.centreon-collect-mysql-alma9-test @@ -41,7 +41,7 @@ dnf --best install -y gcc \ 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 cryptography cd /tmp/collect diff --git a/.github/scripts/collect-prepare-test-robot.sh b/.github/scripts/collect-prepare-test-robot.sh index e0eb711bfb3..9ad027d2257 100755 --- a/.github/scripts/collect-prepare-test-robot.sh +++ b/.github/scripts/collect-prepare-test-robot.sh @@ -30,8 +30,8 @@ if [ $database_type == 'mysql' ]; then sleep 5 echo "########################### Init centreon database ############################" - mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';" - mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED WITH mysql_native_password BY 'centreon';" + mysql -e "CREATE USER IF NOT EXISTS 'centreon'@'localhost' IDENTIFIED BY 'centreon'" + mysql -e "CREATE USER IF NOT EXISTS 'root_centreon'@'localhost' IDENTIFIED BY 'centreon'" else echo "########################### Start MariaDB ######################################" if [ "$distrib" = "ALMALINUX" ]; then diff --git a/.github/scripts/collect-unit-tests.sh b/.github/scripts/collect-unit-tests.sh index 57f7d6b11a0..ea6239a89da 100755 --- a/.github/scripts/collect-unit-tests.sh +++ b/.github/scripts/collect-unit-tests.sh @@ -13,6 +13,7 @@ else CXXFLAGS="-Wall -Wextra" cmake3 -G "Ninja" -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DWITH_CENTREON_CLIB_INCLUDE_DIR=../clib/inc/ -DWITH_CENTREON_CLIB_LIBRARIES=centreon-clib/libcentreon_clib.so -DCMAKE_BUILD_TYPE=Debug -DWITH_PREFIX=/usr -DWITH_PREFIX_BIN=/usr/sbin -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_MODULES=/usr/share/centreon/lib/centreon-broker -DWITH_PREFIX_CONF_BROKER=/etc/centreon-broker -DWITH_PREFIX_LIB_BROKER=/usr/lib64/nagios -DWITH_PREFIX_CONF_ENGINE=/etc/centreon-engine -DWITH_PREFIX_LIB_ENGINE=/usr/lib64/centreon-engine -DWITH_PREFIX_LIB_CLIB=/usr/lib64/ -DWITH_RW_DIR=/var/lib/centreon-engine/rw -DWITH_VAR_DIR=/var/log/centreon-engine -DWITH_MODULE_SIMU=On .. fi + #Build ninja -j 8 ninja -j 8 install diff --git a/.github/workflows/package-collect.yml b/.github/workflows/package-collect.yml index e30c867ba59..0c0d7a6d010 100644 --- a/.github/workflows/package-collect.yml +++ b/.github/workflows/package-collect.yml @@ -76,7 +76,7 @@ jobs: - name: Compile sources run: | - sudo pip3 install conan==1.62.0 --prefix=/usr --upgrade + sudo pip3 install conan==1.64.0 --prefix=/usr --upgrade sudo conan install . -s compiler.cppstd=17 -s compiler.libcxx=libstdc++11 --build=missing diff --git a/broker/CMakeLists.txt b/broker/CMakeLists.txt index 9462909cf3b..8b32553ef1b 100644 --- a/broker/CMakeLists.txt +++ b/broker/CMakeLists.txt @@ -66,14 +66,21 @@ endif() if(OS_DISTRIBUTOR STREQUAL "Debian" OR OS_DISTRIBUTOR STREQUAL "Ubuntu") message(STATUS "deb based os") add_definitions("-DMYSQL_SOCKET=\"/var/run/mysqld/mysqld.sock\"") + add_definitions("-DDEFAULT_MARIADB_EXTENSION_DIR=\"/usr/lib/x86_64-linux-gnu/centreon-broker\"") elseif(OS_DISTRIBUTOR STREQUAL "CentOS" OR OS_DISTRIBUTOR STREQUAL "RedHat") message(STATUS "rpm based os") add_definitions("-DMYSQL_SOCKET=\"/var/lib/mysql/mysql.sock\"") + add_definitions("-DDEFAULT_MARIADB_EXTENSION_DIR=\"/usr/lib64/centreon-broker\"") else() message(STATUS "other os: ${OS_DISTRIBUTOR}") - add_definitions("-DMYSQL_SOCKET=/tmp/mysql.sock") + add_definitions("-DMYSQL_SOCKET=\"/tmp/mysql.sock\"") + add_definitions("-DDEFAULT_MARIADB_EXTENSION_DIR=\"/usr/lib/x86_64-linux-gnu/centreon-broker\"") endif() +#we have to provide caching_sha2_password.so generated by conan in order to avoid conflicts with other versions of openssl +configure_file(${CONAN_LIB_DIRS_MARIADB-CONNECTOR-C}/plugin/caching_sha2_password.so ${CMAKE_BINARY_DIR}/lib/caching_sha2_password.so COPYONLY) + + include_directories( "${PROJECT_SOURCE_DIR}/core/inc" "${PROJECT_SOURCE_DIR}/neb/inc" diff --git a/broker/core/sql/inc/com/centreon/broker/sql/database_config.hh b/broker/core/sql/inc/com/centreon/broker/sql/database_config.hh index a03a751d1d4..a36a81e0f26 100644 --- a/broker/core/sql/inc/com/centreon/broker/sql/database_config.hh +++ b/broker/core/sql/inc/com/centreon/broker/sql/database_config.hh @@ -77,6 +77,9 @@ class database_config { int get_connections_count() const; unsigned get_max_commit_delay() const; unsigned get_category() const; + const std::string& get_extension_directory() const { + return _extension_directory; + } void set_type(std::string const& type); void set_host(std::string const& host); @@ -89,6 +92,9 @@ class database_config { void set_queries_per_transaction(int qpt); void set_check_replication(bool check_replication); void set_category(unsigned category); + void set_extension_directory(std::string const& extension_directory) { + _extension_directory = extension_directory; + } database_config auto_commit_conf() const; @@ -107,6 +113,8 @@ class database_config { int _connections_count; unsigned _max_commit_delay; unsigned _category; + // where mariadb will find extension such as caching_sha2_password.so + std::string _extension_directory; }; std::ostream& operator<<(std::ostream& s, const database_config cfg); diff --git a/broker/core/sql/inc/com/centreon/broker/sql/mysql_connection.hh b/broker/core/sql/inc/com/centreon/broker/sql/mysql_connection.hh index 965f4e7aa13..d67aebf9a5e 100644 --- a/broker/core/sql/inc/com/centreon/broker/sql/mysql_connection.hh +++ b/broker/core/sql/inc/com/centreon/broker/sql/mysql_connection.hh @@ -85,6 +85,7 @@ class mysql_connection { const std::string _pwd; const std::string _name; const int _port; + const std::string _extension_directory; const unsigned _max_second_commit_delay; time_t _last_commit; std::atomic _state; diff --git a/broker/core/sql/src/database_config.cc b/broker/core/sql/src/database_config.cc index 86a2aa60830..345c0b31b86 100644 --- a/broker/core/sql/src/database_config.cc +++ b/broker/core/sql/src/database_config.cc @@ -34,8 +34,9 @@ std::ostream& operator<<(std::ostream& s, const database_config cfg) { } s << "queries per transaction:" << cfg.get_queries_per_transaction() << " check replication:" << cfg.get_check_replication() - << " connnexion count:" << cfg.get_connections_count() - << " max comit delay:" << cfg.get_max_commit_delay() << 's'; + << " connection count:" << cfg.get_connections_count() + << " max commit delay:" << cfg.get_max_commit_delay() << 's' + << " extension_directory" << cfg.get_extension_directory(); return s; } @@ -48,7 +49,8 @@ database_config::database_config() : _queries_per_transaction(1), _check_replication(true), _connections_count(1), - _category(SHARED) {} + _category(SHARED), + _extension_directory(DEFAULT_MARIADB_EXTENSION_DIR) {} /** * Constructor. @@ -89,14 +91,16 @@ database_config::database_config(const std::string& type, _check_replication(check_replication), _connections_count(connections_count), _max_commit_delay(max_commit_delay), - _category(SHARED) {} + _category(SHARED), + _extension_directory(DEFAULT_MARIADB_EXTENSION_DIR) {} /** * Build a database configuration from a configuration set. * * @param[in] cfg Endpoint configuration. */ -database_config::database_config(config::endpoint const& cfg) { +database_config::database_config(config::endpoint const& cfg) + : _extension_directory(DEFAULT_MARIADB_EXTENSION_DIR) { std::map::const_iterator it, end; end = cfg.params.end(); @@ -208,6 +212,11 @@ database_config::database_config(config::endpoint const& cfg) { } } else _max_commit_delay = 5; + + it = cfg.params.find("extension_directory"); + if (it != end) { + _extension_directory = it->second; + } } /** @@ -552,6 +561,7 @@ void database_config::_internal_copy(database_config const& other) { _check_replication = other._check_replication; _connections_count = other._connections_count; _max_commit_delay = other._max_commit_delay; + _extension_directory = other._extension_directory; } /** diff --git a/broker/core/sql/src/mysql_connection.cc b/broker/core/sql/src/mysql_connection.cc index 516858a3fc8..78aea399801 100644 --- a/broker/core/sql/src/mysql_connection.cc +++ b/broker/core/sql/src/mysql_connection.cc @@ -14,7 +14,8 @@ * limitations under the License. * * For more information : contact@centreon.com -*/ + */ + #include #include "com/centreon/broker/config/applier/init.hh" @@ -190,6 +191,9 @@ bool mysql_connection::_try_to_reconnect() { uint32_t timeout = 10; mysql_options(_conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); + mysql_optionsv(_conn, MYSQL_PLUGIN_DIR, + (const void*)_extension_directory.c_str()); + if (!mysql_real_connect(_conn, _host.c_str(), _user.c_str(), _pwd.c_str(), _name.c_str(), _port, (_socket == "" ? nullptr : _socket.c_str()), @@ -837,6 +841,9 @@ void mysql_connection::_run() { uint32_t timeout = 10; mysql_options(_conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); + mysql_optionsv(_conn, MYSQL_PLUGIN_DIR, + (const void*)_extension_directory.c_str()); + while (config::applier::mode != config::applier::finished && !mysql_real_connect(_conn, _host.c_str(), _user.c_str(), _pwd.c_str(), _name.c_str(), _port, @@ -1081,6 +1088,7 @@ mysql_connection::mysql_connection(const database_config& db_cfg, _pwd(db_cfg.get_password()), _name(db_cfg.get_name()), _port(db_cfg.get_port()), + _extension_directory(db_cfg.get_extension_directory()), _max_second_commit_delay(db_cfg.get_max_commit_delay()), _last_commit(db_cfg.get_queries_per_transaction() > 1 ? 0 diff --git a/cmake.sh b/cmake.sh index 8a1006b533e..2228e84a99b 100755 --- a/cmake.sh +++ b/cmake.sh @@ -270,8 +270,8 @@ elif [ -r /etc/issue ] ; then fi fi -if ! pip3 install conan==1.62.0 --upgrade --break-system-packages ; then - pip3 install conan==1.62.0 --upgrade +if ! pip3 install conan==1.64.0 --upgrade --break-system-packages ; then + pip3 install conan==1.64.0 --upgrade fi if which conan ; then diff --git a/packaging/centreon-broker-core.yaml b/packaging/centreon-broker-core.yaml index f505fb4dd55..baa7efcf7ce 100644 --- a/packaging/centreon-broker-core.yaml +++ b/packaging/centreon-broker-core.yaml @@ -18,6 +18,14 @@ contents: - src: "../lib/{10-neb,15-stats,20-bam,20-storage,20-unified_sql,50-tcp,50-grpc,60-tls,70-rrd,70-lua,80-sql}.so" dst: "/usr/share/centreon/lib/centreon-broker/" + - src: "../lib/caching_sha2_password.so" + dst: "/usr/lib64/centreon-broker/caching_sha2_password.so" + packager: rpm + + - src: "../lib/caching_sha2_password.so" + dst: "/usr/lib/x86_64-linux-gnu/centreon-broker/caching_sha2_password.so" + packager: deb + - src: "../broker/script/centreon-broker.logrotate" dst: "/etc/logrotate.d/cbd" type: config|noreplace diff --git a/tests/broker-engine/big-metrics.robot b/tests/broker-engine/big-metrics.robot index 84e3176550b..a3f37a3ba75 100644 --- a/tests/broker-engine/big-metrics.robot +++ b/tests/broker-engine/big-metrics.robot @@ -1,7 +1,13 @@ *** Settings *** Documentation There tests are about big metric values -Resource ../resources/import.resource +Resource ../resources/resources.robot + +Library ../resources/Engine.py +Library ../resources/Broker.py +Library ../resources/Common.py + +Library DateTime Suite Setup Ctn Clean Before Suite Suite Teardown Ctn Clean After Suite diff --git a/tests/mysql_docker_conf/centreon16.cnf b/tests/mysql_docker_conf/centreon16.cnf index 3865e9bf923..692a1e39f6c 100644 --- a/tests/mysql_docker_conf/centreon16.cnf +++ b/tests/mysql_docker_conf/centreon16.cnf @@ -1,7 +1,6 @@ [mysqld] #mariadb conf optimized for a 16Gb ram machine port = 3306 -default-authentication-plugin=mysql_native_password max_heap_table_size=1G open_files_limit = 32000 From f8a01d210ae64aaa9ec8a636acf95f8f88993cb0 Mon Sep 17 00:00:00 2001 From: David Boucher Date: Fri, 28 Jun 2024 16:46:44 +0200 Subject: [PATCH 07/12] fix(tests): not16 is fixed (#1480) REFS: MON-124278 --- tests/broker-engine/notifications.robot | 35 +++++++++++++------------ tests/resources/engine-scripts/check.pl | 24 +++++++++++++++-- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/tests/broker-engine/notifications.robot b/tests/broker-engine/notifications.robot index 9018fc05f5c..0ba5c497b13 100644 --- a/tests/broker-engine/notifications.robot +++ b/tests/broker-engine/notifications.robot @@ -457,8 +457,11 @@ not9 Ctn Kindly Stop Broker not10 - [Documentation] This test case involves scheduling downtime on a down host that already had a critical notification.When The Host return to UP state we should receive a recovery notification. + [Documentation] This test case involves scheduling downtime on a down host that already had + ... a critical notification. When The Host return to UP state we should receive a recovery + ... notification. [Tags] broker engine host notification + Ctn Clear Commands Status Ctn Config Engine ${1} ${1} ${1} Ctn Config Notifications Ctn Config Host Command Status ${0} checkh1 2 @@ -935,9 +938,11 @@ not15 Ctn Kindly Stop Broker not16 - [Documentation] notification for a dependensies services group + [Documentation] notification for dependencies services group [Tags] broker engine services unified_sql + Ctn Clear Commands Status Ctn Config Engine ${1} ${4} ${1} + Ctn Set Services Passive ${0} service_.* Ctn Engine Config Set Value 0 interval_length 1 True Ctn Config Engine Add Cfg File ${0} servicegroups.cfg Ctn Add service Group ${0} ${1} ["host_1","service_1", "host_2","service_2"] @@ -998,17 +1003,18 @@ not16 ## Time to set the service3 to CRITICAL HARD. - ${cmd_id} Ctn Get Service Command Id ${3} - Ctn Set Command Status ${cmd_id} ${0} + ${cmd_service_1} Ctn Get Service Command Id ${1} + ${cmd_service_3} Ctn Get Service Command Id ${3} + ${cmd_service_4} Ctn Get Service Command Id ${4} + Ctn Process Service Result Hard host_3 service_3 ${0} The service_3 is OK ${result} Ctn Check Service Status With Timeout host_3 service_3 ${0} 60 HARD Should Be True ${result} Service (host_3,service_3) should be OK HARD - + ##Time to set the service3 to CRITICAL HARD. - ${cmd_id} Ctn Get Service Command Id ${3} - Ctn Set Command Status ${cmd_id} ${2} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_3 service_3 ${2} The service_3 is CRITICAL @@ -1020,8 +1026,7 @@ not16 Should Be True ${result} The notification is not sent for service3 ## Time to set the service3 to OK hard - ${cmd_id} Ctn Get Service Command Id ${3} - Ctn Set Command Status ${cmd_id} ${0} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_3 service_3 ${0} The service_3 is OK @@ -1033,8 +1038,7 @@ not16 Should Be True ${result} The notification is not sent for service3 ## Time to set the service1 to CRITICAL HARD. - ${cmd_id} Ctn Get Service Command Id ${1} - Ctn Set Command Status ${cmd_id} ${2} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_1 service_1 ${2} The service_1 is CRITICAL ${result} Ctn Check Service Status With Timeout host_1 service_1 ${2} 60 HARD @@ -1045,8 +1049,7 @@ not16 Should Be True ${result} The notification is not sent for service1 ## Time to set the service3 to CRITICAL HARD. - ${cmd_id} Ctn Get Service Command Id ${3} - Ctn Set Command Status ${cmd_id} ${2} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_3 service_3 ${2} The service_3 is CRITICAL @@ -1058,8 +1061,7 @@ not16 Should Be True ${result} The notification is sent for service3: dependency not working ## Time to set the service4 to CRITICAL HARD. - ${cmd_id} Ctn Get Service Command Id ${4} - Ctn Set Command Status ${cmd_id} ${2} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_4 service_4 ${2} The service_4 is CRITICAL @@ -1072,8 +1074,7 @@ not16 Should Be True ${result} The notification is sent for service4: dependency not working ## Time to set the service1 to OK hard - ${cmd_id} Ctn Get Service Command Id ${1} - Ctn Set Command Status ${cmd_id} ${0} + ${start} Ctn Get Round Current Date Ctn Process Service Result Hard host_1 service_1 ${0} The service_1 is OK diff --git a/tests/resources/engine-scripts/check.pl b/tests/resources/engine-scripts/check.pl index 6bfae317416..95fd52e8550 100755 --- a/tests/resources/engine-scripts/check.pl +++ b/tests/resources/engine-scripts/check.pl @@ -1,5 +1,24 @@ #!/usr/bin/perl - +# +# Copyright 2023-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 +# +# This script is a little tcp server working on port 5669. It can simulate +# a cbd instance. It is useful to test the validity of BBDO packets sent by +# centengine. use strict; use warnings; use Getopt::Long; @@ -41,9 +60,10 @@ else { if (open(FH, '<', "/tmp/states")) { while () { - if (/$id=>(.*)/) { + if (/^$id=>(.*)/) { $status = $1; chomp $status; + last; } } close FH; From cd7ad241431798f472e0a57d5883f012541b7a9b Mon Sep 17 00:00:00 2001 From: David Boucher Date: Fri, 28 Jun 2024 17:04:26 +0200 Subject: [PATCH 08/12] fix(broker): gnutls minimal version is now 3.6.0 everywhere (#1481) REFS: MON-133902 --- broker/tls/src/internal.cc | 28 +++++----------------------- broker/tls/src/stream.cc | 3 --- packaging/centreon-broker-core.yaml | 2 +- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/broker/tls/src/internal.cc b/broker/tls/src/internal.cc index 5fc09236db6..cc4d72d2e6b 100644 --- a/broker/tls/src/internal.cc +++ b/broker/tls/src/internal.cc @@ -18,12 +18,6 @@ #include -#if GNUTLS_VERSION_NUMBER < 0x030000 -#include -#include - -#include -#endif // GNU TLS < 3.0.0 #include "com/centreon/broker/io/raw.hh" #include "com/centreon/broker/io/stream.hh" #include "com/centreon/broker/log_v2.hh" @@ -56,10 +50,6 @@ unsigned char const tls::dh_params_2048[] = gnutls_dh_params_t tls::dh_params; -#if GNUTLS_VERSION_NUMBER < 0x030000 -GCRY_THREAD_OPTION_PTHREAD_IMPL; -#endif // GNU TLS < 3.0.0 - /** * Deinit the TLS library. */ @@ -81,12 +71,6 @@ void tls::initialize() { sizeof(dh_params_2048)}; int ret; - // Eventually initialize libgcrypt. -#if GNUTLS_VERSION_NUMBER < 0x030000 - log_v2::tls()->info("TLS: initializing libgcrypt (GNU TLS <= 2.11.0)"); - gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); -#endif // GNU TLS < 3.0.0 - // Initialize GNU TLS library. if (gnutls_global_init() != GNUTLS_E_SUCCESS) { log_v2::tls()->error("TLS: GNU TLS library initialization failed"); @@ -97,16 +81,14 @@ void tls::initialize() { { log_v2::tls()->info("TLS: compiled with GNU TLS version {}", GNUTLS_VERSION); - char const* v(gnutls_check_version(GNUTLS_VERSION)); + char const* v(gnutls_check_version("3.6.0")); if (!v) { log_v2::tls()->error( - "TLS: GNU TLS run-time version is incompatible with the compile-time " - "version ({}): please update your GNU TLS library", - GNUTLS_VERSION); + "TLS: The GNU TLS run-time version is older than version 3.6.0. " + "Please updgrade your GNU TLS library"); throw msg_fmt( - "TLS: GNU TLS run-time version is incompatible with the compile-time " - "version ({}): please update your GNU TLS library", - GNUTLS_VERSION); + "TLS: The GNU TLS run-time version is older than version 3.6.0. " + "Please updgrade your GNU TLS library"); } log_v2::tls()->info("TLS: loading GNU TLS version {}", v); // gnutls_global_set_log_function(log_gnutls_message); diff --git a/broker/tls/src/stream.cc b/broker/tls/src/stream.cc index b0528e8a555..01d38a02648 100644 --- a/broker/tls/src/stream.cc +++ b/broker/tls/src/stream.cc @@ -67,9 +67,6 @@ void stream::init(const params& param) { param.apply(_session); // Bind the TLS session with the stream from the lower layer. -#if GNUTLS_VERSION_NUMBER < 0x020C00 - gnutls_transport_set_lowat(*session, 0); -#endif // GNU TLS < 2.12.0 gnutls_transport_set_pull_function(_session, pull_helper); gnutls_transport_set_push_function(_session, push_helper); gnutls_transport_set_ptr(_session, this); diff --git a/packaging/centreon-broker-core.yaml b/packaging/centreon-broker-core.yaml index baa7efcf7ce..940c3ae32cd 100644 --- a/packaging/centreon-broker-core.yaml +++ b/packaging/centreon-broker-core.yaml @@ -50,7 +50,7 @@ overrides: - lua - centreon-clib = ${VERSION}-${RELEASE}${DIST} - centreon-broker = ${VERSION}-${RELEASE}${DIST} - - gnutls >= 3.3.29 + - gnutls >= 3.6.0 conflicts: - centreon-broker-storage - centreon-broker-core-devel From ee5351291ab06676077ce300e5983c44ed5c9d3b Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:59:06 +0200 Subject: [PATCH 09/12] fix(get-version): handle dev maintenance branches (#1487) (#1489) * align get-version with develop * fix(get-version): handle dev maintenance branches (#1487) * fix(get-version): handle dev maintenance branches --- .github/workflows/get-version.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/get-version.yml b/.github/workflows/get-version.yml index bf783a2923e..ea4803dcf60 100644 --- a/.github/workflows/get-version.yml +++ b/.github/workflows/get-version.yml @@ -84,11 +84,26 @@ jobs: GITHUB_RELEASE_TYPE=$(echo $BRANCHNAME |cut -d '-' -f 1) case "$BRANCHNAME" in - master | [2-9][0-9].[0-9][0-9].x) + master) + echo "release=1" >> $GITHUB_OUTPUT + echo "release_cloud=1" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT + ;; + [2-9][0-9].[0-9][0-9].x) echo "release=1" >> $GITHUB_OUTPUT echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT ;; + develop) + echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + echo "release_cloud=1" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT + ;; + dev-[2-9][0-9].[0-9][0-9].x) + echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + echo "release_cloud=0" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT + ;; release* | hotfix*) # Handle workflow_dispatch run triggers and run a dispatch ONLY for cloud release GITHUB_RELEASE_BRANCH_BASE_REF_NAME="$(gh pr view $BRANCHNAME -q .baseRefName --json headRefName,baseRefName,state)" @@ -107,7 +122,7 @@ jobs: echo "GITHUB_RELEASE_BRANCH_PR_NUMBER is: $GITHUB_RELEASE_BRANCH_PR_NUMBER" echo "GITHUB_RELEASE_CLOUD is: $GITHUB_RELEASE_CLOUD" # Github ouputs - echo "release=`echo $GITHUB_RELEASE_BRANCH_PR_NUMBER`.`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT else @@ -116,6 +131,17 @@ jobs: echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT fi ;; + prepare-release-cloud*) + # Set release cloud to 1 (0=not-cloud, 1=cloud) + GITHUB_RELEASE_CLOUD=1 + # Debug + echo "GITHUB_RELEASE_TYPE is: $GITHUB_RELEASE_TYPE" + echo "GITHUB_RELEASE_CLOUD is: $GITHUB_RELEASE_CLOUD" + # Github ouputs + echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT + echo "release_type=$GITHUB_RELEASE_TYPE" >> $GITHUB_OUTPUT + echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT + ;; *) echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT echo "release_cloud=$GITHUB_RELEASE_CLOUD" >> $GITHUB_OUTPUT From 07dac13a0fc35a043f9d6bf2aad4d855817ce7d8 Mon Sep 17 00:00:00 2001 From: pkippes <144150042+pkippes@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:22:48 +0200 Subject: [PATCH 10/12] chore(release): bump collect to 23.10.9 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f40b3b16311..608e2dde3d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,7 @@ endif() # Version. set(COLLECT_MAJOR 23) set(COLLECT_MINOR 10) -set(COLLECT_PATCH 8) +set(COLLECT_PATCH 9) set(COLLECT_VERSION "${COLLECT_MAJOR}.${COLLECT_MINOR}.${COLLECT_PATCH}") add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${COLLECT_VERSION}\") From 569ca7d69feec862500586ce7fb3dfdc6f89cce2 Mon Sep 17 00:00:00 2001 From: pkippes <144150042+pkippes@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:23:02 +0200 Subject: [PATCH 11/12] chore(release): bump collect to 23.10.9 --- .version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.version b/.version index 2ab2504ee00..c4584480e0e 100644 --- a/.version +++ b/.version @@ -1,2 +1,2 @@ MAJOR=23.10 -MINOR=8 +MINOR=9 From 72e45247b19ac87e09edb7fdcd338fcee2b29f36 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:11:37 +0200 Subject: [PATCH 12/12] enh(ci): exclude files from component workflow triggers (#1506) (#1508) * enh(ci): exclude files from component workflow triggers * remove empty line * use more generic pattern for workflow path filtering --- .github/workflows/centreon-collect.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index 921e4df3315..3b3ba71d846 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -22,6 +22,7 @@ on: - selinux/** - "!.veracode-exclusions" - "!veracode.json" + - "!**/test/**" push: branches: - develop @@ -43,6 +44,7 @@ on: - selinux/** - "!.veracode-exclusions" - "!veracode.json" + - "!**/test/**" jobs: get-version: