docker监控
1.监控的分类
prometheus ——大规模的docker监控
第三方监控软件,红帽将其融合到centos 8中了,
sysdig ——当前container实时监控
weave scope——结构可视化监控
cAdvisor/Heapster——google图形化监控
zabbix一般用于页面监控,不用于监控docker
2.docker自带的监控工具
docker container
docker container top id
docker container status
3.linux自带的监控工具
tcpdump
htop
iftop
lsof
strace
4.实验:
(1)sysdig监控:
docker container run -it –rm –name=sysdig –privileged=true –volume=/var/run/docker.sock:/host/var/run/docker.sock –volume=/dev:/host/dev –volume=/proc:/host/proc:ro –volume=/boot:/host/boot:ro –volume=/lib/modules:/host/lib/modules:ro –volume=/usr:/host/usr:ro sysdig/sysdig
在容器中运行
csysdig
F2 回车,直接点然后就是以每一项排序
F7每一列的解释
(2)weave scope——结构可视化监控——容器地图
下载这个软件包
curl -L git.io/scope -o /usr/local/bin/scope
chmod +x /usr/local/bin/scope
启动这个监控容器:
scope launch
* http://192.168.122.1:4040/
* http://192.168.6.152:4040/
然后通过浏览器里访问这个 http://192.168.6.152:4040/地址即可进入图形化界面进行docker容器的管理。
(3)cAdvisor/Heapster——google图形化监控
docker run –volume=/:/rootfs:ro –volume=/var/run:/var/run:rw –volume=/sys:/sys:ro –volume=/var/lib/docker:/var/lib/docker:ro –volume=/sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 –detach=true –name=cadvisor google/cadvisor
5.实验命令:
监控一
iptables -F
setenforce 0
docker container run -it –rm –name=sysdig –privileged=true –volume=/var/run/docker.sock:/host/var/run/docker.sock –volume=/dev:/host/dev –volume=/proc:/host/proc:ro –volume=/boot:/host/boot:ro –volume=/lib/modules:/host/lib/modules:ro –volume=/usr:/host/usr:ro sysdig/sysdig
监控二
curl -L git.io/scope -o /usr/local/bin/scope
chmod +x /usr/local/bin/scope
scope launch
docker run -itd –name web1 busybox
docker ps -a
docker container run -itd –rm –name=sysdig –privileged=true –volume=/var/run/docker.sock:/host/var/run/docker.sock –volume=/dev:/host/dev –volume=/proc:/host/proc:ro –volume=/boot:/host/boot:ro –volume=/lib/modules:/host/lib/modules:ro –volume=/usr:/host/usr:ro sysdig/sysdig
监控三
docker run –volume=/:/rootfs:ro –volume=/var/run:/var/run:rw –volume=/sys:/sys:ro –volume=/var/lib/docker:/var/lib/docker:ro –volume=/sys/fs/cgroup:/sys/fs/cgroup:ro -p 8080:8080 –detach=true –name=cadvisor google/cadvisor
docker pull httpd
docker ps
docker images