Arch Linux BasedManjaro

How To Install Zabbix on Manjaro

Install Zabbix on Manjaro

Imagine a scenario: It’s late, and you’re awakened by a notification. Your server is experiencing unusually high CPU usage. Thanks to proactive system monitoring, you identify a rogue process before it crashes your entire system. This is the power of Zabbix. In this guide, we’ll cover the necessary steps for Zabbix installation on Manjaro.

Zabbix stands out as a robust, open-source monitoring solution. It is designed to keep a watchful eye on your servers, networks, and applications. Zabbix provides real-time insights and alerts, allowing you to address issues promptly. You can customize Zabbix for a wide array of applications, so let’s delve into why combining Zabbix with Manjaro is an excellent choice.

Manjaro, known for its stability, customization options, and rolling release model, complements Zabbix perfectly. This combination ensures you have access to the latest features while maintaining a reliable monitoring infrastructure. This comprehensive guide provides a step-by-step walkthrough on how to install Zabbix on Manjaro. By following this tutorial, you will be well-equipped to monitor your systems effectively. Let’s get started.

What is Zabbix?

Zabbix is an enterprise-class, open-source distributed monitoring solution designed to monitor a variety of IT components, including network devices, servers, virtual machines (VMs), and applications. It offers a wide range of features that make it a favorite among system administrators and IT professionals. Its flexibility and scalability make it suitable for small and large infrastructures.

Key features of Zabbix include:

  • Real-time Monitoring: Zabbix provides real-time monitoring of various metrics. These can include CPU usage, memory utilization, network traffic, and disk space.
  • Data Visualization: Data collected by Zabbix can be visualized through graphs, dashboards, and reports, making it easy to identify trends and anomalies.
  • Alerting and Notifications: Zabbix can send alerts and notifications via email, SMS, or custom scripts when predefined thresholds are breached, enabling proactive issue resolution.
  • Agent-based and Agentless Monitoring: Zabbix supports both agent-based and agentless monitoring, providing flexibility in how you monitor your systems. Agent-based monitoring involves installing a Zabbix agent on the target host, while agentless monitoring uses protocols like SNMP or SSH.
  • Customizable Monitoring Templates: Zabbix offers customizable monitoring templates and triggers. You can tailor these to meet your specific monitoring needs.

Common use cases for Zabbix include:

  • Server Performance Monitoring: Tracking CPU usage, memory usage, disk I/O, and network traffic to ensure optimal server performance.
  • Network Health Checks: Monitoring network devices such as routers, switches, and firewalls to ensure network availability and performance.
  • Application Uptime Monitoring: Ensuring critical applications are running and responsive, with alerts triggered when issues are detected.

Prerequisites

Before you begin with the installation of Zabbix on Manjaro, ensure that you have the following prerequisites in place:

  • A Running Manjaro System: You need a running Manjaro system to install Zabbix. It is recommended to have a minimal system with at least 2GB of RAM and 20GB of disk space.
  • Root or Sudo Privileges: You need root or sudo privileges to install packages and configure the system. These privileges are necessary to execute commands that require administrative permissions.
  • Basic Familiarity with the Command Line: Basic knowledge of the command line is essential for executing commands and editing configuration files. Essential commands include pacman, systemctl, and nano.
  • Internet Connection: An active internet connection is required to download packages from the Manjaro repositories and the Zabbix repository.

Step-by-Step Installation Guide

Follow these steps to install Zabbix server, Zabbix frontend, and Zabbix agent on your Manjaro system.

Updating the System

Before installing any new software, it’s crucial to update your system to ensure you have the latest package information and updates. Open your terminal and run the following command:

sudo pacman -Syu

This command synchronizes the package database and upgrades all installed packages to their latest versions. Regular updates enhance system stability and security.

Adding the Zabbix Repository

To install Zabbix, you need to add the official Zabbix repository to your system’s package manager. This repository contains the Zabbix packages required for installation. Open the pacman.conf file using the nano editor:

sudo nano /etc/pacman.conf

Scroll to the end of the file and add the following lines:

[zabbix]
 SigLevel = Optional TrustAll
 Server = http://repo.zabbix.com/zabbix/7.0/arch/$arch
  • [zabbix]: This line defines the name of the repository.
  • SigLevel = Optional TrustAll: This line sets the signature level for the repository. Optional TrustAll means that package signatures are not required, and all packages from this repository are trusted.
  • Server = http://repo.zabbix.com/zabbix/7.0/arch/$arch: This line specifies the URL of the Zabbix repository. The $arch variable is automatically replaced with your system’s architecture (e.g., x86_64).

