zoukankan      html  css  js  c++  java
  • Ansible-Zabbix-基础agent批量装机

    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连接

    魅力男神
  • 相关阅读:
    ReSharper.8.0.14.856注册码
    asp.net 301重定向代码
    WebResource.axd 404 错误
    【原创】asp.net导出word 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件失败,原因是出现以下错误: 8000401a
    C#操作word或excel及水晶报表,检索 COM 类工厂中 CLSID 为 {} 的组件时失败,原因是出现以下错误: 80070005
    Repository 设计模式介绍
    将15位身份证转换成18位
    清理数据库木马文件
    Oracle的创建表空间及用户
    使用python脚本执行地理处理工具
  • 原文地址:https://www.cnblogs.com/capable/p/10651226.html
Copyright © 2011-2022 走看看