Install Zabbix Monitoring Tool On CentOS, RHEL, Scientific Linux 6.5

Zabbix is an enterprise-class open source distributed monitoring solution that can be used to monitor and track performance and availability of network servers, devices and other IT resources. It supports distributed and WEB monitoring, auto-discovery, and more.

I tested this how-to On CentOS 6.5, although it should work on other RHEL/CentOS 6.x versions. For the testing purpose, I will use two machines.

Zabbix Server System:

Operating system: CentOS 6.5
IP Address: 192.168.1.101/24
Hostname: server.unixmen.local

Zabbix Client System:

Operating system: Ubuntu 13.04
IP Address: 192.168.1.100/24
Hostname: sk

First let us start from server side.

Prerequisites

Before installing Zabbix, we should have install and configure LAMP stack on server. To install and configure LAMP server On Debian 7 and Ubuntu 13.10, refer the following links.

Install LAMP Server On RHEL/CentOS/Scientific Linux 6

Server Side Configuration

Hence Zabbix is not found in the default repositories, we have to add EPEL repository to install Zabbix. To install EPEL repository, follow the below link:

Install EPEL Repository On RHEL / CentOS 6

Now update repository and  Zabbix server using commands:

# yum update 
# yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql

Create MySQL database and user for Zabbix

Let us create a database called ‘zabbix’ and database user called ‘zabbix’ with password ‘centos’.

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.35 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix;
Query OK, 1 row affected (0.05 sec)

mysql> GRANT ALL ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'centos';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

Import zabbix templates to Zabbix database

Let us import the following templates. It will ask you the zabbix password during importing templates.

# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/schema/mysql.sql
# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/data/data.sql
# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/data/images_mysql.sql

Configure Zabbix server

Edit file /etc/zabbix/zabbix_server.conf,

# vi /etc/zabbix/zabbix_server.conf

Set the database name, user and password which you’ve created earlier. If the lines are commented out, uncomment and set the correct values.

[...]
DBName=zabbix
[...]
DBUser=zabbix
[...]
DBPassword=centos
[...]

Save and close the file.

Edit file /etc/zabbix/zabbix_agentd.conf,

# vi /etc/zabbix/zabbix_agentd.conf

Set the zabbix server hostname.

[...]
Hostname=server.unixmen.local
[...]

Adjust PHP settings

We should adjust phip.ini file as per zabbix recommended settings.

Edit file php.ini,

# vi /etc/php.ini

Set the values as shown below. If the lines doesn’t exist, add them.

max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Kolkata

Save and close the file.

Adjust Firewall settings

Adjust iptables to allow the zabbix ports 10050 and 10051.

# vi /etc/sysconfig/iptables

Add the following lines:

[...]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
[...]

Restart iptables service to take effect the changes.

# service iptables restart

Allow Zabbix web console for particular IP range (Optional)

Edit file /etc/httpd/conf.d/zabbix.conf,

# vi /etc/httpd/conf.d/zabbix.conf

Add the ip range that you want to allow to access zabbix web interface. This is optional. If you set Allow from All, you can access zabbix from any network. In my case i allowed the 192.168.1.0/24 series.

Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from 192.168.1.0/24
</Directory>

Save and close the file. Start/Restart zabbix and httpd services and make them to start automatically on every reboot.

# service zabbix-server start
# service zabbix-agent start
# service httpd restart
# service mysqld restart
# chkconfig zabbix-server on 
# chkconfig zabbix-agent on

Access Zabbix Web console

We have completed the installation and configuration part. Now let us setup the zabbix web console. Navigate to http://ip-address/zabbix or http://domain-name/zabbix.

Click Next.

Installation - Mozilla Firefox_001Accept the License agreement.

Installation - Mozilla Firefox_002The installer will check for necessary prerequisites. If everything seems OK, click Next to continue, else go back and install the necessary packages.

Installation - Mozilla Firefox_003Enter the zabbix database name, database user and password and click Test connection. If you entered the correct values, it will show a message that says: OK. Click Next to continue.

Installation - Mozilla Firefox_001Enter your server name and Click Next:

Installation - Mozilla Firefox_002Check the pre-installation summary, if everything good, click Next to continue or click Previous to change the parameters.

Installation - Mozilla Firefox_003Click Next:

Installation - Mozilla Firefox_007Congratulations! You’ve have successfully completed the installation. Click Finish to complete the installation.

Installation - Mozilla Firefox_008Now you’ll be redirected to the zabbix web console page. Enter the username and password. The default username/password is admin/zabbix.

server.unixmen.local: ZABBIX - Mozilla Firefox_004This is how the admin dashboard looks:

ZABBIX - Mozilla Firefox_010Activate Zabbix server

Initially, the zabbix server is deactivated from being monitored. To activate it, go to Configuration -> Hosts. Select the host(zabbix server) and choose Activate selected from the drop-down box and click Go.

Hosts - Mozilla Firefox_011Now you should see the host is being monitored.

Hosts - Mozilla Firefox_012Check Zabbix server Statistics

After a few seconds, click on the Monitoring tab on the top menu bar and select “Latest data”. You’ll see the zabbix server details:

server.unixmen.local: Latest data [refreshed every 30 sec] - Mozilla Firefox_006

Client Side Configuration

Let us install zabbix agent on our client systems. To install zabbix client packages on Fedora/RHEL clients, enter the following command in Terminal:

$ sudo yum install zabbix-agent

On Ubuntu/Debian clients:

$ sudo apt-get install zabbix-agent

Configure Clients

Next edit file /etc/zabbix/zabbix_agentd.conf,

$ sudo vi /etc/zabbix/zabbix_agentd.conf

Add the server ip address and client hostname.

[...]
Server=192.168.1.101
[...]
Hostname=sk
[...]

Where,

192.168.1.101 – CentOS 6.5 IP address(Zabbix server).

sk – Ubuntu 13,04 hostname(client hostname).

Now restart zabbix-agent service with command:

$ sudo service zabbix-agent start

Add Monitoring host

Go to your zabbix server dashboard. To add a monitoring target, navigate to Configuration -> Hosts. Click on Create Host on the right side.

server.unixmen.local: Hosts - Mozilla Firefox_007Enter Hostname, select Groups and IP address as shown below.

server.unixmen.local: Hosts - Mozilla Firefox_008Click Add on the right side and select the template to use.

server.unixmen.local: TEMPLATES - Mozilla Firefox_009Finally click Save on the bottom to go back to the previous windows. Now you will see that the new host has been added to the Monitoring list.

server.unixmen.local: Hosts - Mozilla Firefox_010That’s it. I have covered only basic things. Explore all the options and tweak them as per your requirement to get better monitoring solution. Good luck!

Reference Links:

Zabbix Home page