|
| 1 | +# health_metric_collector |
| 2 | + |
| 3 | + |
| 4 | +## Overview |
| 5 | +This `health_metric_collector` ROS node collects system metrics and publishes them to `/metrics` topic. The `cloudwatch_metrics_collector` node is subscribed to this topic and will publish the metrics to AWS CloudWatch when it is instantiated. |
| 6 | + |
| 7 | +**Keywords**: ROS, AWS, CloudWatch, Metrics |
| 8 | + |
| 9 | +### License |
| 10 | +The source code is released under an [Apache 2.0]. |
| 11 | + |
| 12 | +**Author**: AWS RoboMaker<br/> |
| 13 | +**Affiliation**: [Amazon Web Services (AWS)]<br/> |
| 14 | +**Maintainer **: AWS RoboMaker, [email protected] |
| 15 | + |
| 16 | +### Supported ROS Distributions |
| 17 | +- Kinetic |
| 18 | +- Lunar |
| 19 | +- Melodic |
| 20 | + |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +### AWS Credentials |
| 25 | +You will need to create an AWS Account and configure the credentials to be able to communicate with AWS services. You may find [AWS Configuration and Credential Files] helpful. Specifying AWS [credentials by setting environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html) is not supported. |
| 26 | + |
| 27 | +This node will require the following AWS account IAM role permissions: |
| 28 | +- `cloudwatch:PutMetricData` |
| 29 | + |
| 30 | +### Building from Source |
| 31 | +Create a ROS workspace and a source directory |
| 32 | + |
| 33 | + mkdir -p ~/ros-workspace/src |
| 34 | + |
| 35 | +To build from source, clone the latest version from master branch and compile the package |
| 36 | + |
| 37 | +- Clone the package into the source directory |
| 38 | + |
| 39 | + cd ~/ros-workspace/src |
| 40 | + git clone https://github.com/aws-robotics/utils-common.git |
| 41 | + git clone https://github.com/aws-robotics/utils-ros1.git |
| 42 | + git clone https://github.com/aws-robotics/monitoringmessages-ros1.git |
| 43 | + git clone https://github.com/aws-robotics/health-metrics-collector-ros1.git |
| 44 | + |
| 45 | +- Install dependencies |
| 46 | + |
| 47 | + cd ~/ros-workspace && sudo apt-get update |
| 48 | + rosdep install --from-paths src --ignore-src -r -y |
| 49 | + |
| 50 | +- Build the packages |
| 51 | + |
| 52 | + cd ~/ros-workspace && colcon build |
| 53 | + |
| 54 | +- Configure ROS library Path |
| 55 | + |
| 56 | + source ~/ros-workspace/install/setup.bash |
| 57 | + |
| 58 | +- Build and run the unit tests |
| 59 | + |
| 60 | + colcon build --packages-select health_metric_collector --cmake-target tests |
| 61 | + colcon test --packages-select health_metric_collector && colcon test-result --all |
| 62 | + |
| 63 | + |
| 64 | +## Launch Files |
| 65 | +An example launch file called `sample_application.launch` is included in this project that gives an example of how you can include this node in your project together with the [`cloudwatch_metrics_collector`] node. |
| 66 | + |
| 67 | + |
| 68 | +## Usage |
| 69 | + |
| 70 | +### Run the node |
| 71 | +- **With** launch file: |
| 72 | + - ROS: `roslaunch health_metric_collector sample_application.launch` |
| 73 | + |
| 74 | +- **Without** launch file using default values |
| 75 | + - ROS: `rosrun health_metric_collector health_metric_collector` |
| 76 | + |
| 77 | +### Running the sample application |
| 78 | +To launch the sample application for the metrics node you can run the following command: |
| 79 | + |
| 80 | + roslaunch health_metric_collector sample_application.launch --screen |
| 81 | + |
| 82 | + |
| 83 | +## Configuration file and Parameters |
| 84 | +The `health_metric_collector` node receives an interval parameter that indicates the frequency in which it should sample metrics. e.g. interval=5 indicates sampling every five seconds. The default value is 5. |
| 85 | + |
| 86 | +#### Supported Metrics Types |
| 87 | +- Free RAM (in MB) |
| 88 | +- Total RAM (in MB) |
| 89 | +- Total cpu usage (percentage) |
| 90 | +- Per core cpu usage (percentage) |
| 91 | +- Uptime (in sec) |
| 92 | +- Number of processes |
| 93 | + |
| 94 | +## Performance and Benchmark Results |
| 95 | +We evaluated the performance of this node by runnning the followning scenario on a Raspberry Pi 3 Model B: |
| 96 | + |
| 97 | +- Launch a baseline graph containing the talker and listener nodes from the [roscpp_tutorials package](https://wiki.ros.org/roscpp_tutorials), plus two additional nodes that collect CPU and memory usage statistics. Allow the nodes to run 60 seconds. |
| 98 | +- Launch the `health_metric_collector` ROS node using the launch file `sample_application.launch` as described above. That launch file also starts a `cloudwatch_metrics_collector` node, that forwards to the Amazon CloudWatch Metrics service each of the metric messages the `health_metric_collector` ROS node is publishing to the `/metrics` topic. |
| 99 | +- Allow the nodes to run for 180 seconds. |
| 100 | +- Terminate the `health_metric_collector` and `cloudwatch_metrics_collector` nodes, and allow the remaining nodes to run for 60 seconds. |
| 101 | + |
| 102 | +The following graph shows the CPU usage during that scenario. After launching the nodes with `sample_application.launch`, the 1 minute average CPU usage increases from around 7% to a peak of 15%, and stabilizes around 6%, until the nodes are stopped around second 266. |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +The following graph shows the memory usage during that scenario. We start with a memory usage of 225 MB for the baseline graph, that increases to 251 MB (+11.56%) when `sample_application.launch` is launched. Memory usage keeps stable until we stop the nodes, and after tthat it goes back to 225 MB. |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +## Node |
| 112 | + |
| 113 | +### health_metric_collector |
| 114 | + |
| 115 | +#### Published Topics |
| 116 | +- **`/metrics`** |
| 117 | + |
| 118 | +#### Subscribed Topics |
| 119 | +None |
| 120 | + |
| 121 | +#### Services |
| 122 | +None |
| 123 | + |
| 124 | + |
| 125 | +## Bugs & Feature Requests |
| 126 | +Please contact the team directly if you would like to request a feature. |
| 127 | + |
| 128 | +Please report bugs in [Issue Tracker]. |
| 129 | + |
| 130 | + |
| 131 | +[`cloudwatch_metrics_collector`]: https://github.com/aws-robotics/cloudwatchmetrics-ros1 |
| 132 | +[Amazon Web Services (AWS)]: https://aws.amazon.com/ |
| 133 | +[Apache 2.0]: https://aws.amazon.com/apache-2-0/ |
| 134 | +[AWS Configuration and Credential Files]: https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html |
| 135 | +[Issue Tracker]: https://github.com/aws-robotics/health-metrics-collector-ros1/issues |
| 136 | +[ROS]: http://www.ros.org |
0 commit comments