Menu

Install Zabbix 3.0 (Monitoring Server) on CentOS 7.x / RHEL 7.x

Zabbix is a mature and effortless enterprise-class open source monitoring solution for network monitoring and application monitoring of millions of metrics.
Zabbix uses database like MySQL, MariaDB, Oracle and IBM DB2 to store its data. Zabbix web interface is written in PHP.
Some of its key features are listed below :
  • Monitor everything which is on network like Servers, applications, database instance and network devices.
  • Zabbix provides Web based administration interface.
  • Monitoring CPU utilization of a particular process or a group of process ( proc.cpu.util)
  • Using low-level discovery rules, zabbix can discover Vmware hypervisor ( ESXI ) and Virtual machines.
  • Zabbix also supports agentless monitoring
  • Monitoring of database servers like MySQL, PostgreSQL, Oracle and Microsoft SQL Server.
  • Zabbix can also perform the task of capacity planning for your environment.
  • Zabbix is Open Source so no cost involved and can be deployed on small and large environment.
  • Hardware Monitoring using Zabbix via IPMI credentials.
  • Network Device monitoring using snmp agents.
Below are the details of my server on which i will install Zabbix.
Hostname = zabbix.hackthesec.co.in
IP Address = 192.168.2.2
OS = CentOS 7.x / RHEL 7.x
Step:1 Enable EPEL and Zabbix Repository
[hackthesec@zabbix ~]# yum install epel-release
[hackthesec@zabbix ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Step:2 Install Zabbix Server, Database, Web Server and PHP packages
Use the below command to install rpm package of Zabbix server, Database Sever (MariaDB) , Web Server ( http) and PHP.
[hackthesec@zabbix ~]# yum -y install zabbix-server-mysql zabbix-web-mysql mysql mariadb-server httpd php
Step:3 Configure Zabbix Database.
Start the Database (MariaDB) service
[hackthesec@zabbix ~]# systemctl start mariadb
[hackthesec@zabbix ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[hackthesec@zabbix ~]#
Use ‘mysql_secure_installation‘ command to set the root password of mariadb database and configure other parameters like ‘Remove anonymous users‘, ‘Disallow root login remotely‘ and ‘Remove test database and access to it‘
[hackthesec@zabbix ~]# mysql_secure_installation
Now create the Zabbix Database (zabbix_db) and database user (zabbix_user) and grant all privileges to the user on the Zabbix database.
[hackthesec@zabbix ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> create database zabbix_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix_db.* to zabbix_user@localhost identified by <new_password>;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[hackthesec@zabbix ~]#
Now import the database Schema using below commands,
[hackthesec@zabbix ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.1
[hackthesec@zabbix zabbix-server-mysql-3.0.1]# gunzip create.sql.gz
[hackthesec@zabbix zabbix-server-mysql-3.0.1]# mysql -u root -p zabbix_db < create.sql
Enter password:
[hackthesec@zabbix zabbix-server-mysql-3.0.1]#
Step:4 Edit Zabbix Server Configuration file
Edit the Zabbix Server’s config file (/etc/zabbix/zabbix_server.conf) and specify the database name for zabbix , database user name & its password.
[hackthesec@zabbix ~]# vi /etc/zabbix/zabbix_server.conf
...................................
DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=XXXXXXX
...................................
Save & exit the file.
Configure PHP Setting
Set the below parameters in the PHP config file (/etc/php.ini )
[hackthesec@zabbix ~]# vi /etc/php.ini
................................
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Kolkata
...............................
Allow the ports in the Firewall
[hackthesec@zabbix ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[hackthesec@zabbix ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[hackthesec@zabbix ~]# firewall-cmd --permanent --add-port=80/tcp
success
[hackthesec@zabbix ~]# firewall-cmd --reload 
success
[hackthesec@zabbix ~]# systemctl restart firewalld
[hackthesec@zabbix ~]#
Set the below Selinux rule.

[hackthesec@zabbix ~]# setsebool -P httpd_can_connect_zabbix=1
Start the Zabbix and Web Server Service and make sure it is enable across the reboot.
[hackthesec@zabbix ~]# systemctl start zabbix-server
[hackthesec@zabbix ~]# systemctl enable zabbix-server
ln -s '/usr/lib/systemd/system/zabbix-server.service' '/etc/systemd/system/multi-user.target.wants/zabbix-server.service'
[hackthesec@zabbix ~]# 
[hackthesec@zabbix ~]# systemctl start httpd
[hackthesec@zabbix ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[hackthesec@zabbix ~]#
Step:5 Browse the Zabbix Web interface using below URL
http://192.168.2.2/zabbix/ 
or 
http://zabbix.hackthesec.co.in./zabbix
Replace the IP address or hostname as per your setup.

Click on 'Next step'
On this Step Zabbix Pre-requisites are checked and verified
Click on 'Next step'
Specify the Zabbix Database name, database user and its password.

Specify the Zabbix Server details and Port number.
Click on 'Next step' to continue.
Pre-installation summary of Zabbix Servers, click on 'Next step' to continue.
As we can see that Zabbix installation is completed successfully
When we click on 'finish' , it will re-direct us to the Zabbix web interface Console.
Use user name as 'admin' and password 'zabbix'
Zabbix Server Dashboard :
Step:6 Add a node to Zabbix Server for Monitoring.
Let’s assume i want to add my Ubuntu 16.04 Machine to Zabbix Server for monitoring. Login to the machine and perform the following tasks .
hackthesec@aws:~$ sudo apt-get install zabbix-agent
Edit the Agent file and specify the Zabbix Server address.
hackthesec@aws:~$ sudo vi /etc/zabbix/zabbix_agentd.conf
..................................
Server=192.168.2.2
ServerActive=192.168.2.2
Hostname=aws.hackthesec.co.in
..................................
Start Zabbix Agent Service
hackthesec@aws:~$ sudo systemctl start zabbix-agent
hackthesec@aws:~$ sudo systemctl enable zabbix-agent
Synchronizing state of zabbix-agent.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable zabbix-agent
hackthesec@aws:~$
Now Go to the Zabbix Web Interface .

Click on Configuration —> Hosts –> Create Host
Specify the Host name, IP address and Group names. In Templates Tab, search appropriate templates and click on Add.
To View the events for all the hosts or a particular host, Click on Monitoring —> Triggers

Zabbix Email-Notification Setting
E-mail settings
Initially there are several predefined notification delivery methods in Zabbix. E-mail is one of those.

To configure e-mail settings, go to Administration → Media types and click on Email in the list of pre-defined media types.

This will present us with the e-mail settings definition form.

Set the values of SMTP server, SMTP helo and SMTP e-mail to the appropriate for your environment.Press Update when ready.
Now you have configured 'Email' as a working media type. A media type must be linked to users by defining specific delivery addresses (like we did when configuring a new user), otherwise it will not be used.
New action

Delivering notifications is one of the things actions do in Zabbix. Therefore, to set up a notification, go to Configuration → Actions and click on Create action.
In this form, enter a name for the action.

{TRIGGER.STATUS} and {TRIGGER.NAME} macros (or variables), visible in the Default subject and Default message fields, will be replaced with the actual trigger status and trigger name values.

In the most simple case, if we do not add any more specific conditions, the action will be taken upon any trigger change from 'Ok' to 'Problem'.


We still should define what the action should do - and that is done in the Operations tab. Click on New in there, which opens a new operation form.

Here, click on Add in the Send to Users block and select the user ('user') we have defined. Select 'Email' as the value of Send only to. When done with this, click on Add in the operation detail block.


That is all for a simple action configuration, so click Add in the action form.

About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a Comment

 
Top