DEV Community

Moses Daniel
Moses Daniel

Posted on

How to Integrate and Configure Zabbix for Monitoring IT Infrastructure

Introduction
Zabbix is a powerful open-source monitoring tool used to monitor IT infrastructure, applications, and services. It provides comprehensive visibility into your environment, enabling proactive issue resolution. In this article, we’ll walk you through the steps to integrate and configure Zabbix for your IT infrastructure.


Prerequisites
Before starting, ensure the following:

  • Server Requirements:
    • OS: Ubuntu 22.04 (or your preferred Linux distribution)
    • At least 2GB RAM and 10GB of disk space
  • Database: MySQL or PostgreSQL installed on the server
  • Network Setup: Open ports 80, 10051 (for Zabbix server), and 10050 (for Zabbix agents)

Step 1: Install Zabbix Server

  1. Update System Packages:
   sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode
  1. Add the Zabbix Repository:
   wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-5%2Bubuntu22.04_all.deb
   sudo dpkg -i zabbix-release_6.0-5+ubuntu22.04_all.deb
   sudo apt update
Enter fullscreen mode Exit fullscreen mode
  1. Install Zabbix Server and Agent:
   sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent -y
Enter fullscreen mode Exit fullscreen mode

Step 2: Configure Zabbix Database

  1. Install MySQL Server:
   sudo apt install mysql-server -y
Enter fullscreen mode Exit fullscreen mode
  1. Secure MySQL Installation:
   sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode
  1. Create a Database for Zabbix:
   mysql -u root -p
   CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
   CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
Enter fullscreen mode Exit fullscreen mode
  1. Import Zabbix Schema:
   zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix
Enter fullscreen mode Exit fullscreen mode

Step 3: Configure Zabbix Server

  1. Edit the Zabbix Server Configuration File:
   sudo nano /etc/zabbix/zabbix_server.conf
Enter fullscreen mode Exit fullscreen mode

Update:

   DBName=zabbix
   DBUser=zabbix
   DBPassword=your_password
Enter fullscreen mode Exit fullscreen mode
  1. Restart and Enable Zabbix Server:
   sudo systemctl restart zabbix-server zabbix-agent apache2
   sudo systemctl enable zabbix-server zabbix-agent apache2
Enter fullscreen mode Exit fullscreen mode

Step 4: Access the Zabbix Web Interface

  1. Open the Web UI: Navigate to http://<your_server_ip>/zabbix in a browser.
  2. Follow the Web Installer:

    • Choose your language.
    • Verify prerequisites.
    • Configure the database (use the zabbix user and database name).
    • Finalize the setup.
  3. Login to Zabbix:

    • Default Username: Admin
    • Default Password: zabbix

Step 5: Configure Zabbix Agents

  1. Install Zabbix Agent on a Monitored Host:
   sudo apt install zabbix-agent -y
Enter fullscreen mode Exit fullscreen mode
  1. Edit Agent Configuration:
   sudo nano /etc/zabbix/zabbix_agentd.conf
Enter fullscreen mode Exit fullscreen mode

Update:

   Server=<zabbix_server_ip>
   ServerActive=<zabbix_server_ip>
   Hostname=<monitored_host_name>
Enter fullscreen mode Exit fullscreen mode
  1. Restart the Agent:
   sudo systemctl restart zabbix-agent
   sudo systemctl enable zabbix-agent
Enter fullscreen mode Exit fullscreen mode

Step 6: Add Hosts to Zabbix

  1. Navigate to “Configuration > Hosts” in the Zabbix Web Interface.
  2. Add a New Host:
    • Hostname: Same as in zabbix_agentd.conf.
    • Group: Select or create a group (e.g., Linux Servers).
    • Interfaces: Add the IP address of the monitored host.
  3. Link a Template:
    • Go to “Templates” and select a Template OS Linux template.

Step 7: Set Up Alerts

  1. Navigate to “Configuration > Actions.”
  2. Create a Trigger:
    • Define a condition (e.g., CPU usage > 90%).
    • Configure an action (e.g., send email).
  3. Configure Media Types:
    • Go to “Administration > Media Types.”
    • Add email or other notification methods.

Step 8: Visualize Data

  1. Set Up Dashboards:
    • Navigate to “Monitoring > Dashboards.”
    • Create widgets for CPU, memory, disk, and network usage.
  2. Use Graphs:
    • Go to “Monitoring > Graphs” for detailed performance data.

Step 9: Secure Your Zabbix Installation

  1. Enable HTTPS:
    • Install SSL certificates using Let’s Encrypt or self-signed certificates.
    • Configure Apache to use HTTPS.
  2. Restrict Access:
    • Use a firewall (e.g., ufw) to allow only necessary ports.
   sudo ufw allow 22/tcp
   sudo ufw allow 80/tcp
   sudo ufw allow 443/tcp
   sudo ufw enable
Enter fullscreen mode Exit fullscreen mode

Step 10: Maintain and Monitor

  1. Update Zabbix:
    • Regularly check for updates and apply patches.
  2. Monitor Logs:
   sudo tail -f /var/log/zabbix/zabbix_server.log
Enter fullscreen mode Exit fullscreen mode
  1. Backup Configuration:
    • Export Zabbix configurations and regularly back up the database.

Image description

Image description

Image description

Conclusion
Zabbix is a comprehensive monitoring solution that can scale with your infrastructure. By following these steps, you’ll have a fully functional Zabbix setup that provides real-time insights and proactive issue resolution. If you encounter any challenges, refer to the official Zabbix documentation.

Top comments (0)