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/ ...
随机推荐
- JS中将变量转为字符串
译者按: 语言的细枝末节了解一下就可以了,不需要太较真,不过如果一点也不知道的话,那就不太妙了. 原文: Converting a value to string in JavaScript 译者: ...
- CSS table-layout 属性
设置表格布局算法: table { table-layout:fixed; } 所有浏览器都支持 table-layout 属性. 定义 tableLayout 属性用来显示表格单元格.行.列的算法规 ...
- uni-app (1) 安装与运行。
安装: 直接到官网安装. 到插件市场下载一个模版. 新建项目的时候有提示链接: 找一个模版用于测试,或者在创建的时候选一个内置模版. 运行:第一次运行的时候有几个地方需要配置,这里因为只是用到了微信小 ...
- 《JavaScript高级程序设计》笔记:JavaScript简介(一)
javascript从一个简单的输入验证器发展成为一门强大的编程语言,完全出乎人们的意料. javascript实现一个完整的javascript实现应该由下列三个不同的部分组成:1:核心(ECMAS ...
- Navicat Premium for Mac 破解版地址
找了好几个都不能使用 试了一下这个 可以使用 放地址:http://www.orsoon.com/Mac/85386.html
- ViewPager实现滑动翻页效果
实现ViewPager的滑动翻页效果可以使用ViewPager的setPageTransformer方法,如下: import android.content.Context; import andr ...
- 章节二、1-java概述-数据类型
一.数据类型 1.基本数据类型 a.数值型 1.整数:byte(1个字节=8位) min:-128 max:127 default:0 .short(2个字节=16位) min:-32768 max: ...
- Scrapy实现腾讯招聘网信息爬取【Python】
一.腾讯招聘网 二.代码实现 1.spider爬虫 # -*- coding: utf-8 -*- import scrapy from Tencent.items import TencentIte ...
- 用cmd命令行编译JAVA程序时出现“找不到或无法加载主类”
今天复习Java基础知识时,使用cmd命令窗口进行编译Java文件发现了如下问题: 网上有很多的解决方法,和问题出现的讨论,以下方法是解决我出现这个问题方式. 解决方式: 重点是圈住的部分. 下面是我 ...
- 洗礼灵魂,修炼python(70)--爬虫篇—补充知识:json模块
在前面的某一篇中,说完了pickle,但我相信好多朋友都不懂到底有什么用,那么到了爬虫篇,它就大有用处了,而和pickle很相似的就是JSON模块 JSON 1.简介 1)JSON(JavaScrip ...