zabbix 应用监控作业笔记

目录
  1. 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的更多相关文章

  1. 写Ansible playbook添加zabbix被监控的对象

    本主题达到的效果是能通过编写Ansible Playbook,创建zabbix主机组,把被监控的对象加入到zabbix监控系统中,同时链接到对象的模板. 1.准备工作 在zabbix服务器上面,我们需 ...

  2. ansible笔记(11):初识ansible playbook(二)

    ansible笔记():初识ansible playbook(二) 有前文作为基础,如下示例是非常容易理解的: --- - hosts: test211 remote_user: root tasks ...

  3. ansible笔记(10):初识ansible playbook

    ansible笔记():初识ansible playbook 假设,我们想要在test70主机上安装nginx并启动,我们可以在ansible主机中执行如下3条命令 ansible test70 -m ...

  4. zabbix自动化监控基础

    zabbix安装配置文档 2 一 zabbix-server 安装配置(基础配置) 2 二 zabbix agent安装配置 5 2.1 主动模式和被动模式 6 2.2 安装配置zabbix_agen ...

  5. zabbix服务器监控suse系统教程

    zabbix服务器监控suse系统教程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 花了近一个星期才学会了如何监控window和linux主机的基本信息以及报价情况(我已经把笔记 ...

  6. zabbix全网监控

    为什么要监控 运维的职责1.保障企业数据的安全可靠.2.为客户提供7*24小时服务.3.不断提升用户的体验. 在关键时刻,提前提醒我们服务器要出问题了 当出问题之后,可以便于找到问题的根源 拿到公司服 ...

  7. 《为什么说 Prometheus 是足以取代 Zabbix 的监控神器?》

    为什么说 Prometheus 是足以取代 Zabbix 的监控神器?   Kuberneteschina 致力于提供最权威的 Kubernetes 技术.案例与Meetup! ​关注他 12 人赞同 ...

  8. Ansible--02 ansible playbook的应用

    目录 Ansible playbook的应用 什么是playbook playbook的组成 playbook和Ad-Hoc对比 YAML语法 安装httpd练习 rsyncd实战 实战1: 实战2: ...

  9. 使用Ubuntu系统编译安装Zabbix企业级监控系统

    使用Ubuntu系统编译安装Zabbix企业级监控系统   作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Ubuntu系统部署笔记:https://www.cnblogs.com/ ...

随机推荐

  1. idea项目git版本回退

    idea项目git版本回退 一.查询提交历史 项目上右键,点击Git,点击Show History 二.复制版本号 我这里有两个测试的版本,我的当前版本是[二],所以我选择[一],右键,选择Copy ...

  2. 2:Python字符串与数字

    字符串(引号):只有四种情况如下 name="我是编程高手" name='我是编程高手' name="""我是编程高手""&quo ...

  3. Vue2 几种常见开局方式

    在SF问题中看到了一个关于vue-cli中的template问题,问题是这样的:用vue-cli工具生成的main.js中: import Vue from 'vue' import App from ...

  4. phpcms配置列表页以及获得文章发布时间

    <div class="moocConDetail"> {pc:content action="lists" catid="11" ...

  5. 如何用ABP框架快速完成项目(14) - 结尾? 当然不是, 这只是开始!

    此文当前版本号: 3 最近更新时间: 2018-12-9 04:52   本课程是方向性课程, 目的是避免南辕北辙. 方向盘一旦打正确, 还得需要以下文章去写好具体程序: 前面每篇文章里面的链接, 比 ...

  6. Java多线程面试题整理

    部分一:多线程部分: 1) 什么是线程? 线程是操作系统能够进行运算调度的最小单位,它被包含在进程之中,是进程中的实际运作单位.程序员可以通过它进行多处理器编程,你可以使用多线程对运算密集型任务提速. ...

  7. 浅谈Kotlin(四):控制流

    浅谈Kotlin(一):简介及Android Studio中配置 浅谈Kotlin(二):基本类型.基本语法.代码风格 浅谈Kotlin(三):类 浅谈Kotlin(四):控制流 本篇介绍Kotlin ...

  8. (网页)jQuery判断checkbox是否选中的方法

    if($('#checkbox-id').is(':checked')) { // do something} if ($('#checkbox-id').attr('checked')) {    ...

  9. g4e基础篇#5 创建分支和保存代码

    章节目录 前言 1. 基础篇: 为什么要使用版本控制系统 Git 分布式版本控制系统的优势 Git 安装和设置 了解Git存储库(Repo) 起步 1 – 创建分支和保存代码 起步 2 – 了解Git ...

  10. Django 系统日志logging

    Django使用Python内建的logging模块去建造自己的系统日志的,如果你想详细了解这个模块的话,请自己去看python的说明文档,这里仅仅介绍Django中的日志系统. 日志配置包括四个部分 ...