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/ ...
随机推荐
- Java编程思想__异常
1.使用异常链,需要采用如下方式包装捕获到的异常: public void two() { System.out.println("two()"); try { one(); } ...
- Js 控制随机数概率
如: 取 1~10 之间的随机数,那么他们的取值范围是: 整数 区间 概率 1 [0,1) 0.1 2 [1,2) 0.1 3 [2,3) 0.1 4 [3,4) 0.1 5 [4,5) 0.1 6 ...
- js正则表达式 URL格式匹配详解
0.URL格式 protocol :// hostname[:port] / path / [;parameters][?query]#fragment [;parameters]没见过 这里就不做相 ...
- git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:
方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来) git stash git pull origin master git sta ...
- 2018-11-23 手工翻译Vue.js源码:尝试重命名标识符与文本
续前文: 手工翻译Vue.js源码第一步:14个文件重命名 对core/instance/索引中的变量, 方法进行重命名如下(题图): import { 混入初始化 } from './初始化' im ...
- 「Android」SurfaceFlinger分析
本篇针对surfaceFlinger模块进行分析,目录如下: 1.SurfaceFlinger功能 1.1.BufferQueue原理(native/libs/gui模块) 1.2 layer显示 ...
- Android 如何解决dialog弹出时无法捕捉Activity的back事件
Android 如何解决dialog弹出时无法捕捉Activity的back事件 在一些情况下,我们需要捕捉back键事件,然后在捕捉到的事件里写入我们需要进行的处理,通常可以采用下面三种办法捕捉到b ...
- mac版本查看日志命令
1. ls -l 列出所有文件目录,并可以查看文件目录的所有权限 2.cd 切换至某个目录 eg: cd /Applications 再继续 ls -l 列出所有文件目录 3.cd .. 返回到上 ...
- Java 一些知识点总结
本篇文章会对面试中常遇到的Java技术点进行全面深入的总结,帮助我们在面试中更加得心应手,不参加面试的同学也能够借此机会梳理一下自己的知识体系,进行查漏补缺(阅读本文需要有一定的Java基础).本文的 ...
- 网站出现403 Forbidden
1, 你在一定时间内过多地访问此网站(一般是用采集程序),被防火墙拒绝访问了 2, 网站域名解析到了空间,但空间未绑定此域名 3, 你的网页脚本文件在当前目录下没有执行权限 4, 服务器繁忙,同一IP ...