Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ansible bulk install Zabbix-agnet client

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The previous article introduced the installation tutorial of Zabbix server, and here are two ways to install client-side Zabbix-agent:

One: single installation

1. Install the client

[root@centos78 ~] # yum install zabbix-agent-y

2. Edit the configuration file

[root@centos78 ~] # vim / etc/zabbix/zabbix_agentd.conf

Modify server, hostname, serveractive information

[root@centos78 ~] # systemctl restart zabbix-agent

[root@centos78 ~] # systemctl enable zabbix-agent

Second, batch installation:

If you have a large number of clients and you want to use operation and maintenance automation for batch installation, you need to install the clients in batch with ansible.

1. Install the associated components

[root@centos78 ~] # yum install gcc* pcre*-y (error will be reported if script push is missing)

[root@centos78 ~] # yum install epel-release-y

2. Install ansible components

[root@centos78 ~] # yum install ansible-y

3. Configure ssh secret-free communication

[root@centos78 ~] # ssh-keygen (you can hit enter continuously)

[root@centos78 ~] # ssh-copy-id 192.168.101.78

[root@centos78 ~] # ssh-copy-id 192.168.101.75

4. Configure ansible, edit hosts, and define groups

[root@centos78 ~] # vim / etc/ansible/hosts

[zabbix]

192.168.101.75

192.168.101.78

Whether the ping client communicates

[root@centos78] # ansible zabbix-m ping

192.168.101.78 | SUCCESS = > {

"changed": false

"ping": "pong"

}

192.168.101.75 | SUCCESS = > {

"changed": false

"ping": "pong"

}

5. Configure batch push scripts

[root@centos78 ~] # cd / etc/ansible/

[root@centos78 ansible] # cat zabbix_agent.yml (deploy the ansible client using ansible's jinjia template)

-hosts: zabbix

Remote_user: root

Tasks:

-name: install zabbix_agent packages

Yum: name= {{item}} state=latest

With_items:

-curl-devel

-name: copy install_shell to clien

Copy: src=/etc/ansible/zabbix_agent.sh dest=/usr/local/src/zabbix_agent.sh

-name: sent tar

Copy: src=/usr/local/src/zabbix-3.4.12.tar.gz dest=/usr/local/src/zabbix-3.4.12.tar.gz (if there is no installation package, you can download it according to operation)

Notify: install shell

Handlers:

-name: install shell

Shell: / bin/bash / usr/local/src/zabbix_agent.sh

6. Download the client zabbix-3.4.12.tar.gz for batch installation

[root@centos78 ansible] # cd / usr/local/src/ (download path is the same as script path)

[root@centos78 src] # wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz

[root@centos78 ansible] # cd / usr/local/src/ (download path is the same as script path)

7. Edit script content

[root@centos78 ansible] # cat zabbix_agent.sh

#! / bin/bashuseradd zabbix- 's / sbin/nologincd / usr/local/srctar-xf zabbix-3.4.12.tar.gzcd zabbix-3.4.12./configure-- with-net-snmp-- with-libcurl-- enable-agent-- prefix=/usr/local/zabbixmake & & make installcp misc/init.d/fedora/core5/zabbix_agentd / etc/init.d/chmod 700 / etc/init.d/zabbix_agentdsed-I's\ ZABBIX_BIN= "/ usr/local/sbin / zabbix_agentd\ ZABBIX_BIN= "/ usr/local/zabbix/sbin/zabbix_agentd\ g' / etc/init.d/zabbix_agentdsed-I's\ Server=127.0.0.1\ Server=192.168.101.78\ g' / usr/local/zabbix/etc/zabbix_agentd.confsed-I's\ ServerActive=127.0.0.1\ ServerActive=192.168.101.78\ g' / usr/local/zabbix/etc/zabbix_agentd.conf / etc/init.d/zabbix_agentd startchkconfig zabbix_agentd on

8. Execute script to install the client in batch

[root@centos78 ansible] # ansible-playbook zabbix_agent.yml

PLAY [zabbix] *

TASK [Gathering Facts] *

Ok: [192.168.101.78]

Ok: [192.168.101.75]

TASK [install zabbix_agent packages] *

Ok: [192.168.101.75] = > (item= [u 'curl-devel'])

Ok: [192.168.101.78] = > (item= [u 'curl-devel'])

TASK [copy install_shell to clien] *

Ok: [192.168.101.78]

Ok: [192.168.101.75]

TASK [sent tar] *

Ok: [192.168.101.78]

Ok: [192.168.101.75]

PLAY RECAP *

192.168.101.75: ok=4 changed=0 unreachable=0 failed=0

192.168.101.78: ok=4 changed=0 unreachable=0 failed=0

Check to see if zabbix client is running

[root@centos78 ansible] # ansible zabbix-m shell-a "ps-ef | grep zabbix_agentd"

192.168.101.78 | SUCCESS | rc=0 > >

Zabbix 11785 1 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd

Zabbix 11787 11785 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]

Zabbix 11788 11785 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: listener # 1 [waiting for connection]

Zabbix 11789 11785 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: listener # 2 [waiting for connection]

Zabbix 11790 11785 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: listener # 3 [waiting for connection]

Zabbix 11791 11785 0 22:33? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: active checks # 1 [idle 1 sec]

Root 17136 17131 0 23:52 pts/1 00:00:00 / bin/sh-c ps-ef | grep zabbix_agentd

Root 17138 17136 0 23:52 pts/1 00:00:00 grep zabbix_agentd

192.168.101.75 | SUCCESS | rc=0 > >

Zabbix 21448 1 0 22:20? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd

Zabbix 21450 21448 0 22:20? 00:00:01 / usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]

Zabbix 21451 21448 0 22:20? 00:00:01 / usr/local/zabbix/sbin/zabbix_agentd: listener # 1 [waiting for connection]

Zabbix 21452 21448 0 22:20? 00:00:01 / usr/local/zabbix/sbin/zabbix_agentd: listener # 2 [waiting for connection]

Zabbix 21453 21448 0 22:20? 00:00:01 / usr/local/zabbix/sbin/zabbix_agentd: listener # 3 [waiting for connection]

Zabbix 21454 21448 0 22:20? 00:00:00 / usr/local/zabbix/sbin/zabbix_agentd: active checks # 1 [idle 1 sec]

Root 23645 23640 0 23:52 pts/1 00:00:00 / bin/sh-c ps-ef | grep zabbix_agentd

Root 23647 23645 0 23:52 pts/1 00:00:00 grep zabbix_agentd

The zabbix client is already configured by bulk installation using ansible, and the client basic components, such as make, should also be installed during batch installation.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report