Installlion's Logo

Installlion.com

Installing And Configuring Zabbix on Debian

On August 22, 2017, a new version of the free monitoring system was released, which I regularly use. I will describe in detail the installation and initial configuration of Zabbix 3.4 using the example of Debian 9 with screenshots and explanations. This version will have some very interesting and useful innovations, so it’s definitely worth looking at.

Content:

Introduction

By and large, in version 3.4 there were no fundamental changes in the installation and configuration of zabbix, you can use the previous instructions. But to simplify myself and the rest of life, I will still write detailed instructions, where all links will be relevant, so that everything can be repeated in the shortest possible time with a simple copy-paste. I myself often install the zabbix monitoring system, as I consider it the most functional and convenient to use.

Let’s start installing and configuring the latest version of zabbix 3.4 on a server with Debian 9.

Preparing the server for installation

We traditionally start by preparing the working environment. First of all, we need to install and configure the  Debian 9 server. Next, we need to configure the web server for the management interface to work. In this article I will be doing a standard Zabbix installation on a traditional apache + php web server. If you want your zabbix to work on the nginx + php-fpm web server, read a separate material on installing zabbix on nginx and php-fpm.

Let’s start by updating the system:

# apt update && apt upgrade

The work will take place on the next version of Debian:

Debian server version

Now let’s install mysql server – mariadb . It is needed to store all the information that zabbix uses. Just in case, I will mention it for those who do not know what mariadb is and why we put it, and not mysql. Mariadb is a fork of mysql. They are fully compatible, it is possible at any time to switch from one subdivision to another and vice versa. There is information that mysql works faster with mariadb and people are slowly moving to it. CentOS developers starting from version 7 and Debian starting from 9th offer it as the default database server.

# apt install mysql-server mysql-client

Launch mariadb and add it to startup:

# systemctl start mariadb
# systemctl enable mariadb.service

Run the initial mysql configuration script:

# / usr / bin / mysql_secure_installation

All preparatory work has been completed, we move on.

Installing Zabbix 3.4 server on Debian 9

We connect the official repository 3.4 for Debian 9 Stretch:

# wget http://repo.zabbix.com/zabbix/3.4/debian/pool/main/z/zabbix-release/zabbix-release_3.4-1+stretch_all.deb
# dpkg -i zabbix-release_3.4-1 + stretch_all.deb
# apt update

Install Zabbix server with web interface and MySQL database:

# apt install zabbix-server-mysql zabbix-frontend-php

We are waiting for the download of all dependencies to finish. After that, you need to create a user and a database for monitoring. If you previously configured a separate web server and you have phpmyadmin installed, you can do it through it. If you don’t have it, then we do everything through the console.

# mysql -uroot -ptopsecret
> create database zabbix character set utf8 collate utf8_bin;
> grant all privileges on zabbix. * to zabbix @ localhost identified by 'zabpassword';
topsecretmysql root user password, this is not system root
zabpasswordpassword of the zabbix user who has full access to the zabbix mysql database

Exit the mysql console by typing exit.

Now let’s import the database schema and initial data.

# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uroot -ptopsecret zabbix

Now we edit the zabbiks server configuration file. We register the data for connecting to the database.

# mcedit /etc/zabbix/zabbix_server.conf

Change the lines:

DBHost = localhost
DBName = zabbix
DBUser = zabbix
DBPassword = zabpassword

These minimum settings are sufficient for the server to work. But I recommend increasing the Timeout parameter even more . It is responsible for the waiting time for a response from an agent, snmp device, or external check. The default is 3 seconds. Sometimes this is not enough. In particular, when some script is used, which takes a long time to execute, to get the metric. Set 10 seconds.

Launch zabbix and add it to startup.

# systemctl start zabbix-server
# systemctl enable zabbix-server

Checking the log file for errors.

# cat /var/log/zabbix/zabbix_server.log

