Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Zabbix Cookbook
  • Table Of Contents Toc
Zabbix Cookbook

Zabbix Cookbook

By : Patrik Uytterhoeven
4.5 (4)
close
close
Zabbix Cookbook

Zabbix Cookbook

4.5 (4)
By: Patrik Uytterhoeven

Overview of this book

If you have some experience with Zabbix and wish to take your infrastructure to the next level, then this book is for you. Before you start with Zabbix, or monitoring in general, it is best to have some basic Linux knowledge and a good understanding of snmp, virtualization, and scripting.
Table of Contents (13 chapters)
close
close
12
Index

Agent installation and configuration

In this section, we will explain you the installation and configuration of the Zabbix agent. The Zabbix agent is a small piece of software about 700 KB in size. You will need to install this agent on all your servers to be able to monitor the local resources with Zabbix.

Getting ready

In this recipe, to get our Zabbix agent installed, we need to have our server with the Zabbix server up and running as explained in Server installation and configuration. In this setup, we will install our agent first on the Zabbix server. We just make use of the Zabbix server in this setup to install a server that can monitor itself. If you monitor another server then there is no need to install a Zabbix server, only the agent is enough.

How to do it...

Installing the Zabbix agent is quite easy once our server has been set up. The first thing we need to do is install the agent package.

Installing the agent packages can be done by running yum as we have already added the repository to our package manager in the previous recipe Server installation and configuration. In case you have skipped it, then go back and add the Zabbix repository to your package manager.

  1. Install the Zabbix agent from the package manager:
    # yum install zabbix-agent
    
  2. Open the correct port in your firewall. The Zabbix server communicates to the agent if the agent is passive. So, if your agent is on a server other than Zabbix, then we need to open the firewall on port 10050. (We shall further explain active and passive agents in Chapter 4).
  3. Edit the firewall, open the file /etc/sysconfig/iptables and add the following after the line with dport 22 in the next line:
    # -A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
    
  4. Users of RHEL 7 can run:
    # firewall-cmd --permanent --add-port=10050/tcp
    
  5. Now that the firewall is adjusted, you can restart the same:
    # service iptables restart
    # firewall-cmd --reload (if you use RHEL 7)
    

    The only thing left to do is edit the zabbix_agentd.conf file, start the agent, and make sure it starts after a reboot.

  6. Edit the Zabbix agent configuration file and add or change the following settings. We will see later in Chapter 4 the difference between active and passive; for now just fill in both variables.
    # vi /etc/zabbix/zabbix_agentd.conf
    Server=<ip of the zabbix server>
    ServerActive=<ip of the zabbix server>
    

    That's all for now in order to edit in the zabbix_agentd.conf file.

  7. Now, let's start the Zabbix agent:
    # service zabbix-agent start
    # systemctl start zabbix-agent (if you use RHEL 7)
    
  8. And finally make sure that our agent will come online after a reboot:
    # chkconfig zabbix-agent on
    # systemctl enable zabbix-agent (for RHEL 7 users)
    
  9. Check again that there are no errors in the log file from the agent:
    # tail /var/log/zabbix/zabbix_agentd.log
    

How it works...

The agent we have installed is installed from the Zabbix repository on the Zabbix server, and communicates to the server on port 10051 if we make use of an active agent. If we make use of a passive agent, then our Zabbix server will talk to the Zabbix agent on port 10050. Remember that our agent is installed locally on our host; so all communication stays on our server. This is not the case if our agent is installed on another server instead of our Zabbix server. We have edited the configuration file from the agent and changed the Server and ServerActive options. Our Zabbix agent is now ready to communicate with our Zabbix server. Based on the two parameters we have changed, the agent knows what the IP is from the Zabbix server.

The difference between passive and active modes is that the client in passive mode will wait for the Zabbix server to ask for data from the Zabbix agent.

The agent in active mode will ask the server first what it needs to monitor and pull this data from the Zabbix server. From that moment on, the Zabbix agent will send the values by itself to the server at regular intervals.

So when we use a passive agent the Zabbix server pulls the data from the agent where a active agent pushes the data to the server.

We did not change the hostname item in the zabbix_agentd.conf file, a parameter we normally need to change and give the host a unique name. In our case the name in the agent will already be in the Zabbix server that we have installed, so there is no need to change it this time.

There's more...

Just like our server, the agent has a plenty more options to set in its configuration file. So open the file again and have a look at what else we can adjust. In the following URLs you will find all options that can be changed in the Zabbix agent configuration file for Unix and Windows:

https://www.zabbix.com/documentation/2.4/manual/appendix/config/zabbix_agentd.

https://www.zabbix.com/documentation/2.4/manual/appendix/config/zabbix_agentd_win.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Zabbix Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon