From af943d64605c08875d564cc37ecfa9e0988082dc Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 23 Jan 2024 07:45:10 +0100 Subject: [PATCH 01/17] Configure the monitoring of topics through the YAML Signed-off-by: tempate --- .../configuration/SpecsConfiguration.hpp | 4 ++++ .../src/cpp/YamlReader_configuration.cpp | 16 ++++++++++++++++ tools/ddsrouter_tool/src/cpp/main.cpp | 14 ++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp index 5ea94e58a..80c6ea05b 100644 --- a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp +++ b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,9 @@ struct SpecsConfiguration : public ddspipe::core::IConfiguration //! Configuration of the DDS Pipe's Log consumers. ddspipe::core::DdsPipeLogConfiguration log_configuration; + + //! TODO + ddspipe::core::MonitorTopicsConfiguration topics_monitor{}; }; } /* namespace core */ diff --git a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp index 1c3a8b8a8..889f8ae82 100644 --- a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp +++ b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -85,6 +86,21 @@ void YamlReader::fill( object.log_configuration = YamlReader::get(yml, LOG_CONFIGURATION_TAG, version); } + + ///// + // Get optional monitor tag + if (YamlReader::is_tag_present(yml, MONITOR_TAG)) + { + const auto monitor_yml = get_value_in_tag(yml, MONITOR_TAG); + + if (YamlReader::is_tag_present(monitor_yml, MONITOR_TOPICS_TAG)) + { + object.topics_monitor = YamlReader::get( + monitor_yml, + MONITOR_TOPICS_TAG, + version); + } + } } template <> diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 9a65d9fe3..0d7ab1718 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include @@ -159,6 +162,17 @@ int main( // Load XML profiles ddspipe::participants::XmlHandler::load_xml(router_configuration.xml_configuration); + // Monitoring Topics + { + ddspipe::core::Monitor::get_instance().clear_consumers(); + + static ddspipe::core::DdsMonitorConsumer consumer(router_configuration.advanced_options.topics_monitor.topic_name); + ddspipe::core::Monitor::get_instance().register_consumer(&consumer); + + static ddspipe::core::StdoutMonitorConsumer consumer2; + ddspipe::core::Monitor::get_instance().register_consumer(&consumer2); + } + // Create DDS Router core::DdsRouter router(router_configuration); From 1632055b878da61217c462c27657e82d410a73ab Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 23 Jan 2024 10:24:10 +0100 Subject: [PATCH 02/17] Replace MonitorTopicsConfiguration with MonitorConfiguration Signed-off-by: tempate --- .../configuration/SpecsConfiguration.hpp | 4 ++-- ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp | 10 +--------- tools/ddsrouter_tool/src/cpp/main.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp index 80c6ea05b..b9b34c8b2 100644 --- a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp +++ b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -77,7 +77,7 @@ struct SpecsConfiguration : public ddspipe::core::IConfiguration ddspipe::core::DdsPipeLogConfiguration log_configuration; //! TODO - ddspipe::core::MonitorTopicsConfiguration topics_monitor{}; + ddspipe::core::MonitorConfiguration monitor{}; }; } /* namespace core */ diff --git a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp index 889f8ae82..317edca68 100644 --- a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp +++ b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp @@ -91,15 +91,7 @@ void YamlReader::fill( // Get optional monitor tag if (YamlReader::is_tag_present(yml, MONITOR_TAG)) { - const auto monitor_yml = get_value_in_tag(yml, MONITOR_TAG); - - if (YamlReader::is_tag_present(monitor_yml, MONITOR_TOPICS_TAG)) - { - object.topics_monitor = YamlReader::get( - monitor_yml, - MONITOR_TOPICS_TAG, - version); - } + object.monitor = YamlReader::get(yml, MONITOR_TAG, version); } } diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 0d7ab1718..c71428d54 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -166,11 +166,11 @@ int main( { ddspipe::core::Monitor::get_instance().clear_consumers(); - static ddspipe::core::DdsMonitorConsumer consumer(router_configuration.advanced_options.topics_monitor.topic_name); - ddspipe::core::Monitor::get_instance().register_consumer(&consumer); + static ddspipe::core::DdsMonitorConsumer dds_consumer(router_configuration.advanced_options.monitor); + ddspipe::core::Monitor::get_instance().register_consumer(&dds_consumer); - static ddspipe::core::StdoutMonitorConsumer consumer2; - ddspipe::core::Monitor::get_instance().register_consumer(&consumer2); + static ddspipe::core::StdoutMonitorConsumer stdout_consumer(router_configuration.advanced_options.monitor); + ddspipe::core::Monitor::get_instance().register_consumer(&stdout_consumer); } // Create DDS Router From add33a836c436206ae7869c9a900314c79c71024 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 23 Jan 2024 15:21:12 +0100 Subject: [PATCH 03/17] Only compile the monitor module on demand Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index c71428d54..083e507f0 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -163,6 +163,7 @@ int main( ddspipe::participants::XmlHandler::load_xml(router_configuration.xml_configuration); // Monitoring Topics + #ifdef MONITOR_ENABLED { ddspipe::core::Monitor::get_instance().clear_consumers(); @@ -172,6 +173,7 @@ int main( static ddspipe::core::StdoutMonitorConsumer stdout_consumer(router_configuration.advanced_options.monitor); ddspipe::core::Monitor::get_instance().register_consumer(&stdout_consumer); } + #endif // if MONITOR_ENABLED // Create DDS Router core::DdsRouter router(router_configuration); From 983812aaf388abff88be3885cfe393fb1c3de132 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 8 Feb 2024 17:15:29 +0100 Subject: [PATCH 04/17] Refactor Signed-off-by: tempate --- .../src/cpp/YamlReader_configuration.cpp | 2 +- tools/ddsrouter_tool/src/cpp/main.cpp | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp index 317edca68..0198b769d 100644 --- a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp +++ b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 083e507f0..ed15fa815 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include #include @@ -163,17 +163,23 @@ int main( ddspipe::participants::XmlHandler::load_xml(router_configuration.xml_configuration); // Monitoring Topics - #ifdef MONITOR_ENABLED { - ddspipe::core::Monitor::get_instance().clear_consumers(); + static ddspipe::core::Monitor monitor; - static ddspipe::core::DdsMonitorConsumer dds_consumer(router_configuration.advanced_options.monitor); - ddspipe::core::Monitor::get_instance().register_consumer(&dds_consumer); + if (router_configuration.advanced_options.monitor.status.enabled) + { + auto status_producer = ddspipe::core::StatusMonitorProducer::get_instance(); + status_producer->init(router_configuration.advanced_options.monitor.status); + monitor.register_producer(status_producer); + } - static ddspipe::core::StdoutMonitorConsumer stdout_consumer(router_configuration.advanced_options.monitor); - ddspipe::core::Monitor::get_instance().register_consumer(&stdout_consumer); + if (router_configuration.advanced_options.monitor.topics.enabled) + { + auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); + topics_producer->init(router_configuration.advanced_options.monitor.topics); + monitor.register_producer(topics_producer); + } } - #endif // if MONITOR_ENABLED // Create DDS Router core::DdsRouter router(router_configuration); From 8ab6d61cb06a712914c18d0e87aa28aa400cb76d Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 9 Feb 2024 08:45:53 +0100 Subject: [PATCH 05/17] Documentation Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index 9da144832..f54256f0c 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -493,6 +493,57 @@ The type of the logs published is defined as follows: publish-type: false stdout: true +.. _user_manual_configuration_specs_monitor: + +Monitor +------- + +``specs`` supports a ``monitor`` **optional** tag to publish inside information from the |ddsrouter|. +In particular, the |ddsrouter| can monitor the frequency of the messages it receives and the number of messages lost. +The monitor can be configured to publish this information on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). +If the monitor is not enabled, the |ddsrouter| will not collect or publish any tracking data. + +.. note:: + + After publishing the data, the |ddsrouter| will reset the counters. + +The type of the data published is defined as follows: + +**Monitoring Topics** + +.. code-block:: idl + + struct DdsTopicData + { + string participant_id; + unsigned long msgs_lost; + unsigned long msgs_received; + double frequency; + }; + + struct DdsTopic + { + string name; + string data_type_name; + sequence data; + }; + + struct MonitoringTopics + { + sequence topics; + }; + +**Example of usage** + +.. code-block:: yaml + + monitor: + topics: + enable: true + domain: 11 + period: 1000 + topic-name: "DdsRouterTopicInformation" + Participant Configuration ========================= @@ -947,6 +998,13 @@ A complete example of all the configurations described on this page can be found topic-name: "DdsRouterLogs" publish-type: false stdout: true + + monitor: + topics: + enable: true + domain: 11 + period: 1000 + topic-name: "DdsRouterTopicStatistics" # XML configurations to load xml: From c8f4ca2f9c164349da510e75bd5e47def5973e41 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 9 Feb 2024 09:38:42 +0100 Subject: [PATCH 06/17] Minor improvements to the documentation Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index f54256f0c..cb9dd4da8 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -498,18 +498,20 @@ The type of the logs published is defined as follows: Monitor ------- -``specs`` supports a ``monitor`` **optional** tag to publish inside information from the |ddsrouter|. -In particular, the |ddsrouter| can monitor the frequency of the messages it receives and the number of messages lost. -The monitor can be configured to publish this information on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). -If the monitor is not enabled, the |ddsrouter| will not collect or publish any tracking data. +``specs`` supports a ``monitor`` **optional** tag to publish internal data from the |ddsrouter|. +The monitor can be configured to publish this data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). +If the monitor is not enabled, the |ddsrouter| will not collect or publish any data. .. note:: - After publishing the data, the |ddsrouter| will reset the counters. + The data published is relative to each period. + The |ddsrouter| will reset its tracked data after publishing it. + +In particular, the |ddsrouter| will track the number of messages lost, received, and the frequency of each topic. The type of the data published is defined as follows: -**Monitoring Topics** +**MonitoringTopics.idl** .. code-block:: idl @@ -542,7 +544,7 @@ The type of the data published is defined as follows: enable: true domain: 11 period: 1000 - topic-name: "DdsRouterTopicInformation" + topic-name: "DdsRouterTopicData" Participant Configuration ========================= From 2d5e005b0362bfa7ac8549cbe79efcece051526d Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 12 Feb 2024 15:41:56 +0100 Subject: [PATCH 07/17] Minor fixes Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 9 ++++++--- tools/ddsrouter_tool/src/cpp/main.cpp | 7 ------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index cb9dd4da8..c6346cad9 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -526,7 +526,10 @@ The type of the data published is defined as follows: struct DdsTopic { string name; - string data_type_name; + string type_name; + boolean type_discovered; + boolean type_mismatch; + boolean qos_mismatch; sequence data; }; @@ -542,7 +545,7 @@ The type of the data published is defined as follows: monitor: topics: enable: true - domain: 11 + domain: 10 period: 1000 topic-name: "DdsRouterTopicData" @@ -1004,7 +1007,7 @@ A complete example of all the configurations described on this page can be found monitor: topics: enable: true - domain: 11 + domain: 10 period: 1000 topic-name: "DdsRouterTopicStatistics" diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index ed15fa815..d909f841b 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -166,13 +166,6 @@ int main( { static ddspipe::core::Monitor monitor; - if (router_configuration.advanced_options.monitor.status.enabled) - { - auto status_producer = ddspipe::core::StatusMonitorProducer::get_instance(); - status_producer->init(router_configuration.advanced_options.monitor.status); - monitor.register_producer(status_producer); - } - if (router_configuration.advanced_options.monitor.topics.enabled) { auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); From 7efdb86cb472e7e83b3de5ee582a37253d35b6cd Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 12 Feb 2024 16:27:02 +0100 Subject: [PATCH 08/17] Basic docker test Signed-off-by: tempate --- ddsrouter_test/compose/CMakeLists.txt | 2 + .../compose/test_cases/monitoring/compose.yml | 51 +++++++++++++++++++ .../test_cases/monitoring/ddsrouter.yaml | 18 +++++++ 3 files changed, 71 insertions(+) create mode 100644 ddsrouter_test/compose/test_cases/monitoring/compose.yml create mode 100644 ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml diff --git a/ddsrouter_test/compose/CMakeLists.txt b/ddsrouter_test/compose/CMakeLists.txt index a88e120e2..539ec7a9a 100644 --- a/ddsrouter_test/compose/CMakeLists.txt +++ b/ddsrouter_test/compose/CMakeLists.txt @@ -68,6 +68,8 @@ set(TESTS discovery_trigger/none discovery_trigger/any/reader discovery_trigger/any/writer + + monitoring ) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_cases DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/ddsrouter_test/compose/test_cases/monitoring/compose.yml b/ddsrouter_test/compose/test_cases/monitoring/compose.yml new file mode 100644 index 000000000..f91eddcec --- /dev/null +++ b/ddsrouter_test/compose/test_cases/monitoring/compose.yml @@ -0,0 +1,51 @@ +# Test description: +# TODO +# +# Test architecture: +# +# TODO + +services: + + # ROUTER + ddsrouter: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: ddsrouter + networks: + - std_net + volumes: + - ./ddsrouter.yaml:/config.yaml + command: ddsrouter -c /config.yaml --timeout 12 + + # DOMAIN 0 + publisher_0: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: publisher_0 + networks: + - std_net + command: install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample publisher --interval 100 --samples 80 --domain 80 + + # DOMAIN 1 + subscriber_1: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: subscriber_1 + networks: + - std_net + volumes: + - ../../scripts:/scripts + command: python3 /scripts/execute_and_validate_subscriber.py --exe install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample --timeout 10 --args "--samples 80 --domain 81" + + # DOMAIN 2 + subscriber_2: + image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} + container_name: subscriber_2 + networks: + - std_net + volumes: + - ../../scripts:/scripts + command: python3 /scripts/execute_and_validate_subscriber.py --exe install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample --timeout 10 --args "--samples 8 --domain 82 --topic DdsRouterTopicData" + +networks: + std_net: + default: + driver: none diff --git a/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml b/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml new file mode 100644 index 000000000..3b1a70397 --- /dev/null +++ b/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml @@ -0,0 +1,18 @@ +version: v4.0 + +participants: + - name: Local_80 + kind: local + domain: 80 + + - name: Local_81 + kind: local + domain: 81 + +specs: + monitor: + topics: + enable: true + domain: 82 + period: 1000 + topic-name: "DdsRouterTopicData" From f43861b49c533ee5d58eba720b321b7a7bfc460d Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 13 Feb 2024 11:45:48 +0100 Subject: [PATCH 09/17] Initialize the Monitor in the right place Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index d909f841b..4dc618ba1 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -162,18 +162,6 @@ int main( // Load XML profiles ddspipe::participants::XmlHandler::load_xml(router_configuration.xml_configuration); - // Monitoring Topics - { - static ddspipe::core::Monitor monitor; - - if (router_configuration.advanced_options.monitor.topics.enabled) - { - auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); - topics_producer->init(router_configuration.advanced_options.monitor.topics); - monitor.register_producer(topics_producer); - } - } - // Create DDS Router core::DdsRouter router(router_configuration); @@ -247,6 +235,17 @@ int main( commandline_args.reload_time); } + // Monitoring + ddspipe::core::Monitor monitor; + + if (router_configuration.advanced_options.monitor.topics.enabled) + { + // Register the Topics Monitor Producer + auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); + topics_producer->init(router_configuration.advanced_options.monitor.topics); + monitor.register_producer(topics_producer); + } + // Start Router router.start(); From 37fc4d60735714e9f2a00ccf2c8836538725b370 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 4 Mar 2024 12:59:58 +0100 Subject: [PATCH 10/17] Apply DdsPipe suggestions Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 4dc618ba1..cf1453260 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -30,9 +30,21 @@ #include #include +#include +#include #include #include +#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) + #include + #include + #include +#else + #include + #include + #include +#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) + #include #include @@ -238,11 +250,23 @@ int main( // Monitoring ddspipe::core::Monitor monitor; - if (router_configuration.advanced_options.monitor.topics.enabled) + if (router_configuration.advanced_options.monitor.producers["topics"].enabled) { // Register the Topics Monitor Producer auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); - topics_producer->init(router_configuration.advanced_options.monitor.topics); + topics_producer->init(router_configuration.advanced_options.monitor.producers["topics"]); + + // Register the type object + registerMonitoringTopicsTypes(); + + // Register the type + fastdds::dds::TypeSupport type(new MonitoringTopicsPubSubType()); + + // Register the consumers + topics_producer->register_consumer(std::make_unique>()); + topics_producer->register_consumer(std::make_unique>( + router_configuration.advanced_options.monitor.consumers["topics"], type)); + monitor.register_producer(topics_producer); } From 78676cf05156dab4a03a2df72c8556c07281b41c Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 5 Mar 2024 14:42:48 +0100 Subject: [PATCH 11/17] Apply suggestions Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index cf1453260..a5cfcccbd 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -249,6 +250,7 @@ int main( // Monitoring ddspipe::core::Monitor monitor; + ddspipe::core::DdsMonitorParticipantRegistry registry; if (router_configuration.advanced_options.monitor.producers["topics"].enabled) { @@ -256,16 +258,13 @@ int main( auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); topics_producer->init(router_configuration.advanced_options.monitor.producers["topics"]); - // Register the type object - registerMonitoringTopicsTypes(); - // Register the type fastdds::dds::TypeSupport type(new MonitoringTopicsPubSubType()); // Register the consumers topics_producer->register_consumer(std::make_unique>()); topics_producer->register_consumer(std::make_unique>( - router_configuration.advanced_options.monitor.consumers["topics"], type)); + router_configuration.advanced_options.monitor.consumers["topics"], registry, type)); monitor.register_producer(topics_producer); } From 60d85de31a3e98af74d594c625b76de9a74d21e1 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 7 Mar 2024 10:43:20 +0100 Subject: [PATCH 12/17] Register participants inside the Monitor Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 33 ++------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index a5cfcccbd..84bb7ddeb 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -30,22 +30,6 @@ #include #include -#include -#include -#include -#include -#include - -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include #include @@ -249,24 +233,11 @@ int main( } // Monitoring - ddspipe::core::Monitor monitor; - ddspipe::core::DdsMonitorParticipantRegistry registry; + ddspipe::core::Monitor monitor{router_configuration.advanced_options.monitor}; if (router_configuration.advanced_options.monitor.producers["topics"].enabled) { - // Register the Topics Monitor Producer - auto topics_producer = ddspipe::core::TopicsMonitorProducer::get_instance(); - topics_producer->init(router_configuration.advanced_options.monitor.producers["topics"]); - - // Register the type - fastdds::dds::TypeSupport type(new MonitoringTopicsPubSubType()); - - // Register the consumers - topics_producer->register_consumer(std::make_unique>()); - topics_producer->register_consumer(std::make_unique>( - router_configuration.advanced_options.monitor.consumers["topics"], registry, type)); - - monitor.register_producer(topics_producer); + monitor.monitorize_topics(); } // Start Router From bcaf8e9d2a8222287125a881bfc7bb4d9080a8ac Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 8 Mar 2024 10:31:47 +0100 Subject: [PATCH 13/17] Rename frequency to msg_rx_rate Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index c6346cad9..b0c742ca9 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -520,7 +520,7 @@ The type of the data published is defined as follows: string participant_id; unsigned long msgs_lost; unsigned long msgs_received; - double frequency; + double msg_rx_rate; }; struct DdsTopic @@ -1003,7 +1003,7 @@ A complete example of all the configurations described on this page can be found topic-name: "DdsRouterLogs" publish-type: false stdout: true - + monitor: topics: enable: true From dd4cd339a6036e77b3b9a7cf50ed7d558e16e229 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 12 Mar 2024 14:53:06 +0100 Subject: [PATCH 14/17] Replace monitorize with monitor Signed-off-by: tempate --- tools/ddsrouter_tool/src/cpp/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 84bb7ddeb..27ec0e0a7 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -237,7 +237,7 @@ int main( if (router_configuration.advanced_options.monitor.producers["topics"].enabled) { - monitor.monitorize_topics(); + monitor.monitor_topics(); } // Start Router From d38439b6c70c7af699009a43ae6c4438ae17355b Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 19 Mar 2024 08:27:21 +0100 Subject: [PATCH 15/17] Apply suggestions Signed-off-by: tempate --- .../configuration/SpecsConfiguration.hpp | 4 +- ddsrouter_test/compose/CMakeLists.txt | 2 - .../compose/test_cases/monitoring/compose.yml | 51 ------------------- .../test_cases/monitoring/ddsrouter.yaml | 18 ------- .../src/cpp/YamlReader_configuration.cpp | 2 +- docs/rst/notes/forthcoming_version.rst | 7 ++- docs/rst/user_manual/configuration.rst | 6 +-- tools/ddsrouter_tool/src/cpp/main.cpp | 8 +-- 8 files changed, 17 insertions(+), 81 deletions(-) delete mode 100644 ddsrouter_test/compose/test_cases/monitoring/compose.yml delete mode 100644 ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml diff --git a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp index b9b34c8b2..7839188cf 100644 --- a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp +++ b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp @@ -76,8 +76,8 @@ struct SpecsConfiguration : public ddspipe::core::IConfiguration //! Configuration of the DDS Pipe's Log consumers. ddspipe::core::DdsPipeLogConfiguration log_configuration; - //! TODO - ddspipe::core::MonitorConfiguration monitor{}; + //! Configuration of the DDS Pipe's Monitor. + ddspipe::core::MonitorConfiguration monitor_configuration{}; }; } /* namespace core */ diff --git a/ddsrouter_test/compose/CMakeLists.txt b/ddsrouter_test/compose/CMakeLists.txt index 539ec7a9a..a88e120e2 100644 --- a/ddsrouter_test/compose/CMakeLists.txt +++ b/ddsrouter_test/compose/CMakeLists.txt @@ -68,8 +68,6 @@ set(TESTS discovery_trigger/none discovery_trigger/any/reader discovery_trigger/any/writer - - monitoring ) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_cases DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/ddsrouter_test/compose/test_cases/monitoring/compose.yml b/ddsrouter_test/compose/test_cases/monitoring/compose.yml deleted file mode 100644 index f91eddcec..000000000 --- a/ddsrouter_test/compose/test_cases/monitoring/compose.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Test description: -# TODO -# -# Test architecture: -# -# TODO - -services: - - # ROUTER - ddsrouter: - image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} - container_name: ddsrouter - networks: - - std_net - volumes: - - ./ddsrouter.yaml:/config.yaml - command: ddsrouter -c /config.yaml --timeout 12 - - # DOMAIN 0 - publisher_0: - image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} - container_name: publisher_0 - networks: - - std_net - command: install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample publisher --interval 100 --samples 80 --domain 80 - - # DOMAIN 1 - subscriber_1: - image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} - container_name: subscriber_1 - networks: - - std_net - volumes: - - ../../scripts:/scripts - command: python3 /scripts/execute_and_validate_subscriber.py --exe install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample --timeout 10 --args "--samples 80 --domain 81" - - # DOMAIN 2 - subscriber_2: - image: ${DDSROUTER_COMPOSE_TEST_DOCKER_IMAGE} - container_name: subscriber_2 - networks: - - std_net - volumes: - - ../../scripts:/scripts - command: python3 /scripts/execute_and_validate_subscriber.py --exe install/AdvancedConfigurationExample/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationExample --timeout 10 --args "--samples 8 --domain 82 --topic DdsRouterTopicData" - -networks: - std_net: - default: - driver: none diff --git a/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml b/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml deleted file mode 100644 index 3b1a70397..000000000 --- a/ddsrouter_test/compose/test_cases/monitoring/ddsrouter.yaml +++ /dev/null @@ -1,18 +0,0 @@ -version: v4.0 - -participants: - - name: Local_80 - kind: local - domain: 80 - - - name: Local_81 - kind: local - domain: 81 - -specs: - monitor: - topics: - enable: true - domain: 82 - period: 1000 - topic-name: "DdsRouterTopicData" diff --git a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp index 0198b769d..dd83e4856 100644 --- a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp +++ b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp @@ -91,7 +91,7 @@ void YamlReader::fill( // Get optional monitor tag if (YamlReader::is_tag_present(yml, MONITOR_TAG)) { - object.monitor = YamlReader::get(yml, MONITOR_TAG, version); + object.monitor_configuration = YamlReader::get(yml, MONITOR_TAG, version); } } diff --git a/docs/rst/notes/forthcoming_version.rst b/docs/rst/notes/forthcoming_version.rst index 64fdd5761..0d0a40550 100644 --- a/docs/rst/notes/forthcoming_version.rst +++ b/docs/rst/notes/forthcoming_version.rst @@ -6,6 +6,11 @@ Forthcoming Version ################### -This release will include the following **Configuration features**: +The next release will include the following **Features**: + +* Publish the :ref:`Logs `. +* :ref:`Monitor `. + +The next release will include the following **Configuration features**: * New configuration option ``logging`` to configure the :ref:`Logs `. diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index b0c742ca9..df8dfa140 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -499,7 +499,7 @@ Monitor ------- ``specs`` supports a ``monitor`` **optional** tag to publish internal data from the |ddsrouter|. -The monitor can be configured to publish this data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). +The monitor publishes (and logs) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). If the monitor is not enabled, the |ddsrouter| will not collect or publish any data. .. note:: @@ -545,8 +545,8 @@ The type of the data published is defined as follows: monitor: topics: enable: true - domain: 10 period: 1000 + domain: 10 topic-name: "DdsRouterTopicData" Participant Configuration @@ -1007,8 +1007,8 @@ A complete example of all the configurations described on this page can be found monitor: topics: enable: true - domain: 10 period: 1000 + domain: 10 topic-name: "DdsRouterTopicStatistics" # XML configurations to load diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 27ec0e0a7..fd3834203 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -232,10 +233,11 @@ int main( commandline_args.reload_time); } - // Monitoring - ddspipe::core::Monitor monitor{router_configuration.advanced_options.monitor}; + // Monitor + auto monitor_configuration = router_configuration.advanced_options.monitor_configuration; + ddspipe::core::Monitor monitor{monitor_configuration}; - if (router_configuration.advanced_options.monitor.producers["topics"].enabled) + if (monitor_configuration.producers[ddspipe::core::TOPICS_MONITOR_PRODUCER_ID].enabled) { monitor.monitor_topics(); } From 61d51a6ccd0cab42f4e4a505e4a489ab54d3034b Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 19 Mar 2024 15:46:03 +0100 Subject: [PATCH 16/17] Apply suggestions Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index df8dfa140..2b95b66e7 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -499,7 +499,7 @@ Monitor ------- ``specs`` supports a ``monitor`` **optional** tag to publish internal data from the |ddsrouter|. -The monitor publishes (and logs) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). +If the monitor is enabled, it publishes (and logs) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). If the monitor is not enabled, the |ddsrouter| will not collect or publish any data. .. note:: @@ -508,7 +508,7 @@ If the monitor is not enabled, the |ddsrouter| will not collect or publish any d The |ddsrouter| will reset its tracked data after publishing it. -In particular, the |ddsrouter| will track the number of messages lost, received, and the frequency of each topic. +In particular, the |ddsrouter| will track the number of messages lost, received, and the message reception rate [Hz] of each topic. The type of the data published is defined as follows: **MonitoringTopics.idl** From ac92f9b07367e6cad7a1ce8c7cc08c157691bff2 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 19 Mar 2024 16:15:00 +0100 Subject: [PATCH 17/17] Apply suggestions Signed-off-by: tempate --- docs/rst/user_manual/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index 2b95b66e7..16580b726 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -499,7 +499,7 @@ Monitor ------- ``specs`` supports a ``monitor`` **optional** tag to publish internal data from the |ddsrouter|. -If the monitor is enabled, it publishes (and logs) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). +If the monitor is enabled, it publishes (and logs under the ``MONITOR_DATA`` :ref:`log filter `) the *DDS Router's* internal data on a ``domain``, under a ``topic-name``, once every ``period`` (in milliseconds). If the monitor is not enabled, the |ddsrouter| will not collect or publish any data. .. note::