If you get a whole bunch of errors like this

Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutNumLines :: = {nsExtendOutput1Entry 3}
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutputFull :: = {nsExtendOutput1Entry 2}
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutput1Line :: = {nsExtendOutput1Entry 1}
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendOutLine :: = {nsExtendOutput2Entry 2}
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendLineIndex :: = {nsExtendOutput2Entry 1}
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyStart :: = {netSnmpNotifications 1}
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyShutdown :: = {netSnmpNotifications 2}
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyRestart :: = {netSnmpNotifications 3}
Cannot adopt OID in UCD-SNMP-MIB: laErrMessage :: = {laEntry 101}
Cannot adopt OID in UCD-SNMP-MIB: laErrorFlag :: = {laEntry 100}
Cannot adopt OID in UCD-SNMP-MIB: laLoadFloat :: = {laEntry 6}
Cannot adopt OID in UCD-SNMP-MIB: laLoadInt :: = {laEntry 5}
Cannot adopt OID in UCD-SNMP-MIB: laConfig :: = {laEntry 4}
Cannot adopt OID in UCD-SNMP-MIB: laLoad :: = {laEntry 3}
Cannot adopt OID in UCD-SNMP-MIB: laNames :: = {laEntry 2}
Cannot adopt OID in UCD-SNMP-MIB: laIndex :: = {laEntry 1}

Then the snmp-mibs-downloader package should be installed  . To do this, you need to add a non-free repository. To do this, edit the /etc/apt/sources.list file to add an additional non-free to the standard repository.

deb http://mirror.yandex.ru/debian/ stretch main non-free 
deb-src http://mirror.yandex.ru/debian/ stretch main non-free

We update the list of packages and install the required one.

# apt update && apt install snmp-mibs-downloader

Restart zabbix-server and check the log.

# systemctl restart zabbix-server
Server start log

Now everything is all right.

To continue configuring the monitoring server, we need to go to the web interface. Before that, let’s edit the web server configuration file. Open the config and uncomment the lines, changing them to your time zone.

# mcedit /etc/zabbix/apache.conf

php_value date.timezone Europe / Moscow

We save the file. Now restart apache and add it to startup.

# systemctl restart apache2
# systemctl enable apache2

You can go to the web interface at  http://10.1.4.81/zabbix , where 10.1.4.81 is the ip address of the server where we install and configure the zabbix monitoring. It is important to check your iptables settings at this point. If you have not configured it or disabled it, then most likely nothing will open at the specified address. In this article, I will not be distracted by configuring the firewall, this is a topic for a separate conversation. I considered the issue of configuring iptables in detail separately. Either configure the firewall or just disable it.

Open the zabbix web interface in the browser. We are greeted by a welcome page. If you have the same thing, you are on the right track.

Installing zabbix 3.4 on Debian 9

Click Next step and go to the checks page. If everything was done exactly according to the instructions, then all the checks will be passed for you.

Checking system requirements

Let’s move on and specify the parameters for connecting to mysql. The data is the same as we indicated earlier when creating the database and user.

Database connection

At the next stage, you need to specify the server address and port on which it will work. Leave the default values.

Additional server parameters

We check all the settings once again. If everything is in order, we move on to the final stage of the installation.

Checking the settings

If you have received this message, then congratulations, the installation of the Zabbix 3.4 monitoring server is complete.

Completing the installation of Zabbix

Click Finish and go to the login page in the system. The default data is as follows:

UserAdmin
Passwordzabbix

We are greeted by a bare control panel, since we do not observe any parameters and do not have a single data collection object.

Monitoring Server Home Page

We will set up data collection a little later by installing the zabbix agent on the same server. In the meantime, let’s make some minimal and necessary settings on the server.

Setting up email notifications

In version 3.4 (appeared since version 3.0) there is a setting for notifications with smtp authorization . Previously, to implement such an obvious and necessary function, you had to use third-party programs and scripts. I wrote separately about this – sending email notifications with smtp authorization. Now all this is in the past. Let’s configure sending notifications via the web interface.

Go to the Administration -> Media types section and click on Email .

Setting up email notifications

We specify the following settings for sending mail via gmail .

Gmail sending options

We have configured the shipping address. Now the user needs to add an address to receive. To do this, go to  Administration -> Users , select the Admin user .

Zabbix administrator setup

Go to the Media tab and click Add .

Adding a mailbox

We indicate the mailbox of the recipient of notifications.

Adding an administrator mailbox

Click Add , then Update . Next, you need to activate sending notifications by events. To do this, go to Configuration -> Actions and click on Disabled so that it becomes Enabled .

Activation of sending notifications

That’s it, we have configured sending notifications, it remains to wait for the trigger to fire to check. We will do this later, when we connect the host to monitoring.

If you need telegram notifications, then read a separate article on this topic.

Installing zabbix agent

Now let’s install at least one monitoring agent to check the system operation. We will install it on the same server. This is done simply:

# apt install zabbix-agent

To work with a server that is installed locally on the same machine, you don’t need to make any more settings. If you install the zabbix agent on a remote machine, then the following parameters will need to be set in the agent configuration file /etc/zabbix/zabbix_agentd.conf :

