4

How to Install and configure Zabbix agent 3.4 on CentOS 7

 2 years ago
source link: https://computingforgeeks.com/how-to-install-and-configure-zabbix-agent-3-4-on-centos-7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to Install and configure Zabbix agent 3.4 on CentOS 7
Search

In our previous guide, we covered the installation of Zabbix Server on Ubuntu 18.04. This is a continuation guide on Zabbix monitoring of your entire Infrastructure – Linux systems, Windows servers, network routers, network switches e.t.c. So let’s get started with how to Install and configure Zabbix agent 3.4 on CentOS 7.

For Ubuntu servers, check How to Install and configure Zabbix agent on Ubuntu 18.04/16.04

Zabbix agent is a program developed in C. It runs on various supported platforms, including Linux, UNIX, and Windows. The work of Zabbix agent is to collect data such as CPU, memory, disk and network interface usage from a device. It has a small resource footprint considering that monitoring configurations are centralized on Zabbix server.

image from zabbix

How Zabbix agent works

Zabbix agent can do both passive (polling) and active checks (trapping). The checks can be performed at an interval or based on specific times schedule. Here is the difference between passive and active checks:

Passive checks (polling):

  • Zabbix server (or proxy) requests a value from Zabbix agent
  • Agent processes the request and returns the value to Zabbix server (or proxy)

Active checks (trapping):

  • Zabbix agent requests from Zabbix server (or proxy) a list of active checks
  • The agent sends the results in periodically

The image below from Zabbix may help visualize passive and active checks in action:

image from zabbix.com

How to Install Zabbix agent on CentOS 7

Below steps are used to install Zabbix agent on CentOS 7

Step 1: Add Zabbix repositories

Add Zabbix 3.4 repositories using the commands below:

$ sudo yum install http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
Loaded plugins: fastestmirror
zabbix-release-3.4-2.el7.noarch.rpm | 13 kB 00:00:00 
Examining /var/tmp/yum-root-oWkdRD/zabbix-release-3.4-2.el7.noarch.rpm: zabbix-release-3.4-2.el7.noarch
Marking /var/tmp/yum-root-oWkdRD/zabbix-release-3.4-2.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package zabbix-release.noarch 0:3.4-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================
Package Arch Version Repository Size
====================================================================================
Installing:
zabbix-release noarch 3.4-2.el7 /zabbix-release-3.4-2.el7.noarch 21 k

Transaction Summary
====================================================================================
Install 1 Package

Total size: 21 k
Installed size: 21 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zabbix-release-3.4-2.el7.noarch 1/1 
Verifying : zabbix-release-3.4-2.el7.noarch 1/1

Installed:
zabbix-release.noarch 0:3.4-2.el7

Complete!

Once the repo has been added, install Zabbix agent by executing the following command on your terminal.

$ sudo yum install zabbix-agent zabbix-sender
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.clouvider.net
 * extras: centos.serverspace.co.uk
 * updates: repo.uk.bigstepcloud.com
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:3.4.10-1.el7 will be installed
---> Package zabbix-sender.x86_64 0:3.4.10-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================
 Package                Arch            Version               Repository       Size
====================================================================================
Installing:
 zabbix-agent           x86_64          3.4.10-1.el7          zabbix          365 k
 zabbix-sender          x86_64          3.4.10-1.el7          zabbix          264 k

Transaction Summary
====================================================================================
Install  2 Packages

