部署脚本
#!/bin/bash
netstat -ntlp | grep 18080 && echo "port 18080 used" && exit
VERSION=v0.36.0 # use the latest release version from https://github.com/google/cadvisor/releases
docker pull tengxunharbor.leyaoyao.com/lyy-gz/cadvisor:$VERSION
sudo docker run \
--restart=always \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=18080:8080 \
--detach=true \
--name=cadvisor \
tengxunharbor.xxx.com/xxx-gz/cadvisor:$VERSION
nginx配置(通过http的方式下载安装)
[root@VM-13-6-centos /usr/local/tengine/conf/vhost]# cat cadvisor.conf
server {
listen 8082;
server_name localhost;
location / {
root /usr/local/tengine/download;
autoindex on; #开启索引功能
autoindex_exact_size off; #关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
autoindex_localtime on; #显示本机时间而非 GMT 时间
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
安装命令(uat环境)
curl http://10.180.13.6:8082/cadvisor-install.sh|bash
prometheus配置
添加对应主机
[root@VM-3-102-centos /data/prometheus]# echo $PWD/prometheus.yml
/data/prometheus/prometheus.yml
#docker监控
- job_name: 'uat_docker'
static_configs:
- targets:
- 10.180.3.200:18080
重启prometheus
curl -XPOST http://127.0.0.1:9090/-/reload
grafana添加对应图表(id:8321)