This script can be used to feed collectd with cpu and memory usage statistics for running docker containers using the collectd exec
plugin.
This script will report the used and cached memory as well as the user and system cpu usage by inspecting the appropriate cgroup stat file for each running container.
This script is intented to be executed by collectd on a host with running docker containers. To use, simply configure the exec
plugin in collectd to execute the collectd-docker.sh
script. You may need to adjust the script to match your particulars, such as the mount location for cgroup.
LoadPlugin exec
<Plugin exec>
Exec ubuntu "/usr/share/collectd/collectd-docker.sh"
</Plugin>
This will execute the collectd-docker.sh
you placed in /usr/share/collectd
using the ubuntu
user.
How can I convert these number values to CPU usage in percentage and RAM usage in gigabytes?
I get numbers like 738967552 for RAM usage and numbers like 103358 for CPU usage in a single container. I would like to display these numbers in my Grafana Dashboard as CPU percentage and RAM in gigabytes (or also percentage).