1.引言
1.1目的
zabbix+grafana实现图形化监控
2.部署环境
服务器ip | 服务 | 版本 |
---|---|---|
192.168.5.137 | zabbix–server | 6.0.21 |
192.168.5.137 | grafana | 10.2.2 |
192.168.5.152 | zabbix–client | 6.0.21 |
3.部署zabbix–server
3.1 创建zabbix目录
mkdir zabbix
3.2 编写docker–compose文件
cd zabbix
vim docker-compose.yaml
version: '3'
services:
mysql:
image: mysql:8.0
container_name: mysql
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/var/log/mysql
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- MYSQL_ROOT_PASSWORD=myrootpass
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
expose:
- "3306"
networks:
zabbix-net:
command: --character-set-server=utf8 --collation-server=utf8_bin
zabbix-gateway:
image: zabbix/zabbix-java-gateway:6.0-centos-latest
container_name: zabbix-gateway
volumes:
- /etc/localtime:/etc/localtime
restart: always
privileged: true
ports:
- "10052:10052"
networks:
zabbix-net:
zabbix-snmptraps:
image: zabbix/zabbix-snmptraps:6.0-centos-latest
container_name: zabbix-snmptraps
volumes:
- /etc/localtime:/etc/localtime
- ./snmptraps:/var/lib/zabbix/snmptraps
- ./mibs:/var/lib/zabbix/mibs
restart: always
privileged: true
ports:
- "1162:1162/udp"
networks:
zabbix-net:
zabbix-server:
image: zabbix/zabbix-server-mysql:6.0-centos-latest
container_name: zabbix-server
volumes:
- /etc/localtime:/etc/localtime
- ./snmptraps:/var/lib/zabbix/snmptraps
- ./mibs:/var/lib/zabbix/mibs
- ./alertscripts:/usr/lib/zabbix/alertscripts
- ./externalscripts:/usr/lib/zabbix/externalscripts
restart: always
privileged: true
environment:
- ZBX_LISTENPORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- MYSQL_ROOT_PASSWORD=myrootpass
- ZBX_CACHESIZE=1G
- ZBX_HISTORYCACHESIZE=512M
- ZBX_HISTORYINDEXCACHESIZE=16M
- ZBX_TRENDCACHESIZE=256M
- ZBX_VALUECACHESIZE=256M
- ZBX_STARTPINGERS=64
- ZBX_IPMIPOLLERS=1
- ZBX_ENABLE_SNMP_TRAPS=true
- ZBX_STARTTRAPPERS=1
- ZBX_JAVAGATEWAY_ENABLE=true
- ZBX_JAVAGATEWAY=zabbix-gateway
- ZBX_STARTJAVAPOLLERS=1
ports:
- "10051:10051"
networks:
zabbix-net:
links:
- mysql
- zabbix-gateway
zabbix-web:
image: zabbix/zabbix-web-nginx-mysql:6.0-centos-latest
container_name: zabbix-web
volumes:
- ./font/simfang.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
- /etc/localtime:/etc/localtime
restart: always
privileged: true
environment:
- ZBX_SERVER_NAME=Zabbix 6.0
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
- DB_SERVER_HOST=mysql
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=mypass
- MYSQL_ROOT_PASSWORD=myrootpass
- PHP_TZ=Asia/Shanghai
ports:
- "80:8080"
networks:
zabbix-net:
links:
- mysql
- zabbix-server
networks:
zabbix-net:
driver: bridge
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.1
3.3 启动zabbix容器
docker-compose -f docker-compose.yaml up –d
3.4 查看zabbix容器
docker ps
3.5 访问zabbix的web页面
url: http://192.168.5.137:80
4.部署grafana
4.1创建grafana目录
mkdir grafana
4.2 编写grafana.yaml文件
cd grafana
vim grafana.yaml
version: '3.9'
services:
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
environment:
- TZ=Asia/Shanghai
networks:
- grafana
volumes:
- ./grafana:/var/lib/grafana
networks:
grafana:
driver: bridge
4.3启动grafana容器
docker-compose -f grafana.yaml up –d
4.4 安装grafana的zabbix数据源
进入grafana容器
docker exec -it grafana bash
安装zabbix数据源
grafana cli plugins install alexanderzobnin-zabbix-app
查看是否安装成功
grafana cli plugins ls
重启grafana容器
docker restart grafana
4.5 访问grafana的web页面
url:http://192.168.5.137:3000
5.部署zabbix-client
5.1 创建zabbix目录
mkdir zabbix
5.2 编写zabbix.yaml文件
cd zabbix
vim zabbix.yaml
version: '3'
services:
zabbix-agent:
image: zabbix/zabbix-agent:latest
environment:
- ZBX_SERVER_HOST=192.168.5.137
- ZBX_HOSTNAME=test
volumes:
- ./agentd/zabbix_agentd.conf:/etc/zabbix/zabbix_agentd.conf
ports:
- "10050:10050"
5.3 启动zabbix客户端
docker-compose -f zabbix.yaml up –d
6.添加zabbix监控
6.1 添加zabbix客户端ip
6.2 监控zabbix客户端CPU
6.3添加cpu触发器
6.4 添加图形化界面
6.5 查看监控到的数据
7.配置grafana
7.1 添加zabbix插件
7.2搜索添加zabbix数据源
7.3 添加zabbix服务端信息
7.4 开启zabbix模板
7.5 添加zabbix监控数据
至此zabbix+grafana部署完成。
原文地址:https://blog.csdn.net/hanyuce/article/details/134662227
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_36956.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。