Zabbix is designed to monitor server performance, availability of a server, network devices, and other network components. We can easily keep track of any applications, systems and network devices status using this.
In this article, I'll explain how to install Zabbix 3.4, an open source monitoring tool on our latest Ubuntu 18.04 server and show you how to add remote servers for monitoring.
The core of Zabbix is built in with Java and C, but it comes with a user-friendly frontend interface build in PHP which makes it easier to track and monitor the systems.
- A freshly installed Ubuntu 18.04 server with root user privileges.
- A well-configured LAMP server.
Installing LAMP server
Before installing Zabbix server, we need to properly configure a LAMP server. First, we can install Apache and PHP along with some of the required PHP modules using this command below:
#apt update -y #apt install apache2 libapache2-mod-php7.2 php7.2 php7.2-xml php7.2-bcmath php7.2-mbstring -y
Once all the components are installed, we need to install MariaDB. Zabbix uses MySQL, Oracle, and PostgreSQL to store its data. Here we install MariaDB to store its data. The latest version of this software is available on our default Ubuntu 18.04 repository. Hence, we can simply run this command to install it.
#apt install mariadb-server -y
Next, we can start and enable all services to start on boot time:
#systemctl start apache2 #systemctl enable apache2 #systemctl start mysql #systemctl enable mysql
Hence, we are done with our LAMP server. Next, we can start our Zabbix installation.
Installing and Configuring Zabbix Server
Depending on our OS platform and requirement we need to choose/install the latest supporting Zabbix repository to our server.
Step 1: Download and install Zabbix Repository with MySQL
We can download and install the latest Zabbix 3.4 repository for our Ubuntu 18.04 server with the commands below:
# wget https://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb # dpkg -i zabbix-release_3.4-1+bionic_all.deb # apt update
Step 2: Install Zabbix server, frontend, and Zabbix-Agent
Secondly, we need to install our Zabbix server, Frontend and Zabbix Agent from the Zabbix repository which we installed. Please run this command to install it as below:
# apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
Step 3: Create Initial Zabbix Database
Once all the above components are installed, we can create a database for our Zabbix user:
~# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 41 Server version: 10.1.29-MariaDB-6 Ubuntu 18.04 Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.01 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> quit
Now you can Import the initial schema and data to our newly created Zabbix database. You will be prompted to enter your DB user password during the import process.
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Step 4: Configuring the database for Zabbix server
In this stage, you need to properly update the database password in the Zabbix configuration file at
/etc/zabbix/zabbix_server.conf as below:
# grep -i DBpassword /etc/zabbix/zabbix_server.conf # For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. ### Option: DBPassword DBPassword=password
You need to uncomment the DB password option and provide it with the exact Zabbix DB user password as required.
Step 5: Configuring PHP for Zabbix frontend
We need to configure the PHP and set proper timezone to carry out with the Zabbix Frontend installation smoothly. First of all, you can set proper timezone in your PHP configuration file located at
/etc/php/7.2/apache2/php.ini and modify it accordingly to your preferred time zone. I've updated it as below:
# grep -i timezone /etc/php/7.2/apache2/php.ini ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Europe/Riga
Next, we need to update the Zabbix configuration file at
/etc/zabbix/apache.conf with the same timezone as below:
# grep timezone /etc/zabbix/apache.conf php_value date.timezone Europe/Riga
You would uncomment the php_value for timezone in the PHP 7 Module section in the mentioned configuration file and update with the exact timezone as before.
Step 6: Start Zabbix server and agent processes
Finally, we can start and enable all required Zabbix services and Apache2 with the commands below:
# systemctl restart zabbix-server zabbix-agent apache2 # systemctl enable zabbix-server zabbix-agent apache2
That's all! Now our Zabbix server will be up and running. You can check it working by accessing the URL >>>
Installing/Configuring Zabbix Frontend
Once, we have our Zabbix server up and running, we can access our newly installed Zabbix frontend with the URL >>
http://Server-IP or hostname/zabbix. This will open up the frontend installation Wizard. To make it fully functional, we need to complete the Setup process for the Zabbix Frontend.
Let's navigate through each setup process one by one. You can click
Next Step to check the pre-requisites. In this stage, we need to make sure our server meets all software pre-requisites listed below. You can click Next Step to proceed once it's done.
In this stage, make sure to update the details to connect to our Zabbix database to ensure proper DB connection and proceed with the Zabbix server settings including the host and port 10051 destined for it.
Finally, we can once again verify all settings done in the above stages in the Pre-installation Summary and click
Next Step to complete the installation.
If everything goes well, you will get the above message stating a successful installation of the Zabbix frontend. Now you can click the Finish tab to exit the installation wizard.
Accessing the Zabbix Dashboard
Hurray! our Zabbix Frontend is ready. You can access it using the default Zabbix login credentials with username
"Admin" and password
"zabbix" in the URL >>>
Changing Admin Password
Once you have successfully logged in to the Zabbix Frontend Panel with the default admin login credentials, it's mandatory to modify the Admin credentials for security reasons. You can modify your Admin password by navigating through the path:
Administration > Users > Admin > Password > Change Password as in the screenshots below:
Adding a Monitoring Host
Since our Zabbix server is ready to use, we can test it functioning by adding our first monitoring target host which is our Zabbix server itself. You can do this by navigating through the path:
Configuration >> Hosts as in the screenshots.
As you can see, our host status is set to disabled status by default. We need to click on the disabled button to enable Zabbix agent on this server to monitor the host. As seen in the screenshot, the
Status is turned to
enabled and the server is now being monitored.
Just wait for a few minutes for our Zabbix server to grab the monitoring data from the server and update the graphs. Now you can view the host graphs by navigating through the path:
Monitoring > Screens > Server Name as in the snapshot.
Adding a Remote Host
First of all, we need to install/enable Zabbix Agent on our remote host. The work of Zabbix agent is to collect data such as CPU, memory, disk and network interface usage from a device. Zabbix agent can do both passive (polling) and active checks (trapping). These checks can be performed at an interval or based on specific time schedules. Let's see how to install/enable Zabbix agent on an Ubuntu 18.04 node.
Installing Zabbix Agent
Initially, you need SSH to our new host server and download the Zabbix 3.4 Repository for our Ubuntu 18.04 host setup and install the Zabbix Agent from that.
#wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb #dpkg -i zabbix-release_3.4-1+bionic_all.deb #apt install zabbix-agent
Configuring Zabbix Agent
Now, you can configure our Zabbix Agent to initiate proper connections with the Zabbix server. We use pre-shared keys (PSK) to secure the connection between the server and the agent. The Zabbix agent configuration is located at
Step 1: Generating PSK key and configuring it.
Firstly, we need to generate the PSK key. This can be obtained by running the command:
#sh -c "openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk"
You can save this key which will be used during the Agent configuring.
# cat /etc/zabbix/zabbix_agentd.psk abb6a14eace79044b9f3bab0c6cd26d50b4cfb3dc6fe2ef815b96216073b333b
Step 2: Adding the Zabbix Server to the Agent configuration.
Now you have to open-up the Zabbix Agent configuration file
/etc/zabbix/zabbix_agentd.conf and configure it to setup secure connection between the servers. First, you need to edit the '95' and '136' line number with the Zabbix Server IP as below. Here 18.104.22.168 is my Zabbix server IP.
# sed -n '95 p' /etc/zabbix/zabbix_agentd.conf Server=22.214.171.124
Next, we need to edit the 136 line with the Zabbix server information.
# sed -n '136 p' /etc/zabbix/zabbix_agentd.conf ServerActive=126.96.36.199
Step 3: Configuring and Enabling the PSK secure connection
In order to configure a secure connection between the servers, we're enabling TLS connection with PSK support. We need to edit the following lines in the Zabbix Agent configuration accordingly to make it possible.
Modify the following lines in /etc/zabbix/zabbix_agentd.conf from:
# sed -n -e 324p -e 335p -e 385p -e 392p /etc/zabbix/zabbix_agentd.conf # TLSConnect=unencrypted # TLSAccept=unencrypted # TLSPSKIdentity= # TLSPSKFile= TO: # sed -n -e 324p -e 335p -e 385p -e 392p /etc/zabbix/zabbix_agentd.conf TLSConnect=psk TLSAccept=psk TLSPSKIdentity=PKI 001 TLSPSKFile=/etc/zabbix/zabbix_agentd.psk
Defining each section:
TLSConnect=psk*// This enables Pre-shared Key support //*
TLSAccept=psk*// This allows accepting all incoming connections using PSK support//*
TLSPSKIdentity=PKI 001*// A unique name is given to identify your Agent pre-shared key//*
TLSPSKFile=/etc/zabbix/zabbix_agentd.psk*// This helps the Zabbix agent to identify your PSK file created. //*
Step 4: Start the Zabbix Agent
Now you can save these changes and start the Zabbix agent and set it to start at boot time with these commands below:
~# systemctl start zabbix-agent # systemctl enable zabbix-agent Synchronizing state of zabbix-agent.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent
Our Zabbix agent is now ready to send data to the Zabbix server. But in order to use it, we have to link this Agent to it from the Zabbix server's web console.
Step 5: Adding our New host to the Zabbix Server
We've successfully installed/configured Zabbix Agent on our new host. Now we need to register this new node to our Zabbix server through our Web console. You can log in to our Zabbix server web-interface with the URL >>
http://Zabbix_ServerIP/zabbix/ with the Admin login credentials created. Now we can navigate through the path:
Configuration > Hosts > Create Host
This will open-up the host configuration page, where you can add the HOST name, IP details of the new host. Furthermore, you can choose the group to which you prefer to add this new host. You can either create a new group as your preference or you can add to the pre-existing groups. One host can be included in multiple groups as per our preference. Here, I'm adding our new node to the default
Linux Servers group.
After adding our host, we can modify its settings by selecting our added node from the Hosts list. I've chosen default Template
Template OS Linux for my node. You can choose any template as preferred from the Template lists.
Next, we need to navigate to the Encryption tab. As we've decided we need to choose PSK for both Connections to host and Connections from host. Then set
PSK identity to
PSK 001, which is the value of the
TLSPSKIdentity setting we configured in the Zabbix Agent in the beginning. Then set PSK value to the key you generated for the Zabbix agent. It's the one stored in the file
/etc/zabbix/zabbix_agentd.psk on the agent machine.
That's all! Now you will see your new host with green labels indicating that everything is working fine and the connection is encrypted.
To ensure things are working, you can even shut down your new host and see whether Zabbix is alerting about the problem. In that case, it will report a problem as seen in the screenshot.
- How to Install LAMP Stack on Ubuntu 18.04
- How to Install LEMP on Ubuntu 18.04
- How to Install and Use Netdata Monitoring Tool on Linux
- How to Install Icinga 2 and Icinga Web 2 on Debian 9.3
Similarly, you can add new hosts to your Zabbix server by installing and configuring the Zabbix Agent in there and registering it to your Zabbix server. I hope this article is useful and informative. Please post your valuable suggestions and comments on this.