# mcedit /etc/zabbix/zabbix_agentd.conf
Server = 10.1.4.81
ServerActive = 10.1.4.81
Hostname = web-server # the name of your monitoring node, which will be indicated on the zabbix server

We start the agent and add to startup:

# systemctl start zabbix-agent
# systemctl enable zabbix-agent

Checking the log file.

# cat /var/log/zabbix/zabbix_agentd.log

21197: 20150912: 212555.935 no active checks on server [127.0.0.1:10051]: host [Zabbix server] not monitored

I have the following error there. I know what it is connected with. The server has already added a local host for monitoring by default, but it is disabled. To enable it, go to the Configuration -> Hosts section and activate the Zabbix server by clicking on Disabled so that it becomes Enabled .

Monitoring node activation

You can wait, or manually restart the agent to check the changes immediately:

# systemctl restart zabbix-agent

For reliability, we check again the log file for errors. They shouldn’t be. The agent is up and running and starts sending data to the server. To check the receipt of data, you need to wait a couple of minutes and go to the Monitoring -> Latest data section . Select our only host there and click Apply .

Checking incoming values

It can be seen that the data has already begun to flow.

Now let’s try to stop the agent and check if the notification arrives in the mail. We go to the console and turn off the agent:

# systemctl stop zabbix-agent

We are waiting for at least 5 minutes. This is the default interval specified for the agent unavailability trigger. After that we check the Dashboard , the Problems widget .

Checking notifications in zabbix

When you hover the mouse over the word Done in the Actions column, you will see information that an email notification has been sent to the Admin user. In the mail you will have a letter:

Notification letter

After the agent resumes working on debian, you will once again receive a notification that it is now available.

Installing zabbix agent on Windows and configuring monitoring

Now, for the sake of completeness, let’s add one agent to the server installed on a windows machine and configure its monitoring. To do this, go to the downloads page  http://www.zabbix.com/download.php and download the latest agent for Windows. All agents are located in the Zabbix pre-compiled agents section  . Direct link to the latest version at the time of this writing –  zabbix_agents_3.4.0.win.zip

We unpack the archive. Create a zabbix folder on the C: drive and copy the following files there:

  • zabbix_agentd.exe
  • zabbix_get.exe
  • zabbix_sender.exe
  • zabbix_agentd.win.conf

Take the executable files of the bitness that you have in the system. The original archive contains both x32 and x64. Next, open the command line with administrator rights and run the following command to install the zabbix agent on windows:

c: /zabbix/zabbix_agentd.exe --config c: /zabbix/zabbix_agentd.win.conf --install
Installing zabbix agent on windows

Open the zabbix_agentd.win.conf file  with  any text editor and change the following parameters:

LogFile = c: \ zabbix \ zabbix_agentd.log
Server = 10.1.4.81
ServerActive = 10.1.4.81
Hostname = win7-01

Now open the snap-in with services, look for a service named Zabbix agent and start it.

Starting zabbix service on windows

Don’t forget to create an Allow Rule in Windows Firewall. Windows Defender Firewall – Advanced Options – Inbound Rule – Create Rule.

  • Rule type: For port;
  • Protocols and ports: TCP protocol; Specified local ports: 10050;
  • Action: Allow the connection;
  • Profile (check the boxes): Domain, Private, Public;
  • Name: Zabbix Agent;

For monitoring of windows machines to work, you need to add a host to the monitoring server with the same hostname that we specified in the agent config. To do this, go to the web panel, open the Configuration -> Hosts section and click Create host .

Adding windows host to Zabbix server

On the first tab, specify the host name, the same as on the client, add it to any existing group and set the ip address of the computer.

New host parameters

Then go to the Templates tab and click Select. Select the Template OS Windows template  and click the small Add link , then the big one.

Template assignment

A new monitoring host has been added, it remains to wait a few minutes for fresh data. You can check them where before, in Latest data , by selecting a new host.

Checking Windows Host Monitoring

This completes the installation and configuration of windows monitoring using the zabbix agent. You can add new computers with different versions of windows. The same version of the agent is suitable for all, both desktop and server systems.

Conclusion

The Zabbix team is closely monitoring the backward compatibility of their products. Thanks to this, the transition to new versions is painless. There is no need to reconfigure or fix old developments. In new versions, functionality is only added, the old one most often does not undergo changes, you can continue to use it.

This completes the installation and basic configuration of the zabbix 3.4 monitoring server on a server running on Debian 9 OS. Tips, remarks, corrections, please leave in the comments.