Cadviosr是Google用来监测单节点的资源信息的监控工具。虽然Docker提供了一些CLI的命令行的功能,但是在一个看图的时代,基本的功能是很难满足人民群众日益增长的物质文化需求,Cadvisor提供了一目了然的单节点多容器的资源监控功能。Google的Kubernetes中也缺省地将其作为单节点的资源监控工具,各个节点缺省会被安装上Cadvisor。在免费的世界里,Cadvisor作为一个很不错的工具,越来越多的引起很多人过渡性的关注。

1、docker拉取cadvisor镜像*

        #  docker pull docker.io/google/cadvisor

2、运行一个容器,并配置

        #  docker run \
              --volume=/:/rootfs:ro \
                --volume=/var/run:/var/run:rw \
                --volume=/sys:/sys:ro \
                --volume=/var/lib/docker/:/var/lib/docker:ro \
                --publish=8090:8080 \
                --detach=true \
                --name=cadvisor \
                google/cadvisor:latest

3、打开网页查看:

        localhost:8090/containers/

Docker 部署单节点监控,cAdvisor_第1张图片

4、若启动报如下错误:


I0731 07:54:09.774446       1 factory.go:356] Registering Docker factory
I0731 07:54:11.776339       1 factory.go:54] Registering systemd factory
I0731 07:54:11.776979       1 factory.go:86] Registering Raw factory
I0731 07:54:11.777773       1 manager.go:1178] Started watching for new ooms in manager
W0731 07:54:11.777792       1 manager.go:313] Could not configure a source for OOM detection, disabling OOM events: open /dev/kmsg: no such file or directory
I0731 07:54:11.779795       1 manager.go:329] Starting recovery of all containers
I0731 07:54:11.866094       1 manager.go:334] Recovery completed
F0731 07:54:11.866150       1 cadvisor.go:156] Failed to start container manager: inotify_add_watch /sys/fs/cgroup/cpuacct,cpu: no such file or directory

处理方法如下:

[root@localhost /]# sudo mount -o remount,rw '/sys/fs/cgroup'
[root@localhost /]# sudo ln -s /sys/fs/cgroup/cpu,cpuacct /sys/fs/cgroup/cpuacct,cpu

重新启动成功