zabbix 应用监控作业笔记 ansible-playbook
zabbix 应用监控作业笔记
- 2台web(Nginx+PHP)、1台MySQL、1台NFS、1台Rsync(所有的.conf监控项一样,模板不一样)
1.自定义监控项、自定义触发器、自定义动作
2.如何制作模板,模板的导出与导入使用Ansible统一
安装Zabbix-Agent
配置Zabbix-Agent
推送所有的脚本
推送所有的.conf文件
# ansible 批量管理
1.创建密钥对
[root@m01 ~]# ssh-keygen -t rsa -C xuliangwei.com #一路回车即可
[root@m01 ~]# ls ~/.ssh/
id_rsa(钥匙) id_rsa.pub(锁头)
2#发送密钥给需要登录的用户
[root@m01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@172.16.1.71
配置ansible 主机清单
[root@m01 ansible-playbook]# cat /etc/ansible/hosts
[lb]
172.16.1.5
172.16.1.6
[web]
172.16.1.7
172.16.1.8
[sweb]
172.16.1.9
[nfs]
172.16.1.31
[backup]
172.16.1.41
[db]
172.16.1.51
[zabbix]
172.16.1.71
目录结构
[root@m01 ansible-playbook]# tree
.
├── conf
│ ├── conf.zip
│ ├── php-status.conf
│ ├── ss_get_mysql_stats.php
│ ├── status.conf
│ ├── www.conf
│ ├── zabbix_agentd.conf
│ ├── zabbix.conf
│ └── zabbix_server.conf
├── mail.retry
├── mail.yaml
├── scripts
│ └── mysql.sh
├── zabbix-backup.yaml
├── zabbix-mysql.yaml
├── zabbix-nfs.yaml
├── zabbix-server.retry
├── zabbix-server.yaml
└── zabbix-web.yaml
2 directories, 17 files
mail.yal
- import_playbook: zabbix-web.yaml
- import_playbook: zabbix-backup.yaml
- import_playbook: zabbix-nfs.yaml
- import_playbook: zabbix-mysql.yaml
- import_playbook: zabbix-server.yaml
zabbix-web.yaml
- hosts: web
tasks:
- name: Yum zabbix-agent
yum: name=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.12-1.el7.x86_64.rpm state=present
- name: configure zabbix-agent
copy: src=./conf/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf
- name: Start zabbix-agent
service: name=zabbix-agent state=started enabled=yes
- name: Copy nginx conf
copy: src=./conf/status.conf dest=/etc/nginx/conf.d/status.conf
- name: Restart nginx
service: name=nginx state=restarted
# - name: Mkdir directory
# file: path=/etc/zabbix/zabbix_agentd.d/scripts state=directory mode=755
#
# - name: copy nginx_status.sh
# copy: src=./scripts/nginx_status.sh dest=/etc/zabbix/zabbix_agentd.d/scripts/nginx_status.sh
#
# - name: chmod 755
# shell: chmod 755 /etc/zabbix/zabbix_agentd.d/scripts/nginx_status.sh
- name: cpoy conf.zip
unarchive: src=conf/conf.zip dest=/etc/zabbix/zabbix_agentd.d/ creates=/etc/zabbix/zabbix_agentd.d/io.conf
# unarchive: src=./conf/conf.zip dest=/etc/zabbix/zabbix_agentd.d/
- name: Restart zabbix-agent
service: name=zabbix-agent state=restarted
- name: php-fpm/www.conf
copy: src=./conf/www.conf dest=/etc/php-fpm.d/www.conf
- name: php-status.conf
copy: src=./conf/php-status.conf dest=/etc/nginx/conf.d/
- name: Restart php-fpm
service: name=php-fpm state=restarted
- name: Restart zabbix-agent
service: name=zabbix-agent state=restarted
zabbix-backup.yaml
- hosts: backup
tasks:
- name: Install zabbix-agent
yum: name=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.12-1.el7.x86_64.rpm state=present
- name: configure zabbix-agent
copy: src=./conf/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf
- name: cpoy conf.zip
unarchive: src=conf/conf.zip dest=/etc/zabbix/zabbix_agentd.d/ creates=/etc/zabbix/zabbix_agentd.d/io.conf
- name: Start zabbix-agent
service: name=zabbix-agent state=started enabled=yes
zabbix-nfs.yaml
- hosts: nfs
tasks:
- name: Yum zabbix-agent
yum: name=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.12-1.el7.x86_64.rpm state=present
- name: configure zabbix-agent
copy: src=./conf/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf
- name: cpoy conf.zip
unarchive: src=conf/conf.zip dest=/etc/zabbix/zabbix_agentd.d/ creates=/etc/zabbix/zabbix_agentd.d/io.conf
- name: Start zabbix-agent
service: name=zabbix-agent state=started enabled=yes
zabbix-mysql.yaml
- hosts: db
tasks:
- name: Yum zabbix-agent
yum: name=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.12-1.el7.x86_64.rpm state=present
- name: configure zabbix-agent
copy: src=./conf/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf
- name: Start zabbix-agent
service: name=zabbix-agent state=started enabled=yes
- name: Yum php php-mysql
yum: name=php,php-mysql state=installed
- name: Yum percona
yum: name=https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm state=present
- name: copy percona configurl
copy: src=./conf/ss_get_mysql_stats.php dest=/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
- name: cpoy conf.zip
unarchive: src=conf/conf.zip dest=/etc/zabbix/zabbix_agentd.d/ creates=/etc/zabbix/zabbix_agentd.d/io.conf
- name: Restart zabbix-agent
service: name=zabbix-agent state=started
- name: ReStart zabbix-agent
service: name=zabbix-agent state=started
zabbix-server.yaml
- hosts: zabbix
tasks:
- name: Yum zabbixsrc
yum: name=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm state=present
- name: Yum zabbix
yum: name=zabbix-server-mysql,zabbix-web-mysql,zabbix-agent,mariadb-server state=installed
- name: start mariadb
service: name=mariadb state=started enabled=yes
- name: all in one mysql.sh
script: ./scripts/mysql.sh
args:
creates: /tmp/file.txt
- name: copy zabbix_server.conf
copy: src=./conf/zabbix_server.conf dest=/etc/zabbix/zabbix_server.conf
- name: copy httpd/zabbix.conf
copy: src=./conf/zabbix.conf dest=/etc/httpd/conf.d/zabbix.conf
- name: Start zabbix-server
service: name=zabbix-server state=started enabled=yes
- name: Start httpd
service: name=httpd state=started enabled=yes
- name: Start mariadb
service: name=mariadb state=started enabled=yes
浏览器访问 http://10.0.0.71/zabbix/
链接: https://pan.baidu.com/s/1qOQVASOq4kVXvbpjum7a5A 提取码: ygvn
zabbix 应用监控作业笔记 ansible-playbook的更多相关文章
- 写Ansible playbook添加zabbix被监控的对象
本主题达到的效果是能通过编写Ansible Playbook,创建zabbix主机组,把被监控的对象加入到zabbix监控系统中,同时链接到对象的模板. 1.准备工作 在zabbix服务器上面,我们需 ...
- ansible笔记(11):初识ansible playbook(二)
ansible笔记():初识ansible playbook(二) 有前文作为基础,如下示例是非常容易理解的: --- - hosts: test211 remote_user: root tasks ...
- ansible笔记(10):初识ansible playbook
ansible笔记():初识ansible playbook 假设,我们想要在test70主机上安装nginx并启动,我们可以在ansible主机中执行如下3条命令 ansible test70 -m ...
- zabbix自动化监控基础
zabbix安装配置文档 2 一 zabbix-server 安装配置(基础配置) 2 二 zabbix agent安装配置 5 2.1 主动模式和被动模式 6 2.2 安装配置zabbix_agen ...
- zabbix服务器监控suse系统教程
zabbix服务器监控suse系统教程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 花了近一个星期才学会了如何监控window和linux主机的基本信息以及报价情况(我已经把笔记 ...
- zabbix全网监控
为什么要监控 运维的职责1.保障企业数据的安全可靠.2.为客户提供7*24小时服务.3.不断提升用户的体验. 在关键时刻,提前提醒我们服务器要出问题了 当出问题之后,可以便于找到问题的根源 拿到公司服 ...
- 《为什么说 Prometheus 是足以取代 Zabbix 的监控神器?》
为什么说 Prometheus 是足以取代 Zabbix 的监控神器? Kuberneteschina 致力于提供最权威的 Kubernetes 技术.案例与Meetup! 关注他 12 人赞同 ...
- Ansible--02 ansible playbook的应用
目录 Ansible playbook的应用 什么是playbook playbook的组成 playbook和Ad-Hoc对比 YAML语法 安装httpd练习 rsyncd实战 实战1: 实战2: ...
- 使用Ubuntu系统编译安装Zabbix企业级监控系统
使用Ubuntu系统编译安装Zabbix企业级监控系统 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Ubuntu系统部署笔记:https://www.cnblogs.com/ ...
随机推荐
- mysql用户授权、数据库权限管理、sql语法详解
mysql用户授权.数据库权限管理.sql语法详解 —— NiceCui 某个数据库所有的权限 ALL 后面+ PRIVILEGES SQL 某个数据库 特定的权限SQL mysql 授权语法 SQL ...
- JavaScript是如何工作的:Web Workers的构建块 + 5个使用他们的场景
摘要: 理解Web Workers. 原文:JavaScript是如何工作的:Web Workers的构建块 + 5个使用他们的场景 作者:前端小智 Fundebug经授权转载,版权归原作者所有. 这 ...
- JavaScript主流框架3月趋势总结
原文: What’s New in JavaScript Frameworks-March 2018 译者: Fundebug 为了保证可读性,本文采用意译而非直译.另外,本文版权归原作者所有,翻译仅 ...
- LeNet训练MNIST
jupyter notebook: https://github.com/Penn000/NN/blob/master/notebook/LeNet/LeNet.ipynb LeNet训练MNIST ...
- WORLD 目录排版调整
文本如下: ----------------------------------------------------------------- 前言1 简介2 我爱你3 圣灵丹方士大夫4 阿类似的看风 ...
- jQuery 事件 - ready() 方法
转载:http://www.w3school.com.cn/jquery/jquery_hide_show.asp 实例 在文档加载后激活函数: $(document).ready(function( ...
- 「Android」 Surface分析
本篇针对Surface模块进行分析,从Java层的Activity创建开始,到ViewRoot.WindowsManagerService,再到JNI层和Native层. 首先推荐一个Android源 ...
- WPF:Metro样式ProgressBar(圆点横向移动),自适应宽度
先看效果图: 最直观的,这是4个圆点在移动,就用一个横向的StackPanel表示这四个点吧. <StackPanel Orientation="Horizontal"> ...
- 在 Centos 安装 MySQL
MySQL是开源的数据库管理系统,通常作为LEMP(Linux, Nginx, MySQL/MariaDB, PHP/Python/Perl)技术栈的一部分,而被安装.RedHat 会害怕 Oracl ...
- abseil初体验[google开源的C++库]
Google公开了其项目内部使用的一系列C++库,具体介绍参考: http://www.infoq.com/cn/news/2017/10/abseil?utm_source=infoq&ut ...