This article is part of an Essential Guide, our editor-selected collection of our best articles, videos and other content on this topic. Explore more in this guide:
1. - Helpful administrative tools for Linux in the enterprise: Read more in this section
- Graphical monitoring and management with RHEL
- Exploring an open source monitoring system for Linux
- SELinux management for business security
- How to set up Zabbix for Linux monitoring
- Setup for standard high-availability Linux software
- Commands for fixing some SELinux virtualization issues
Explore other sections in this guide:
- 2. - Lifting Linux workloads off-premises
- 3. - Breathing new life into big iron
- 4. - Test your Linux skills with this quiz
In a data center, it is important to know what is happening to which machines. Proper monitoring of nodes can help prevent problems with network functionality. In this series of articles, you'll learn how to do this with Zabbix.
Zabbix is an open source network monitoring tool that works with a centralized Linux-based Zabbix server. The server communicates to the native agents that are available for many operating systems, including Linux, UNIX and Windows. For operating systems without an agent, generic monitoring protocols such as SNMP or IPMI can be used.
The advantages of using the Zabbix monitoring tool are many. For starters, Zabbix can send out alerts and notifications if specific predefined events are occurring. It also provides graphing functionality, which allows the administrator to get an overview of the current state of specific nodes and the network in general.
To get a working Zabbix environment, you'll need to start with the server. To interact with this server, the administrator will use a Zabbix front-end interface, which talks to the Zabbix server and database. All three -- interface, server and database -- can reside on the same server, but there is an option to install them on different machines if you want a more distributed environment. The Zabbix server can directly monitor devices on the same network, but if the devices are on another network, a Zabbix proxy is often used.
Zabbix installation options
There are two ways to install Zabbix: Download the source packages and install them on the Linux host for your Zabbix server, or use the packages included with some Linux distributions. Using the distribution packages makes installing and updating Zabbix easier, but compiling your own Zabbix means that it will work for every Linux distribution and include the latest and greatest features.
Precompiled packages are not available for some Linux distributions, such as SUSE. If you don't want to deal with the underlying Linux operating system, Fedora or Ubuntu might be the best bet. They both contain the Zabbix packages right from the installation repositories. Compiling your own will also work, but it requires additional Linux knowledge. In this article, we will install Zabbix using precompiled packages on Fedora 17, which is available for free.
Installing base packages
Make sure your Fedora Linux server has at least 10 GB of available disk space. You won't need that for the initial Zabbix installation, but you will need it if Zabbix starts filling the database in a larger environment.
Next, use the Yellow Dog Updater Modified (YUM) command yum install zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql mysql zabbix-agent to install Zabbix and all of its required components. After installing the software, you need to start the zabbix services and make sure that they'll start after a reboot of your server. To accomplish this, run the following commands and reboot your server:
systemctl enable mysqld.service
systemctl enable zabbix-server-mysql.service
systemctl enable httpd.service
Before continuing, you'll need to create a MySQL database. Use mysql -u root to log in as a root user. This opens a mysql prompt. Enter the following commands to create the required database:
mysql> create database zabbix character set
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by ‘password';
The database has the default name zabbix, and the administrator name is zabbix, with the password as password. You now need to populate the database with the Zabbix schema and some initial data. To do this, you can use the default SQL files that have been installed in /usr/share/doc/zabbix-server-mysql-<version>/create/schema. Import the files by using the following mysql commands from a Linux shell:
# mysql -u zabbix -p zabbix <
# mysql -u zabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-<VERSION>/create/data/data.sql
# mysql -u zabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-<VERSION>/create/data/images_mysql.sql
These commands will import the SQL files in the MySQL database, using the user account "zabbix." The option -p tells the mysql command to prompt for a password, and the argument zabbix tells MySQL to add all of these data to the zabbix database. Next, the input file is specified by using input redirection (<), which is followed by the name of the file that is to be used as the input file.
Before you continue the configuration, make sure Zabbix can connect to the database you've just created. To do this, open the configuration file /etc/zabbix/zabbix_server.conf and make sure the following lines are included:
Restart your server and make sure everything comes up correctly. After restarting, use the command systemctl status zabbix-server.service. This should show a list of Zabbix processes that have been started.
Connecting to the Web interface
Once everything is started, you can open a browser session to the Zabbix Web front end at http://yourzabbixserver/zabbix, where you can configure your Zabbix server.
The first import screen checks the prerequisites. In many cases, you will find the default PHP settings that your distribution uses are insufficient, so make a note of the settings concerned and open /etc/php.ini to change them. After making the changes, restart the Apache service. On Fedora 17, do this by issuing the systemctl restart httpd.service command.
In the next window, configure the connection between Zabbix and the database. In this screen, the default user name root is used; make sure to change this to zabbix.
After creating the database connection, enter the location where the Zabbix server can be found and the port you're using. If the Web front end is running elsewhere from the server process, specify the IP address where the Zabbix server can be reached or just type "next" to continue. You'll now see a preinstallation summary. Verify that the parameters are OK and then finish the installation procedure. This gives you access to a Zabbix login window, where you can log in as the default user Admin with the password zabbix. Your zabbix environment is now ready for use.
In the next article of this series, you'll learn how to start monitoring systems with Zabbix.
ABOUT THE AUTHOR
Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance, and has completed several projects that implement all three. He is also the writer of various Linux-related books, such as Beginning the Linux Command Line, Beginning Ubuntu Server Administration and Pro Ubuntu Server Administration.