Zabbix: a network monitor. Installation in Ubuntu Server 18.04

0
2198
server

System and server administrators need to have professional software installed, in order to be able to monitor what is happening on them or their networks, with the primary objective of preventing failures and if they exist, to be able to keep up to date in the shortest possible time.

As the article title says, Zabbix is a fantastic open-source application that monitors networks within a given topology. It was first created by Alexei Vladishev, specialized in networks with an important user base and an active community, that is always contributing both in its development and in its support for users. Uses MySQL, PostgreSQL, SQLite, Oracle or IBM DB2 as database. Its backend is written in C and the web frontend is written in PHP.

Let’s get to work: installing the Prerequisites

The first thing we must always do is to make sure that our system is up to date. For them we write on a terminal:

           sudo apt update && sudo apt -y upgrade

1.- Upgrading the system
1.- Upgrading the system

With this single line we do two things: the first is to refresh the cache of the repositories and the second is to update them without being asked if we want to do it.

Once our system is updated with the latest security patches, the next thing we need to do is install a LAMP server. We can do it with the following instructions, always from the terminal:

          sudo apt install apache2 libapache2-mod-php7.2 mysql-server-5.7 mysql-client php7.2 php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php-xml php-mbstring php-bcmath

2.- Installing prerequisites
2.- Installing prerequisites

Already with that we will have a basic LAMP server running on our system.

Then we must change our timezone in the php.ini file. As an example I will put America/Caracas.

           sudo nano /etc/php/7.2/apache2/php.ini

3.- Editing php.ini file
3.- Editing php.ini file
5.- Editing php.ini file
5.- Editing php.ini file

For the changes to take effect, we must restart the apache service2.

sudo systemctl restart apache2.service

Installing Zabbix

Now we can add the Zabbix repository for Ubuntu 18.04 and then install it using the APT package manager. To add the repository just install a.deb file that we download with the following command:

          wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1%2Bbionic_all.deb

5.- Adding zabbix repository
5.- Adding zabbix repository

and then we install it with:

sudo dpkg -i zabbix-release_3.4-1+bionic_all.deb

6.- Adding zabbix repository
6.- Adding zabbix repository

As we have added a new repository, we must refresh the cache of it, we do it with:

sudo apt update

7.- apt update
7.- apt update

And we proceed to install in a single command: the Zabbix server, the agent and the  front-end to access from the web browser:

          sudo apt install zabbix-server-mysql zabbix-agent zabbix-frontend-php

8.- Installing zabbix packages
8.- Installing zabbix packages

Configure MySql

At this point, we already have Zabbix installed but we need to configure mysql so that the program knows how to use it.

            sudo mysql_secure_installation

9.- Mysql secure installation script
9.- Mysql secure installation script

Where we will define our root key. The rest of the questions can be answered according to our taste. In my case, I said: Y,N,Y,Y.

Now we must log in to mysql with the password we have previously defined, to create the database and the zabbix user.

         sudo mysql -u root -p

10.- logging in to mysql
10.- logging in to mysql

          CREATE DATABASE zabbix;

11.- Creating Database Zabbix
11.- Creating Database Zabbix

And select the database with:

           use zabbix;

Now we must create a mysql user that has permissions on the Zabbix database.

         GRANT ALL ON zabbix.* TO ‘zabbixuser’@’localhost’ IDENTIFIED BY ‘zabbixpss’;

12.- Creating user zabbixuser
12.- Creating user zabbixuser

We briefly explain: zabbix is the database; zabixuser is the username mysql and zabbixpss is the password for that username. Obviously when you do the tutorial don’t tell anyone the password 😉

Now we leave mysql writing exit

At this point we must enable the ubuntu root user for the following commands to work.

sudo -i

And then:

      sudo passwd root

it will ask us for a new password and that’s it.

We log in as root:

su

13.- logging in as root user
13.- logging in as root user

Next, copy the mysql configuration to the new user.

      zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

14.- Importing sql config
14.- Importing sql config
15.- Importing sql config
15.- Importing sql config

Defining the basic settings of Zabbix

We are almost finished, for now we have to define some parameters in the Zabbix configuration file so that it can work correctly.

          nano /etc/zabbix/zabbix_server.conf

16.- editing zabbix server config file
16.- editing zabbix server config file

We must modify these parameters so that you can communicate with mysql:

DBHost=localhost

DBName=zabbix

DBUser=zabbixuser

DBPassword=zabbixpss

For these changes to take effect we must restart the Zabbix, apache and mysql services.

For apache:

           systemctl restart apache2.service

Next, the zabbix server:

           systemctl restart zabbix-server.service

And Finally, mysql:

           systemctl restart mysql.service

17.- Restarting services
17.- Restarting services

We have finally completed the process, and can view your front-end from the web browser.

          http://ip_server/zabbix

and we should see something like this.

Zabbix
18.-Zabbix

We click on next

Zabbix 2
19.-Zabbix 2

After clicking on next we are presented with a screen where we must enter the mysql configuration parameters:

zabbix mysql
20.-zabbix mysql

Then we can name the zabbix instance that we have just created:

21.-Configuring Zabbix
21.-Configuring Zabbix

You will then give us the summary of the pre-installation:

22.- Installation summary
22.- Pre-installation summary

And finally, we did it: Zabbix-server is installed!!

23.- Zbbix installed
23.- Zbbix installed

When you access the zabbix directory again from your browser, you will be able to log in.

24.- Zabbix log in
24.- Zabbix log in

To log in as administrator, the user is admin and the password is zabbix, with this we will enter the dashboard

25.-Zabbix Dashboard
25.-Zabbix Dashboard

Of course, in this instantiation the Dashboard is empty, the agent is already installed in the machines to be monitored, and then add them to Zabbix.

Zabbix is a very useful server tool for monitoring services and today we have learned how to install it in our Ubuntu Server 18.04.

Please share this article through your social networks.

 

Spread the love
  • 19
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here