Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 735d20b

Browse files
James Sirimm318
authored andcommitted
Initial commit
0 parents  commit 735d20b

27 files changed

+1271
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*Issue #, if available:*
2+
3+
*Description of changes:*
4+
5+
6+
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install:
2+
- git clone https://github.com/ros-industrial/industrial_ci.git .ros_ci
3+
script:
4+
- .ros_ci/travis.sh

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
![cpu](wiki/images/cpu.svg)
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+
![memory](wiki/images/memory.svg)
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
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(health_metric_collector)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
# add_compile_options(-std=c++17)
6+
set(CMAKE_CXX_STANDARD 14)
7+
8+
## Find catkin macros and libraries
9+
find_package(catkin REQUIRED COMPONENTS
10+
ros_monitoring_msgs
11+
roscpp
12+
rospy
13+
std_msgs
14+
message_generation
15+
aws_common
16+
aws_ros1_common
17+
)
18+
19+
###################################
20+
## catkin specific configuration ##
21+
###################################
22+
catkin_package(
23+
INCLUDE_DIRS include
24+
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
25+
)
26+
27+
###########
28+
## Build ##
29+
###########
30+
31+
## Specify additional locations of header files
32+
include_directories(
33+
include
34+
${catkin_INCLUDE_DIRS}
35+
)
36+
37+
set(ALL_SRC_FILES src/cpu_data.cpp src/cpu_stats.cpp src/metric_manager.cpp src/cpu_metric_collector.cpp src/sys_info_collector.cpp)
38+
add_library(collector_lib ${ALL_SRC_FILES})
39+
40+
add_executable(health_metric_collector src/collector.cpp)
41+
target_link_libraries(health_metric_collector ${catkin_LIBRARIES} collector_lib)
42+
43+
install(DIRECTORY config launch
44+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
45+
46+
install(DIRECTORY include/${PROJECT_NAME}/
47+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
48+
FILES_MATCHING PATTERN "*.h"
49+
PATTERN ".svn" EXCLUDE)
50+
51+
install(TARGETS collector_lib DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
52+
53+
install(TARGETS health_metric_collector
54+
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
55+
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
56+
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
57+
)
58+
59+
#############
60+
## Testing ##
61+
#############
62+
63+
if(CATKIN_ENABLE_TESTING)
64+
find_package(rostest REQUIRED)
65+
include_directories(/usr/include/gmock /usr/src/gmock)
66+
add_library(libgmock /usr/src/gmock/src/gmock-all.cc)
67+
68+
add_rostest_gtest(test_health_metric_collector
69+
test/test_health_metric_collector.test
70+
test/health_metric_collector_test.cpp
71+
)
72+
73+
target_include_directories(test_health_metric_collector
74+
PRIVATE include
75+
${catkin_INCLUDE_DIRS}
76+
)
77+
78+
target_link_libraries(test_health_metric_collector ${catkin_LIBRARIES} libgmock collector_lib)
79+
endif()

0 commit comments

Comments
 (0)