我部署了一个 docker 容器,内存限制为300M和 CPU-1 Core。当容器启动并且我的程序执行时,它遵循 300M 的内存限制和 1st CPU Core 的 CPU 限制。
然而,在容器内运行的 collectd 会推送实际盒子(16 GB RAM)的内存和交换内存指标,而不是受限容器(300MB RAM)。
有没有我缺少的配置?
码头工人运行命令:
docker run -e CONTAINER_NAME='sample_docker_container' -m 300M --memory-swap=300M --cpuset-cpus="1" --net=host --name=sample_docker -p 4000:4000 -p 4001:4001 -p 4002:4002 sample_docker
石墨指标:
如图所示,这些指标被推送用于大于 300MB 的 RAM。当我在我的实际盒子中运行高性能代码(使用超过 4 GB 的 RAM)时,容器内的 collectd 也会增加使用的 RAM。
因此,它不会从 docker 容器内部收集和推送指标。
收集.conf:
Hostname sample_docker_container
Interval 60
LoadPlugin logfile
<Plugin logfile>
LogLevel info
File STDOUT
Timestamp true
PrintSeverity false
</Plugin>
Include "/opt/comp/indis-docker/collectd/conf/collectd.d/*"
collectd_perf.conf:
LoadPlugin disk
LoadPlugin load
LoadPlugin memory
LoadPlugin swap
LoadPlugin vmem
LoadPlugin interface
<Plugin interface>
Interface "lo"
Interface "eth0"
Interface "eth1"
IgnoreSelected false
</Plugin>
LoadPlugin df
<Plugin df>
MountPoint "/dev"
MountPoint "/run"
MountPoint "/run/lock"
MountPoint "/run/shm"
IgnoreSelected true
ValuesPercentage true
</Plugin>
LoadPlugin cpu
LoadPlugin "aggregation"
<Plugin "aggregation">
<Aggregation>
Plugin "cpu"
Type "cpu"
SetPlugin "cpu"
SetPluginInstance "%{aggregation}"
GroupBy "Host"
GroupBy "TypeInstance"
CalculateMinimum true
CalculateMaximum true
CalculateAverage true
</Aggregation>
</Plugin>
LoadPlugin "match_regex"
PostCacheChain "Cpumetrics"
<Chain "Cpumetrics">
<Rule>
<Match "regex">
Plugin "^cpu$"
PluginInstance "^[0-9]+$"
</Match>
<Target write>
Plugin "aggregation"
</Target>
Target stop
</Rule>
Target "write"
</Chain>