YouTube Icon

Code Playground.

How to Install and Configure Zabbix on Debian 9 Linux

CFG

How to Install and Configure Zabbix on Debian 9 Linux

Zabbix is a mature open-source software for monitoring networks and applications. Zabbix can collects metrics from diverse networks gadgets, systems, and packages. In case of any screw ups, Zabbix will send notification signals via various strategies.

Zabbix helps each agent-based totally and agent-much less tracking. The Zabbix agent has a small footprint and can run on numerous systems, which include Linux, UNIX, macOS, and Windows.
This educational explains the way to install and configure the cutting-edge version of Zabbix 4.Zero on a Debian nine Linux server the use of MySQL as a database lower back-cease. We can even show you how to set up the Zabbix agent on a remote host and add the host to the Zabbix server.

Prerequisites
The consumer you are logged in as ought to have sudo privileges if you want to set up packages.

Creating MySQL Database
Zabbix helps each MySQL /MariaDB and PostgreSQL . In this guide, we’ll use MariaDB as a database back-give up.

If you don’t have MariaDB established in your Debian server, deploy it through following those instructions .

Login to the MySQL console:

sudo mysql


Run the following SQL declaration to create a new database :

CREATE DATABASE zabbix CHARACTER SET utf8 collate utf8_bin;


Next, create a MySQL consumer account and supply get entry to to the database :

GRANT ALL ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'change-with-strong-password';

Make positive you convert trade-with-sturdy-password with a strong password.
Once accomplished, go out the MySQL console by typing:

EXIT;

Installing Zabbix on Debian
At the time of writing this article, the today's stable model of Zabbix is model 4.Zero. The Zabbix packages available in Debian repositories are often old so we’ll use the official Zabbix repository .

1. Installing Zabbix
Download the today's Zabbix repository .Deb package deal with following wget command :

wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb

Once the report is downloaded, install it with:

sudo apt install ./zabbix-release_4.0-2+stretch_all.deb


Update the applications list and set up the Zabbix server, the internet frontend with MySQL database aid and the Zabbix agent:

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


The command above can even installation Apache , PHP , and all required PHP modules.

2. Configuring PHP for Zabbix frontend
An Apache configuration record with all of the required Apache and PHP settings is created at some point of the installation.
Open the configuration file, uncomment the timezone line and alternate it in your time sector. You can find the entire listing of time zones supported with the aid of PHP right here .

/etc/apache2/conf-enabled/zabbix.conf

...
    <IfModule mod_php7.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone America/Denver
    </IfModule>
...


Once completed, shop the file and restart the Apache provider for adjustments to be activated.

sudo systemctl restart apache2


3. Configuring the MySQL Database For Zabbix Server
Import the MySQL dump record which incorporates an initial schema and records for the Zabbix server with MySQL.

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

Next, open the Zabbix configuration and set the database password:

sudo nano /etc/zabbix/zabbix_server.conf


Search for the following phase, uncomment the DBPassword directive and add the database password.

/etc/zabbix/zabbix_server.conf

...
### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=change-with-strong-password
...


Save and near the document.

Restart and permit the Zabbix server and agent offerings:

sudo systemctl restart zabbix-server zabbix-agent
sudo systemctl enable zabbix-server zabbix-agent


Verify that the Zabbix server is walking:

sudo systemctl status zabbix-server
? zabbix-server.service - Zabbix Server
   Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-01-28 15:37:21 CST; 35s ago
 Main PID: 27632 (zabbix_server)
   CGroup: /system.slice/zabbix-server.service
   ...

Installing and Configuring Zabbix Frontend
Zabbix web interface is written in PHP and allows you to configure the server, view collected statistics and upload hosts you need to monitor.
TO start the set up, open your favored browser and type your server’s domain name or public IP address followed by way of /zabbix:

http(s)://your_domain_or_ip_address/zabbix


On the first screen, you may be presented with a welcome message. Click Next step to continue.


Next, you may see an information web page with a list of the essential PHP programs required to run the Zabbix Frontend. Scroll right down to verify that the entirety is established and installation successfully. Once established, click Next step to proceed.


On the subsequent display, the setup wizard will ask you to go into the database connection information. Enter the MySQL consumer and database info you formerly created.


Entering a call for the server is non-compulsory. Enter it when you have more than one Zabbix monitoring servers. If provided, it will be displayed within the menu bar and page titles.

Click Next step to retain.


On the following display, you'll see the pre-set up summary.
Click Next step and once the installation is finished you may be taken to a web page showing that Zabbix net interface has been mounted. To access your Zabbix login page click on the Finish button.


The default consumer is “Admin” and the password is “zabbix”. Enter the username and password and click on at the Log in button.


Once you log in, you will be redirected to the Zabbix administration dashboard.

From here, you can start customizing your Zabbix installation and adding new hosts. First, you need to alternate the modern password. To do this navigate to the consumer profile page by clicking on the profile icon on the top navigation.

