diff --git a/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp b/ddsrouter_core/include/ddsrouter_core/configuration/SpecsConfiguration.hpp index 5ea94e58a..7839188cf 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; + + //! Configuration of the DDS Pipe's Monitor. + ddspipe::core::MonitorConfiguration monitor_configuration{}; }; } /* namespace core */ diff --git a/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp b/ddsrouter_yaml/src/cpp/YamlReader_configuration.cpp index 1c3a8b8a8..dd83e4856 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,13 @@ 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)) + { + object.monitor_configuration = YamlReader::get(yml, MONITOR_TAG, version); + } } template <> 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 9da144832..16580b726 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -493,6 +493,62 @@ 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 internal data from the |ddsrouter|. +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:: + + 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 message reception rate [Hz] of each topic. +The type of the data published is defined as follows: + +**MonitoringTopics.idl** + +.. code-block:: idl + + struct DdsTopicData + { + string participant_id; + unsigned long msgs_lost; + unsigned long msgs_received; + double msg_rx_rate; + }; + + struct DdsTopic + { + string name; + string type_name; + boolean type_discovered; + boolean type_mismatch; + boolean qos_mismatch; + sequence data; + }; + + struct MonitoringTopics + { + sequence topics; + }; + +**Example of usage** + +.. code-block:: yaml + + monitor: + topics: + enable: true + period: 1000 + domain: 10 + topic-name: "DdsRouterTopicData" + Participant Configuration ========================= @@ -948,6 +1004,13 @@ A complete example of all the configurations described on this page can be found publish-type: false stdout: true + monitor: + topics: + enable: true + period: 1000 + domain: 10 + topic-name: "DdsRouterTopicStatistics" + # XML configurations to load xml: diff --git a/tools/ddsrouter_tool/src/cpp/main.cpp b/tools/ddsrouter_tool/src/cpp/main.cpp index 9a65d9fe3..fd3834203 100644 --- a/tools/ddsrouter_tool/src/cpp/main.cpp +++ b/tools/ddsrouter_tool/src/cpp/main.cpp @@ -29,7 +29,8 @@ #include #include - +#include +#include #include #include @@ -232,6 +233,15 @@ int main( commandline_args.reload_time); } + // Monitor + auto monitor_configuration = router_configuration.advanced_options.monitor_configuration; + ddspipe::core::Monitor monitor{monitor_configuration}; + + if (monitor_configuration.producers[ddspipe::core::TOPICS_MONITOR_PRODUCER_ID].enabled) + { + monitor.monitor_topics(); + } + // Start Router router.start();