Save the file and exit the nano editor. Next, update the package database to include the newly added repository:

sudo pacman -Syy

This command forces pacman to download the latest package lists from all configured repositories. You can now install Zabbix server, Zabbix frontend, and Zabbix agent from the Zabbix repository.

Installing Zabbix Server, Frontend, and Agent

With the Zabbix repository added and the package database updated, you can now install the necessary Zabbix components. Run the following command:

sudo pacman -S zabbix zabbix-server zabbix-web-nginx-pgsql
  • zabbix: This package contains common files required by other Zabbix components.
  • zabbix-server: This package contains the Zabbix server daemon, which is responsible for collecting and processing monitoring data.
  • zabbix-web-nginx-pgsql: This package includes the Zabbix frontend, Nginx web server configuration, and PostgreSQL database support. It provides the web interface for accessing and managing Zabbix.

If you prefer using Apache instead of Nginx, you can install the zabbix-web-apache-pgsql package. Note that you should only install one web server package (either Nginx or Apache). It is important to remember that this choice defines how you will access the Zabbix web interface.

During the installation, you may encounter errors related to unmet dependencies or conflicts. Resolve these issues by carefully reading the error messages and installing any missing packages. If conflicts arise, try removing conflicting packages before proceeding with the Zabbix installation. Here are some common issues:

  • Dependency Errors: If you encounter dependency errors, use the pacman -S command to install the missing dependencies. For example, if the error message indicates a missing library, run sudo pacman -S <library_name>.
  • Package Conflicts: If there are package conflicts, try removing the conflicting packages using sudo pacman -R <package_name> before reinstalling Zabbix.

Creating the Database

Zabbix requires a database to store configuration data, historical data, and events. You can use either MariaDB or PostgreSQL. This guide uses PostgreSQL.

PostgreSQL

First, create a database and a user for Zabbix:

sudo -u postgres createdb zabbix
sudo -u postgres createuser zabbix

Next, connect to the PostgreSQL server and set a password for the Zabbix user and grant the necessary privileges:

sudo -u postgres psql

Execute the following SQL commands:

ALTER USER zabbix WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE zabbix to zabbix;
\q
  • ALTER USER zabbix WITH ENCRYPTED PASSWORD 'password';: This command sets an encrypted password for the zabbix user. Replace 'password' with a strong, secure password.
  • GRANT ALL PRIVILEGES ON DATABASE zabbix to zabbix;: This command grants all privileges on the zabbix database to the zabbix user. This allows the Zabbix server to read and write data to the database.
  • \q: This command exits the PostgreSQL command-line interface.

These commands create the database and configure user privileges for Zabbix to function correctly with PostgreSQL.

MariaDB

If you prefer to use MariaDB, the process is similar. Log in to the MariaDB server as the root user:

sudo mysql -u root -p

Enter the root password when prompted. Then, execute the following SQL commands to create the database and user:

CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
EXIT;
  • CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;: This command creates a new database named zabbix with UTF-8 encoding, ensuring proper storage of international characters.
  • CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';: This command creates a new user named zabbix with the specified password, restricting access to the local host. Replace 'password' with a strong, secure password.
  • GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';: This command grants all privileges on the zabbix database to the zabbix user, allowing full access to the database.
  • FLUSH PRIVILEGES;: This command reloads the grant tables, ensuring that the new privileges are immediately applied.
  • EXIT;: This command exits the MariaDB command-line interface.

Configuring the Zabbix Server

After setting up the database, you need to configure the Zabbix server to connect to it. Open the Zabbix server configuration file using the nano editor:

sudo nano /etc/zabbix/zabbix_server.conf

Find the following lines and update them with your database details:

DBName=zabbix
DBUser=zabbix
DBPassword=password
  • DBName=zabbix: This specifies the name of the database Zabbix will use.
  • DBUser=zabbix: This specifies the username Zabbix will use to connect to the database.
  • DBPassword=password: This specifies the password for the Zabbix database user.

Replace password with the actual password you set for the Zabbix database user. Additionally, consider setting up a firewall to protect your monitoring data.

There are other parameters in the configuration file. These can be configured to suit your specific environment:

  • ListenPort: Specifies the port on which the Zabbix server listens for incoming connections. The default port is 10051.
  • LogFile: Specifies the path to the Zabbix server log file. It is useful for troubleshooting and monitoring Zabbix server activity.

Save the file and exit the nano editor. Ensure that you keep your monitoring environment secure by regularly reviewing and updating these settings.

Configuring the Frontend (Nginx)

If you installed the zabbix-web-nginx-pgsql package, you need to configure Nginx to serve the Zabbix frontend. Open the Nginx configuration file:

sudo nano /etc/nginx/nginx.conf

Add the following lines inside the http block:

server {
  listen 80;
  server_name zabbix.example.com;
  root /usr/share/zabbix;
  index index.php;
  access_log /var/log/nginx/zabbix.access.log;
  error_log /var/log/nginx/zabbix.error.log;
 

  location / {
  try_files $uri $uri/ /index.php?$args;
  }
 

  location ~ \.php$ {
  fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
  }
 }
 
  • listen 80;: This directive tells Nginx to listen on port 80 for incoming HTTP requests.
  • server_name zabbix.example.com;: This directive sets the server name or domain name for your Zabbix installation. Replace zabbix.example.com with your actual domain name or IP address.
  • root /usr/share/zabbix;: This directive specifies the root directory for the Zabbix frontend files.
  • index index.php;: This directive sets the default index file for the Zabbix frontend.
  • location / { ... }: This block configures how Nginx handles requests to the root directory. It tries to serve static files first and, if not found, passes the request to the index.php file.
  • location ~ \.php$ { ... }: This block configures how Nginx handles PHP files. It passes PHP files to the PHP-FPM (FastCGI Process Manager) for processing.

Save the file and restart Nginx to apply the changes:

sudo systemctl restart nginx

After restarting Nginx, the Zabbix web interface should be accessible through your specified domain name or IP address.

Starting and Enabling Zabbix Server

With the configuration complete, start the Zabbix server and enable it to start automatically at boot:

sudo systemctl start zabbix-server
sudo systemctl enable zabbix-server
  • sudo systemctl start zabbix-server: This command starts the Zabbix server daemon.
  • sudo systemctl enable zabbix-server: This command enables the Zabbix server to start automatically when the system boots up.

Enabling the Zabbix server ensures that it runs continuously, providing uninterrupted monitoring of your systems. Now that the Zabbix server is up and running, it’s time to configure the frontend through the web interface.

Initial Zabbix Frontend Configuration

To complete the Zabbix installation, you need to configure the frontend through the web interface. Open your web browser and navigate to http://your-ip-address-or-domain-name/zabbix. You will be greeted by the Zabbix web installation wizard.

Install Zabbix on Manjaro

Follow these steps to complete the initial configuration:

  1. Language Selection: Choose your preferred language and click “Next step”.
  2. Prerequisite Check: The wizard checks if all the necessary prerequisites are met. If any prerequisites are missing, install them and refresh the page. Click “Next step” to continue.
  3. Database Configuration: Enter the database details you configured earlier:
    • Database type: PostgreSQL
    • Database host: localhost
    • Database port: 5432
    • Database name: zabbix
    • Database user: zabbix
    • Database password: your_password

    Click “Next step”.

  4. Zabbix Server Details: Enter the Zabbix server details:
    • Name: Zabbix server
    • Timezone: Choose your appropriate timezone.

    Click “Next step”.

  5. Pre-Installation Summary: Review the configuration summary and click “Next step” to complete the installation.
  6. Finish Installation: Click “Finish” to complete the installation. You will be redirected to the Zabbix login page.

After the installation is complete, log in with the default credentials:

  • Username: Admin
  • Password: zabbix

Once logged in, change the default password for security reasons. Navigate to “User profile” and click the “Change password” button.

Configuring Zabbix Agent on the Host

To monitor the Manjaro host itself, you need to install and configure the Zabbix agent. The Zabbix agent collects data from the host and sends it to the Zabbix server. This data includes CPU usage, memory utilization, disk space, and network traffic. You can use the Zabbix agent to monitor various aspects of your system’s performance.

Install the Zabbix agent using the following command:

sudo pacman -S zabbix-agent

Edit the Zabbix agent configuration file:

sudo nano /etc/zabbix/zabbix_agentd.conf

Find the following lines and update them:

Server=your_zabbix_server_ip
Hostname=your_host_name
  • Server=your_zabbix_server_ip: Replace your_zabbix_server_ip with the IP address of your Zabbix server. This tells the agent where to send the monitoring data.
  • Hostname=your_host_name: Replace your_host_name with the hostname of the machine where the agent is installed. This identifies the host in the Zabbix frontend.

Save the file and start and enable the Zabbix agent:

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

After configuring the Zabbix agent, the host will appear in the Zabbix frontend, and you can begin monitoring its metrics.

Basic Zabbix Usage

Now that you have installed and configured Zabbix, it’s time to learn some basic usage. This section covers adding a host to monitor, creating a simple trigger, and viewing graphs and data.

To add a host to monitor:

  1. Log in to the Zabbix frontend.
  2. Navigate to “Configuration” -> “Hosts”.
  3. Click “Create host”.
  4. Enter the host details:
    • Hostname: The hostname of the machine you want to monitor.
    • Visible name: A friendly name for the host.
    • Groups: Add the host to relevant host groups.
    • Interfaces: Add an agent interface with the IP address of the host.
  5. Click “Add” to create the host.

To create a simple trigger:

  1. Navigate to “Configuration” -> “Hosts” and select the host you just added.
  2. Click “Triggers” -> “Create trigger”.
  3. Enter the trigger details:
    • Name: A descriptive name for the trigger (e.g., “CPU Usage High”).
    • Expression: Define the trigger expression (e.g., {your_host_name:system.cpu.util[,avg5].avg(5m)}>90 for CPU usage above 90% over 5 minutes).
    • Severity: Set the severity level (e.g., “Warning”, “Average”, “High”).
  4. Click “Add” to create the trigger.

To view graphs and data:

  1. Navigate to “Monitoring” -> “Latest data”.
  2. Select the host you want to view data for.
  3. Choose the item you want to graph (e.g., “CPU utilization”).
  4. Click “Graph” to view the historical data.

These basic steps will help you get started with monitoring your systems using Zabbix. Explore additional features to enhance your monitoring capabilities.

Troubleshooting Common Issues

During the installation and configuration of Zabbix, you may encounter some common issues. Here are some troubleshooting tips to help you resolve them.

  • Zabbix Server Not Starting:
    • Check the Zabbix server log file (/var/log/zabbix/zabbix_server.log) for any error messages.
    • Verify that the database connection details in /etc/zabbix/zabbix_server.conf are correct.
    • Ensure that the database server is running and accessible.
  • Agent Not Connecting:
    • Check the Zabbix agent log file (/var/log/zabbix/zabbix_agentd.log) for any error messages.
    • Verify that the Server parameter in /etc/zabbix/zabbix_agentd.conf is set to the correct Zabbix server IP address.
    • Ensure that the firewall is not blocking traffic between the Zabbix server and the agent.
  • Frontend Not Accessible:
    • Check the Nginx/Apache configuration to ensure it is correctly set up to serve the Zabbix frontend.
    • Verify that the web server is running and accessible.
    • Check the PHP configuration to ensure all required extensions are installed and enabled.
  • SELinux Considerations:
    • If SELinux is enabled, it may block Zabbix from accessing certain resources. You may need to create SELinux policies to allow Zabbix to function correctly.

By following these troubleshooting steps, you can resolve common issues and ensure that your Zabbix installation is running smoothly.

Advanced Zabbix Configuration (Optional)

Once you have Zabbix up and running, you can explore some advanced configuration options to enhance your monitoring capabilities.

  • Using Zabbix Templates: Zabbix provides templates for monitoring common services such as HTTP, MySQL, and more. These templates include predefined items, triggers, and graphs, making it easy to monitor these services.
  • Setting Up Custom Alerts and Notifications: You can configure custom alerts and notifications based on specific triggers. Zabbix supports various notification methods, including email, SMS, and custom scripts.
  • Exploring Zabbix API: The Zabbix API allows you to automate various tasks, such as adding hosts, creating items, and retrieving data. You can use the API to integrate Zabbix with other systems and automate your monitoring workflows.

These advanced configuration options enable you to tailor Zabbix to your specific monitoring needs and automate your monitoring tasks.

Congratulations! You have successfully installed Zabbix. Thanks for using this tutorial for installing the Zabbix open-source monitoring software on Manjaro system. For additional or useful information, we recommend you check the official Zabbix website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button