How to make your site work stably and not crash. Part 1: Setting up resource monitoring

Zabbix_logo

VPSs are growing in popularity, with more than 30% of companies (including Shopify, Dropbox, and Reddit) keeping their entire infrastructure on them. However, VPS administrators face serious performance, security, and manageability issues. Often, these problems are caused by misconfigurations, which can lead to server overloads and data leaks.

The financial losses from these problems can be significant. For example, server downtime due to overloads affects a company's revenues. Data leaks can entail not only fines for violating data protection legislation, but also loss of customer confidence. As a result, insufficient attention to VPS settings can cost a company millions of rubles, as well as affect its reputation.

 

In a series of articles we will tell you how to set up and manage VPS correctly: so that it works stably and “flies”. We will give a full set of tools for webmasters.

Let's start with the base - resource monitoring. In the first two articles we will tell you how to install Zabbix, configure and use it. In it we will monitor everything that relates to the work of the server. Zabbix is suitable because it is freeware that will give you everything you need to monitor your server in real time.

Resource monitoring

The first thing to do is to set up resource monitoring. CPU, memory and disk space monitoring will reveal performance problems. Zabbix will show you everything you need to know. You will react to problems, avoid downtime and keep your server up and running.

Zabbix

This is what the Zabbix interface looks like. This program will become your on-board sensor suite.

VPS monitoring with Zabbix

Now we will tell you how to install and work with Zabbix on VPS.

By default, all commands are given for Ubuntu, as it is one of the most popular operating systems for VPS. Before installation, you need to enable SSH. Here's how to do it on Ubuntu/Debian. Type in terminal:

sudo apt install openssh-server

Zabbix install

Start the SSH service:
sudo systemctl start ssh

Make sure SSH is enabled at boot:
sudo systemctl enable ssh

Zabbix configure

Once enabled, you will be able to connect to the VPS using an SSH client, for example:

ssh username@ip_address

Now you can move on to installing Zabbix.

Installing Zabbix

Let's download and install Zabbix on the VPS. To do this, write the following commands in the terminal:

sudo wget https://repo.zabbix.com/zabbix/6.3/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.3-3%2Bubuntu22.04_all.deb

Zabbix installing

This command downloads Zabbix for installation on the server with superuser privileges

Next, let's continue typing one command after another:

sudo dpkg -i zabbix-release_6.3-3+ubuntu22.04_all.deb

Zabbix setting

sudo apt update

The sudo apt update command updates information about available packages and their versions on the system.

Zabbix on vps

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent

With this command we install the following components:

  • Zabbix Server with MySQL support for data storage.
  • Zabbix Frontend with PHP for the web interface.
  • Configuration for Apache web server.
  • SQL scripts needed to initialize the Zabbix database.
  • Zabbix Agent for monitoring the local system.

Now let's install SQL if you don't have it.

Installing MySQL

Enter in the terminal:

sudo apt-get install mysql-server

mysql

Next:

sudo systemctl start mysql

Open MySQL:
sudo mysql

mysql install

Create a Zabbix database

Let's create a database using a sequence of commands:
create database zabbix character set utf8mb4 collate utf8mb4_bin;

Zabbix database

Create a Zabbix user (remember to replace 'password' with the desired password):
create user zabbix@localhost identified by 'password';

Zabbix

Grant privileges to the Zabbix user on the database:
grant all privileges on zabbix.* to zabbix@localhost;

Zabbix set up database

Set a global variable (this is required for some functions):
set global log_bin_trust_function_creators = 1;

set up database

Log out of MySQL:
quit;

Customize the database

Next, unpack the file server.sql.gz, which contains the SQL script to configure the Zabbix database and execute it in MySQL. As a result, we will create tables and initial data. This is necessary for Zabbix to work properly. Don't forget to

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

database on Zabbix

Here enter the password you set earlier.

After importing the Zabbix database schema, disable the log_bin_trust_function_creators option.

sudo mysql

Next:

set global log_bin_trust_function_creators = 0;

And:

quit;

This command terminates the MySQL session.

Disabling the log_bin_trust_function_creators option after importing the database schema allows you to limit the ability of users without appropriate privileges to create functions, which increases database security and prevents potential errors.

Edit the database configuration

Let's enter the command:

sudo vim /etc/zabbix/zabbix_server.conf

In the file, let's find the line that is responsible for connecting to the database and sets the password for the Zabbix database user.

Here is this line: DBPassword=. After the equal sign you need to specify the password that you set for the zabbix user.

database configuration

Next, use the systemctl restart zabbix-server zabbix-agent apache2 command to start the Zabbix server, Zabbix agent, and Apache web server.

Zabbix database configuration

Next, enter the command systemctl enable zabbix-server zabbix-agent apache2

Zabbix user

You will be asked to enter your password at each step. Just copy and paste it.

After system reboot Zabbix server, Zabbix agent and Apache will be automatically started.

Log in to Zabbix and start working

Now it's time to enter the program interface. It is available through a browser at the IP address of your server.zabbix.setup.php

Zabbix enter

Then you need to go through the configuration step by step: choose a password, time zone, language, server name. At the end you will see the long-awaited message:

Zabbix log in

Yay! We installed Zabbix. Now we can log in. Enter the username and password you set earlier.

log in Zabbix

And finally we are where we need to be - in the Zabbix dashboard.

Zabbix dashboard

What does Zabbix show?

  • CPU load. This helps you see if the server is overloaded or if any applications are not running efficiently.
  • Memory utilization. You can find out how much RAM is being used and how much is available. This is important so that the server doesn't hang due to lack of resources.
  • Disk space. Zabbix shows how much space is left on disks.
  • Network traffic. You can track how much data is coming in and out of the server. This helps you identify unauthorized connections and understand how network resources are being used.

If you are looking for a reliable VPS, you should pay attention to LikeVPS. This service offers virtual server rentals that are perfect for your needs. You don't have to worry about performance - they have excellent resources and a stable connection.

In addition, LikeVPS support works 24/7, which means that you can get help with any questions at any time. Why risk your business with less reliable providers when you can choose a service that cares about your success?

With LikeVPS, you can focus on your business without being distracted by server problems. Try their services and make sure it's the right choice for your project!

We're done with the installation. But we will tell you how to use Zabbix in the next article: Configuring and monitoring a server with Zabbix.