ansible 批量装机-Zabbix篇

#############################

小错误区:特此警示,问题要全面化,不要单纯想着你这边的问题,有可能也是对面的问题,反则亦此,学会深度用百度。google

[root@zabbix alertscripts]# scp tcp_connect.sh websocket.sh root@10.0.5.251:/usr/lib/zabbix/alertscripts/
bash: scp: command not found
lost connection

这种错误是对面没有安装ssh   ansible add -m command -a 'yum -y install openssh-client*'  这条命令就可以解决

##############################

如下就是批量安装zabbix-agent,修改指向zabbix-server,重启,赋予权限,在文件最后增加内容等

ansible add -m command -a "rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-1.el6.noarch.rpm"  装zabbix4.0agent的软件包源

ansible add -m command -a 'yum -y install zabbix-agent'

ansible add -m command -a 'sed -i 's/Server=127.0.0.1/Server=10.0.5.30/' /etc/zabbix/zabbix_agentd.conf'    修改指向zabbix-server

ansible add -m command -a 'sed -i 's/ServerActive=127.0.0.1/ServerActive=10.0.5.30:10051/' /etc/zabbix/zabbix_agentd.conf'  同上

ansible new -m command -a 'grep -E (^Server) /etc/zabbix/zabbix_agentd.conf '  匹配检索包含的内容

ansible new -m command -a 'mkdir -p /usr/lib/zabbix/alertscripts/'      远程创建目录

ansible new -m copy -a "src=/usr/lib/zabbix/alertscripts/tcp_connect.sh dest=/usr/lib/zabbix/alertscripts/"        拷贝当前文件到远程

ansible add -m command -a 'chown -R zabbix:zabbix /usr/lib/zabbix/alertscripts/'            授权

ansible add -m command -a 'ls -al /usr/lib/zabbix/alertscripts/'                          查看

ansible add -m lineinfile -a 'dest=/etc/zabbix/zabbix_agentd.conf line="UserParameter=tcp30.status[*],/usr/lib/zabbix/alertscripts/tcp_connect.sh $1"'   在文件最后增加内容

ansible add -m lineinfile -a 'dest=/etc/zabbix/zabbix_agentd.conf line="UserParameter=wss30.time,sh /usr/lib/zabbix/alertscripts/websocket.sh wss://zwss.ky017.com:30050"'   同上

ansible add -m command -a 'yum -y install libselinux-python'       不是必须的,如果报错缺少python包时,所要安装的软件

ansible new -m command -a 'service zabbix-agent restart'          重启agent

ansible new -m command -a 'chkconfig --levels 2345 zabbix-agent on'      启动开机运行

ansible new -m command -a 'chkconfig --list zabbix-agent'        查看启动列表

如有特殊需求可以参考https://www.jianshu.com/p/3a67ba27ba20  我这个哥们的“简书”

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a,S[a]}'       统计nginx连接

Ansible-Zabbix-基础agent批量装机的更多相关文章

  1. Ansible实现zabbix服务器agent端批量部署

    项目需求:由于搭建zabbix,需要每台服务器都需要安装监控端(agent)正常的的操作是一台一台去安装,这样确实有点浪费时间,这里为大家准备了一款开源 的自动化运维工具Ansible,相信大家也很熟 ...

  2. Zabbix实战-简易教程--大型分布式监控系统实现Agent批量快速接入

    一.分布式架构 相信使用zabbix的大神都熟悉他的分布式架构,分布式的优势相当明显,分而治之.比如目前我的架构图如下: 那么,对将要接入监控系统的任何一个agent如何快速定位,并进行接入呢?  问 ...

  3. zabbix基础服务搭建

    监控系统的介绍 性能优化和监控点 1.cpu           调度器          有效的分配cpu的时间片           上下文切换           运行队列            ...

  4. ansible入门三(Ansible的基础元素和YAML介绍)

    Ansible的基础元素和YAML介绍   本节内容: YAML Ansible常用的数据类型 Ansible基础元素 一.YAML 1. YAML介绍 YAML是一个可读性高的用来表达资料序列的格式 ...

  5. 批量装机工具cobbler简介及其安装使用

    前言:如果仅有几台机器的话,使用U盘或者光盘装起来还不是很费事,一旦数量到了一定程度,使用手动方法就是一件费时费力的事,PXE+kistart就可以解决这个问题,降低难度,加快速度,而cobbler更 ...

  6. 分布式监控系统之Zabbix基础使用

    前文我们了解了分布式监控系统zabbix的相关组件的作用和zabbix的部署,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/13997582.html:今天我们 ...

  7. 使用ansible实现轻量级的批量主机管理

    作者:邓聪聪 查看ansible配置文件下的hosts的文件 [root@ansible-server scripts]# cat /etc/ansible/hosts [test] 172.16.1 ...

  8. Ansible playbook基础组件介绍

    本节内容: ansible playbook介绍 ansible playbook基础组件 playbook中使用变量 一.ansible playbook介绍 playbook是由一个或多个“pla ...

  9. ansible入门四(Ansible playbook基础组件介绍)

    本节内容: ansible playbook介绍 ansible playbook基础组件 playbook中使用变量 一.ansible playbook介绍 playbook是由一个或多个“pla ...

随机推荐

  1. GWAS:拒绝假阳性之case和control数量比例严重失衡的解决方案(SAIGE模型的应用)

    一.为什么要校正case和control数量比例不平衡情况 试问作为生信届人员,最怕的是什么,当然是统计结果不靠谱.统计结果不靠谱包括两方面:一个是假阴性,一个是假阳性.假阴性可以理解为白天鹅被误当成 ...

  2. 支付宝aar添加与友盟冲突解决

    Program type already present: com.ta.utdid2.b.a.e" 错误提示: 删掉libs中utdid的jar.

  3. vue-cli 项目踩坑 npm install 时出错

    1.报错如下: 2.此时你执行npm run dev  / npm run build 会报错如下 npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! v ...

  4. SQL随记(六)

    1.关于dbms_sql包的一些执行语句 cursor_name := DBMS_SQL.OPEN_CURSOR; --打开游标: DBMS_SQL.PARSE(cursor_name, var_dd ...

  5. npm install 时出现的 EACCES: permission denied 错误的可能有效的解决方案

    最近我开始接触手机 app 的编写,公司用到了 Nativescript.当我下载了公司的项目后,在配置时出现了不少的问题,其中出现概率最高的就是 EACCES: permission denied ...

  6. vue DES 加密

    安装crypto-js cnpm install crypto-js --save 封装一个des.js ECB模式 import cryptoJs from 'crypto-js' // DES加密 ...

  7. Matplotlib图例

    折线图示例 #!/usr/bin/python2.7 import numpy as np from matplotlib import pyplot as plt from dbtools impo ...

  8. Java 集合系列08之 List总结

    一.List概述 1. List是一个接口,它继承于Collection接口,代表有序集合 2. ArrayList, LinkedList, Vector, Stack是List的4个实现类. Ar ...

  9. ARIMA模型原理

    一.时间序列分析 北京每年每个月旅客的人数,上海飞往北京每年的游客人数等类似这种顾客数.访问量.股价等都是时间序列数据.这些数据会随着时间变化而变化.时间序列数据的特点是数据会随时间的变化而变化. 随 ...

  10. shell 脚本实现定时备份mysql数据库

    首先要知道直接在脚本中输入mysql的密码是不被允许的,但是我们可以曲线救国 1. 在新建一个文件专门用来存储用户密码 如: vim ./.mysql.conf [mysqldump] user=yo ...