Skip to main content

How To Install and Configure Zabbix to Securely Monitor Remote Servers on CentOS 7

Prerequisites

To follow this tutorial, you will need:
  • One of the CentOS 7 servers needs Apache, MySQL, and PHP installed. in my blog already a tutorial there for lamp installation in CentOS 7.
Zabbix isn't available in our package manager by default, so we will install a repository configuration package using the official Zabbix repository for CentOS,
  • sudo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
You will see the following output:
Output
Retrieving http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm warning: /var/tmp/rpm-tmp.qLbOPP: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-3.0-1.el7 ################################# [100%]
Now you can run the following command to install the Zabbix server and web frontend with MySQL database support:
  • sudo yum install
    yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml
    yum install httpd httpd-devel
    yum install zabbix-server-mysql zabbix-web-mysql
During the installation process you will be asked about importing a GPG key. Confirm it so the installation can complete.
Let's also install the Zabbix agent, which will let us collect data about the Zabbix server itself.
  • sudo yum install zabbix-agent
Before we can use Zabbix, we have to set up a database to hold the data that the Zabbix server will collect from its agents.

Step 2 — Configuring the MySQL Database For Zabbix

We need to create a new MySQL database and populate it with some basic information in order to make it suitable for Zabbix. We'll also create a specific user for this database so Zabbix isn't logging into MySQL with the root account.
Log into MySQL as the root user using the root password that you set up during the MySQL server installation:
  • mysql -uroot -p
First, create the Zabbix database with UTF-8 character support:
  • create database zabbix character set utf8;
Next, create a user that the Zabbix server will use, give it access to the new database, and set the password:
  • grant all privileges on zabbix.* to zabbix@localhost identified by 'your_password';
Then apply these new permissions:
  • flush privileges;
That takes care of the user and the database. Exit out of the database console.
  • quit;
Next we have to import the initial schema and data. The Zabbix installation provided us with a file that sets this up for us. We just have to import it. Navigate to the directory:
  • cd /usr/share/doc/zabbix-server-mysql-3.x.x/
Run the following command to set up the schema and import the data into the zabbix database. We'll use zcat since the data in the file is compressed.
  • gunzip create.sql.gz
    mysql -u root -p zabbix_db < create.sql 
    
Enter the password for the zabbix user that you configured when prompted.
This command will not output any errors if it was successful. If you see the error ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES) then make sure you used the password for the zabbix user and not the root user.
In order for the Zabbix server to use this database, you need to set the database password in the Zabbix server configuration file.
  • sudo vi /etc/zabbix/zabbix_server.conf
Look for the following section of the file:
/etc/zabbix/zabbix_server.conf
### Option: DBPassword                           
#       Database password. Ignored for SQLite.   
#       Comment this line if no password is used.
#                                                
# Mandatory: no                                  
# Default:                                       
# DBPassword=
These comments in the file explain how to connect to the database. We need to set the DBPassword value in the file to the password for our database user. Add this line below those comments to configure the database:
/etc/zabbix/zabbix_server.conf
DBPassword=your_zabbix_mysql_password
That takes care of the Zabbix server configuration, but we have to make some modifications to our PHP setup in order for the Zabbix web interface to work properly.

Step 3 —

Setup Zabbix Apache Configuration

Zabbix creates its own apache configuration file /etc/httpd/conf.d/zabbix.conf. Edit this file and just update timezone

as you timezone Asia/Kolkata

  • sudo systemctl restart httpd
You can now start the Zabbix server.
  • sudo systemctl start zabbix-server
Then check whether the Zabbix server is running properly:
  • sudo systemctl status zabbix-server
You will see the following status:
Output
● zabbix-server.service - Zabbix Server Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled) Active: :active (running) since Fri 2016-08-05 07:16:35 UTC; 2s ago Process: 10033 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) ...
Finally, enable the Zabbix server to start at boot time:
  • sudo systemctl enable zabbix-server
The server is set up and connected to the database. Now let's set up the web frontend.

Step 4 — Configuring Settings for the Zabbix Web Interface

The web interface lets us see reports and add hosts that we want to monitor, but it needs some initial setup before we can use it. Launch your browser and go to the address http://your_zabbix_server_ip_address/zabbix/. On the first screen, you will see a welcome message. Click Next step to continue.
On the next screen, you will see the table that lists all of the prerequisites to run Zabbix.

Comments

Post a Comment

Popular posts from this blog

How to remove zabbix-agent from Ubuntu 16.04 (Xenial Xerus)

Uninstall zabbix-agent To remove just zabbix-agent package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal: sudo apt-get remove zabbix-agent Uninstall zabbix-agent and it's dependent packages To remove the zabbix-agent package and any other dependant package which are no longer needed from Ubuntu Xenial. sudo apt-get remove --auto-remove zabbix-agent Purging zabbix-agent If you also want to delete configuration and/or data files of zabbix-agent from Ubuntu Xenial then this will work: sudo apt-get purge zabbix-agent To delete configuration and/or data files of zabbix-agent and it's dependencies from Ubuntu Xenial then execute: sudo apt-get purge --auto-remove zabbix-agent

Install Zabbix Agent on Suse Linux and Configure

Install taken from Suse –  http://software.opensuse.org/download/package?project=server:monitoring&package=zabbix-agent For SLE 12 SP1 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_12_SP1/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 12 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_12/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 11 SP4 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_11_SP4/server:monitoring.repo zypper refresh zypper install zabbix-agent For SLE 11 SP3 run the following as root : zypper addrepo http://download.opensuse.org/repositories/server:monitoring/SLE_11_SP3/server:monitoring.repo zypper refresh zypper install zabbix-agent To configure the agent – Instructions taken from – https://www.zabbix.org/wiki

Zabbix alert Notification with Telegram

Zabbix Notifications with graphs in Telegram. Features  Graphs based on latest data are sent directly to your messenger  You can send messages both in private and group chats  Channels support  Saves chatid as a temporary file  Simple markdown and HTML are supported  Emoji in messages First of all : Nedd to install python (>3) on Cent os  # yum -y install python-pip # yum install -y https://centos7.iuscommunity.org/ius-release.rpm #  yum install -y python34u python34u-libs python34u-devel python34u-pi # yum -y install python-pip You need to install the  requests  module for python, this is required for operation! # pip install requests Put  zbxtg.py  in your  AlertScriptsPath  directory, the path is set inside your zabbix_server.conf (once confirm by zabbix server conf file ) Link to download ZBXTG.PY file  https://drive.google.com/open?id=0BxB8j19aCMZ8dFl1aHVuLVJyRjQ # cp zbxtg.py /usr/local/share/zabbix/alertscripts/ Create