In the next article we are going to take a look at Zabbix. This is one monitoring tool open source. With it you will be able to monitor servers, CPU load, networks, cloud services and many other things.
Released on the terms of version 2 of the GNU General Public License, Zabbix is Free Software. Before you start you may want to take a look at the demo to see if it's what you're looking for. You can also check the Project Wiki or the official documentation. In the following lines we are going to see how this tool can be installed in Ubuntu 18.04 LTS.
Add the repository
This tool is not available in the official Ubuntu 18.04 LTS package repository. Despite this, you can easily add the official package repository for the tool in Ubuntu 18.04 LTS and install the tool from there.
Open a terminal (Ctrl + Alt + T) and download the .DEB file necessary with the following command:
wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb
We continue installing the downloaded file:
sudo dpkg -i zabbix-release*.deb
The official repository of this tool must be added to our system. Now we will have to update the cache of the APT package repository:
sudo apt update
Zabbix installation and configuration
After the above, we can now install the tool:
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
Create a MySQL / MariaDB database
To do this, we will start MySQL / MariaDB console with the following command:
sudo mysql -u root
Now create a database called zabbix with the following SQL command:
create database zabbix character set utf8 collate utf8_bin;
We continue to give all privileges to the zabbix user in the zabbix database we just created. We are also going to set a password for the zabbix user with the following SQL command:
grant all privileges on zabbix.* to zabbix@localhost identified by 'TU-CONTRASEÑA-AQUI';
NOTE: Make sure to replace YOUR-PASSWORD-HERE with the password that interests you.
The necessary permissions must be granted and the password must be set. For this example I set the password as zabbix, for simplicity.
We exit the MySQL / MariaDB console with the following command:
quit;
We creating the necessary tables with the following command. It may take a while.
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -Dzabbix -pzabbix
NOTE: Make sure to replace the zabbix password with the password that you have set.
Edit the configuration file
At this point we are going to edit the configuration file /etc/zabbix/zabbix_server.conf with the following command:
sudo vim /etc/zabbix/zabbix_server.conf
Inside the file, you have to look for the line DBUser = zabbix and add a new line below of it, as indicated in the following screenshot. Once you're done, save and close the file.
DBPassword=zabbix, set the database password to zabbix. Replace it with the password that you have previously set.
Set the time zone
Now, we will have to set the correct time zone for the PHP engine. To do it, edit the configuration file /etc/zabbix/apache.conf:
sudo vim /etc/zabbix/apache.conf
Scroll down a bit and find the lines marked in the previous screenshot. Remove the # sign to uncomment them and changes Europe / Riga by the time zone that interests you. You can find more information about what to put there in Wikipedia.
The final configuration file in my case is as follows.
Once you're done, save and close the file.
Restart services
Let restart zabbix-server, zabbix-agent and apache2 services with the command:
sudo systemctl restart zabbix-server zabbix-agent apache2
If you want to add the zabbix-server, zabbix-agent and apache2 services to the system startup of your Ubuntu 18.04 LTS machine, use the command:
sudo systemctl enable zabbix-server zabbix-agent apache2
The zabbix-server, zabbix-agent, and apache2 services must be added at system startup and will start automatically when the computer boots.
Start Zabbix
Run the following command to find the IP address of your Ubuntu 18.04 LTS machine:
ip a
As can be seen, in my case the IP address of my Ubuntu 18.04 LTS machine is 10.0.2.15. It should be different for you. Change it from here on.
Visit http://10.0.2.15/zabbix from the web browser. You should see a page like the previous screenshot. As you are running the interface of this tool for the first time, you must configure it. Click on "Next Step".
Make sure all previous requirements are correct. Continue by clicking on "Next Step".
Now type the password for the MySQL / MariaDB database user you set up earlier and click on "Next Step".
Configure some server details. Click on "Next Step".
Make sure that all the information it's correct.
If you get this far, everything should have been set up correctly. Click on «Finish«.
Now you should be able to log in with the user 'Admin' and by the Ministry of Home Affairs of the Government of Spain with the default password 'zabbix'.
Once you log in, you should see the dashboard. You can now use this tool for whatever you need and as much as you want.