In the first part of this article, we showed you how to install Zabbix from your Ubuntu 18.04 server command line. In our second part, we’ll help you configure the settings for Zabbix from its interface.
The Zabbix interface allows you to add hosts and view reports of the host you are managing. But before you can use this interface, you must perform some initial configuration.
This guide will pick up from where we left in PART ONE: How to Install Zabbix on an Ubuntu 18.04 VPS or Dedicated Server, and show you how to set up the Zabbix interface settings.
If you have VPS or a dedicated server web hosting setup with Ubuntu 18.04, then let’s get started!
Setting Up The Web Interface
Launch your favorite web browser and search http//your IP address or Zabbix server hostname/Zabbix/ to access the welcome page.
Click Next step to view all the prerequisites.
Scroll down the list and ensure all the values are labeled OK. If every configuration requirement is met, hit Next step to continue to the database configuration page.
We configured the database on a Zabbix server (in the previous article), and here we need to configure the settings to allow the Zabbix interface to access this database to read data and manage hosts.
Enter your MySQL credentials as set in step 3 of the previous article, then select Next step toproceed to a Zabbix server details page.
Leave these options at their default values. The Name option is utilized in a Zabbix server to differentiate servers in a case where there are multiple monitoring servers. You need not provide this name; it is optional.
Now, hit Next step to view the pre-installation summary.
Check to see if all the settings are configured correctly. If all the settings are okay, hit Next step to access the final page.
Click Finish to complete the configuration. The web interface configuration process creates a config file in the location /usr/share/zabbix/conf/zabbix.conf.php. This file can be backed up and used later.
Installing A Zabbix Agent
The next step is installing and setting up a Zabbix Agent. The agent is the software installed on the server to be monitored to send data to a Zabbix server.
Log in to the server you want to monitor, and follow the steps below to complete the configuration:
First, execute the command below to install a repository for the configuration package,
$ wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.2-1+xenial_all.deb $ sudo dpkg -i zabbix-release_3.2-1+xenial_all.deb
Next, run the command below to update your package index:
$ sudo apt-getupdate
Then, issue the command below to install the Agent:
$ sudo apt-get install zabbix-agent
Now, let us secure the ServerAgent connection using the preshared keys (PSK). To generate the PSK, execute the command below;
$ sudo sh -c "openssl rand -hex 32 > /etc/zabbix/zabbix_agentd.psk"
Run the command below to display the key:
$ cat /etc/zabbix/zabbix_agentd.psk
This key will be something like:
Note: Copy this key somewhere, you will need it when configuring the host.
To edit the Agent’s settings, execute the command below to open its configuration file:
$ sudo nano /etc/zabbix/zabbix_agentd.conf
Once the file opens, find the section below:
### Option: Server # List of comma delimited IP addresses (or hostnames) of Zabbix servers. # 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. # # Mandatory: no # Default: # Server= Server=127.0.0.1
change your IP address to match the one for the Zabbix server.
Next, find the following section:
### 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=unencrypted
Replace the placeholder unencrypted with psk:
Next, find the section TLSAccept:
### 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=unencrypted
Change unencrypted to psk, that is:
Find the section TLSPSKIdentity:
### Option: TLSPSKIdentity # Unique, case sensitive string used to identify the pre-shared key. # # Mandatory: no # Default: # TLSPSKIdentity=
And add a unique identifier for the preshared key. For example:
Note: Note the unique identifier somewhere, you will use it as your PSK ID when configuring the Zabbix Host.
Now find the TLSPSKFile section:
### Option: TLSPSKFile # Full pathname of a file containing the pre-shared key. # # Mandatory: no # Default: # TLSPSKFile=
Add the file (/etc/zabbix/zabbix_agentd.psk) created in the previous step here to have the following results:
Save the changes and exit the nano editor.
Next, execute the command below to start the Agent, and enable it to run at boot time:
$ sudo systemctl start zabbix-agent $ sudo systemctl enable zabbix-agent
Then, run the command below to check the status of the Zabbix agent:
$ sudo systemctl status zabbix-agent
If everything is okay, you will get the following output:
● zabbix-agent.service - Zabbix Agent Loaded: loaded (/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2017-06-08 08:33:52 UTC; 4s ago Process: 18185 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS) ...
That is it! Your Zabbix agent is fully configured to transmit data to your Zabbix server.
Registering A Host On Your Zabbix Server
Now you have successfully configured the Zabbix web interface and installed Zabbix Agent on the server to be monitored. Now let us register the host to be monitored on the Zabbix server.
Go to your favorite browser and search http://your_zabbix_server_ip_address/zabbix/. This will take you to a Zabbix Server login page:
Enter your login credentials and click Sign in.
Once you sign in, navigate to Configuration> Hosts> Create host to access the host’s configuration page.
Enter the Hostname and the IP of the client machine. Add your new host to Linux Server group, then click Templates to continue:
Find the search section and search Template OS Linux. Once you find this template, hit Add to incorporate it to your host. Click Encryption and choose the PSK option for Connections from host and Connections to host. Next, set PSK 001 as the PSK identity, and set the value of PSK to a key generated when installing your Zabbix agent. Once everything is set as per the instruction click Add to create your new host.
Your new host will be created and labeled in green to show it’s running properly and all connections are encrypted:
After some minutes, go to Latest data and Monitoring to view the latest data from the Zabbix Agent.
Now you can shut down the monitored server to view how Zabbix will notify you to issues. Once the monitored server has been shut down, you will see the following on Zabbix main dashboard:
That is it! You have put everything in place and should be easy to use Zabbix to monitor various critical components of your server.
Check out these top 3 Linux hosting services