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

    魅力男神
  • 相关阅读:
    Laravel artisan 命令工具
    WIN10安装office2003/7失败 WIN10安装office2003权限不足解决
    64windows位安装tensorflow
    Swing图层的应用——实现tooltip显示
    spring加载xml的六种方式
    ubuntu 添加右键打开方式,无法添加程序打开方式
    3.3.4 配置Tomcat的<Context>元素 (转)
    百度tn劫持解决办法
    java代理模式
    js作用域
  • 原文地址:https://www.cnblogs.com/capable/p/10651226.html
Copyright © 2020-2023  润新知