Adding a New Host to Zabbix Server
The process for including a new host for tracking to the Zabbix server includes  steps.
First, you need to install the Zabbix agent on the remote host after which upload the host to the Zabbix server through the net interface.

Installing the Zabbix agent
This educational assumes that the host system also makes use of Debian nine.

Same as whilst installing the Zabbix server, run the following instructions to permit the Zabbix repository:

wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb
sudo apt install ./zabbix-release_4.0-2+stretch_all.deb


Update the packages list and deploy the Zabbix agent package deal:

sudo apt update
sudo apt install zabbix-agent


Zabbix supports  strategies for server-customer communique encryption, Preshared Key (PSK) and certificates-primarily based encryption. In this manual, we can use the pre-shared keys (PSK) method to cozy the connection between the server and agent.

Run to following command to generate a pre-shared key and keep it to a file

openssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agentd.psk


The PSK key will appearance something like this:

fc3077ed3db8589ec920ac98a7ddea96aca205eb63bbd29c66ae91743a7ecbb6


Open the Zabbix agent configuration document:

sudo nano /etc/zabbix/zabbix_agentd.conf


Search for the Server IP Address and change it from the default value to your Zabbix server IP:

/etc/zabbix/zabbix_agentd.conf

...
### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=

Server=127.0.0.1
...

Next, discover the TSLConnect option, uncomment it and set it to psk:

/etc/zabbix/zabbix_agentd.conf

...
### Option: TLSConnect
#       How the agent should connect to server or proxy. Used for active checks.
#       Only one value can be specified:
#               unencrypted - connect without encryption
#               psk         - connect using TLS and a pre-shared key
#               cert        - connect using TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
TLSConnect=psk
...


Locate the TLSAccept alternative, uncomment it and set it to psk:

/etc/zabbix/zabbix_agentd.conf

...
### Option: TLSAccept
#       What incoming connections to accept.
#       Multiple values can be specified, separated by comma:
#               unencrypted - accept connections without encryption
#               psk         - accept connections secured with TLS and a pre-shared key
#               cert        - accept connections secured with TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
TLSAccept=psk
...


Next, discover the TLSPSKIdentity option, uncomment it and set it to PSK 001 The cost needs to be a unique string:

/etc/zabbix/zabbix_agentd.conf

...
### Option: TLSPSKIdentity
#       Unique, case sensitive string used to identify the pre-shared key.
#
# Mandatory: no
# Default:
TLSPSKIdentity=PSK 001
...


Finally, find the TLSPSKFile alternative, uncomment it and set it to point to the previously created pre-shared key:

/etc/zabbix/zabbix_agentd.conf

...
### Option: TLSPSKFile
#       Full pathname of a file containing the pre-shared key.
#
# Mandatory: no
# Default:
TLSPSKFile=/etc/zabbix/zabbix_agentd.psk
...


Once finished, store and near the file.

Start the Zabbix agent carrier and set it to start at boot time with:

sudo systemctl start zabbix-agent
sudo systemctl enable zabbix-agent


Next, add a firewall rule that allows site visitors out of your Zabbix server on TCP port 10050.

Assuming you are the usage of UFW to manipulate your firewall and you need to allow get right of entry to from the 192.168.121.70 IP address you would run the subsequent command:

sudo ufw allow proto tcp from 192.168.121.70 to any port 10050


Set up a New Host
Now that the agent on the remote host you want to monitor is set up and configured the next step is to sign up the host on the Zabbix server.

Log in to the Zabbix Server web interface because the admin consumer:

http(s)://your_domain_or_ip_address/zabbix


Once internal, in the top navigation bar click at the Configuration, after which Hosts

Next, click at the blue Create host button within the pinnacle right corner of the display and the host configuration page will open:
Enter the Hostname and the IP Address of the far off host gadget you need to monitor. Add the host to 1 or a couple of corporations by means of choosing the institution from the listing, or input a non-current organization call to create a new one. The Linux Servers organization is a superb choice.
Once achieved, click on the Templates tab. Select the Template OS Linux and click on the Add hyperlink to feature the template to the host.

Next, click on on the Encryption tab. Select PSK for both Connections to host and Connections from host.

Set the PSK identification cost to PSK 001, the price of the TLSPSKIdentity choice of the Zabbix agent you configured inside the previous step.

In the PSK value filed upload the key you generated for the Zabbix agent, the only stored within the /and many others/zabbix/zabbix_agentd.Psk record.
Finally, to feature the host click on at the blue Add button.

Conclusion
You have efficiently set up the present day Zabbix in your Debian machine and discovered how to add new hosts which you want to display.

You ought to now test the Zabbix Documentation and study more about how to configure and use Zabbix.

If you hit a trouble or have feedback, depart a remark beneath.




CFG