Total download size: 629 k
Installed size: 2.4 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-3.4.10-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Public key for zabbix-agent-3.4.10-1.el7.x86_64.rpm is not installed
(1/2): zabbix-agent-3.4.10-1.el7.x86_64.rpm                  | 365 kB  00:00:00     
(2/2): zabbix-sender-3.4.10-1.el7.x86_64.rpm                 | 264 kB  00:00:00     
------------------------------------------------------------------------------------
Total                                                  722 kB/s | 629 kB  00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Importing GPG key 0xA14FE591:
 Userid     : "Zabbix LLC <[email protected]>"
 Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
 Package    : zabbix-release-3.4-2.el7.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : zabbix-agent-3.4.10-1.el7.x86_64                                                                                                                       1/2 
  Installing : zabbix-sender-3.4.10-1.el7.x86_64                                                                                                                      2/2 
  Verifying  : zabbix-sender-3.4.10-1.el7.x86_64                                                                                                                      1/2 
  Verifying  : zabbix-agent-3.4.10-1.el7.x86_64                                                                                                                       2/2 

Installed:
  zabbix-agent.x86_64 0:3.4.10-1.el7                                                  zabbix-sender.x86_64 0:3.4.10-1.el7                                                 

Complete!

Step 2: Configuring Zabbix Agent

Zabbix agent configuration is /etc/zabbix/zabbix_agentd.conf. Edit

# cat /etc/zabbix/zabbix_agentd.conf
# On line 97 - Specify Zabbix server IP Address
Server=192.168.10.2
# On line 138 - Specify Zabbix server ( For active checks)
ServerActive=192.168.10.2
# On line 150 - Set server hostname reported by Zabbix agent
Hostname=node-01.computingforgeeks.com

Start zabbix-agent after making the change, also enable the service to start on boot:

$ sudo systemctl start zabbix-agent
$ sudo systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

You can check service status using the command:

$ sudo systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-06-15 14:55:00 UTC; 20s ago
Main PID: 28026 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─28026 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─28027 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─28028 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─28029 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─28030 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─28031 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Jun 15 14:55:00 node-01.computingforgeeks.com systemd[1]: Starting Zabbix Agent...
Jun 15 14:55:00 node-01.computingforgeeks.com systemd[1]: Started Zabbix Agent.

If you have firewalld enabled, allow port 10050/tcp on the firewall. This is used by Zabbix agent daemon.

$ sudo firewall-cmd --permanent --add-port=10050/tcp
success
$ sudo firewall-cmd --reload
success

You can check service port if listening using ss or netstat commands:

# ss -tunelp | grep 10050
tcp    LISTEN     0      128       *:10050                 *:*                   users:(("zabbix_agentd",pid=28031,fd=6),("zabbix_agentd",pid=28030,fd=6),("zabbix_agentd",pid=28029,fd=6),("zabbix_agentd",pid=28028,fd=6),("zabbix_agentd",pid=28027,fd=6),("zabbix_agentd",pid=28026,fd=6)) uid:385 ino:15465825 sk:ffffa119c2e264c0 <->
tcp    LISTEN     0      128      :::10050                :::*                   users:(("zabbix_agentd",pid=28031,fd=7),("zabbix_agentd",pid=28030,fd=7),("zabbix_agentd",pid=28029,fd=7),("zabbix_agentd",pid=28028,fd=7),("zabbix_agentd",pid=28027,fd=7),("zabbix_agentd",pid=28026,fd=7)) uid:385 ino:15465826 sk:ffffa11973db8880 v6only:1 <-

Step 3: Add host to Zabbix Server

Login to admin Zabbix server interface, and go to Configuration > Hosts > Create host. Provide the following information:

  • Host name of the server to be monitored
  • Visible name for the server to be monitored.
  • Select the group or add a new group for “Groups” field.
  • IP address
  • Zabbix agent service port -default is 10050

Then go to Templates tab.

1. Click the select button under Link new templates section

Select the templates you want to use:

2. Once you have selected the templates, click on the Add link to link templates to your target systemAfter the templates are linked, they’ll appear on the  Linked templates section

Update the setting using Update button.

After few minutes, monitoring data will be collected and you can visualize them using Zabbix graphs. Default host graphs can be accessed on

Monitoring > Graphs > <Host|Graph>

Below are the Ram and CPU utilization graphs for the host we added earlier.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK