LogoOwlDocs

Introduction to Zabbix

What is Zabbix and what are its use cases ?

What is Zabbix

Zabbix is an open-source monitoring solution designed to track the status of various network services, servers, and other IT resources. It provides real-time monitoring, alerting, and visualization, making it suitable for both small and large-scale environments. Zabbix helps organizations ensure the reliability and performance of their infrastructure by collecting metrics, analyzing data, and notifying administrators of potential issues.

Core Concepts

Zabbix is built around several key concepts :

  • Hosts : Devices or services being monitored.
  • Items : Metrics or data points collected from hosts.
  • Triggers : Conditions that define when an alert should be generated.
  • Actions : Automated responses to triggers, such as sending notifications.
  • Templates : Predefined sets of items, triggers, and actions for easy reuse.

Understanding these concepts helps you efficiently configure and manage your monitoring environment.

Hosts

A Host in Zabbix represents any device, server, or service you want to monitor. Hosts can be physical machines, virtual servers, network devices, or cloud resources. Each host is configured with specific parameters and linked to items, triggers, and templates to define what data is collected and how alerts are managed.

Items

An Item in Zabbix defines a specific metric or data point to be collected from a host. Items can monitor values such as CPU usage, memory consumption, disk space, network traffic, or application-specific statistics. Each item is configured with a type (e.g., agent, SNMP, HTTP), a key (identifying what to collect), and an interval (how often to collect the data). Properly configuring items ensures you gather relevant information for effective monitoring and analysis.

Triggers

A Trigger in Zabbix defines a logical condition based on the values of one or more items. Triggers are used to detect problems or abnormal states in your monitored hosts. For example, a trigger can be set to alert you if CPU usage exceeds a certain threshold or if a service becomes unavailable. When a trigger condition is met, Zabbix can generate an alert and execute predefined actions. Properly configuring triggers ensures timely detection and response to issues in your infrastructure.

Actions

Actions in Zabbix are automated responses triggered when certain conditions are met, such as when a trigger fires. Actions can include sending notifications (email, SMS, etc.), or executing remote commands. By configuring actions, you ensure that the right people are alerted and that corrective measures can be taken automatically, helping to minimize downtime and improve incident response.

Templates

A Template in Zabbix is a reusable set of monitoring definitions, including items, triggers, and actions. Templates allow you to quickly apply consistent monitoring configurations to multiple hosts. By linking hosts to templates, you can standardize monitoring across your infrastructure, simplify management, and ensure best practices are followed. Templates are especially useful for environments with many similar devices or services, as they reduce manual configuration and make updates easier.

Use Cases

Zabbix is a versatile monitoring tool used in a variety of scenarios, including:

  • Server Monitoring : Checking server health and performance.
  • Network Monitoring : Watching network devices for outages or issues.
  • Application Monitoring : Tracking web servers, databases, and apps.

These use cases help organizations quickly spot problems and keep systems running smoothly.

Installing Zabbix

Become the root user to perform administrative tasks :

sudo -s

Install the Zabbix repository to enable access to the latest Zabbix packages :

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_6.0+ubuntu24.04_all.deb
dpkg -i zabbix-release_latest_6.0+ubuntu24.04_all.deb
apt update

Install the Zabbix server, frontend, and agent components :

apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

Create the default Zabbix database in MySQL to store monitoring data :

mysql -u root -p

Inside the MySQL shell, run the following commands to create the Zabbix database and user, and grant the necessary privileges :

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;

Import the initial Zabbix database schema and data :

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

After importing the schema, disable log_bin_trust_function_creators for security :

mysql -uroot -p

Run this command in the MySQL shell to reset log_bin_trust_function_creators for security :

mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

Configure the Zabbix server to use the database password

Edit /etc/zabbix/zabbix_server.conf and set :

DBPassword=password

Edit /etc/zabbix/nginx.conf to set up the web interface. Uncomment or adjust the following lines as needed :

listen 8080;
server_name example.com;

Use the following commands to start and enable the Zabbix server, agent, and related services :

systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm
systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm

Once all services are running, open your web browser and navigate to:

http://<your-server-ip>:8080

Uninstalling Zabbix

Stop all Zabbix-related services to begin the uninstallation process :

sudo systemctl stop zabbix-server zabbix-agent nginx php8.3-fpm

Disable Zabbix services to prevent them from starting automatically on boot :

sudo systemctl disable zabbix-server zabbix-agent nginx php8.3-fpm

Uninstall all Zabbix components from your system using the following commands :

sudo apt remove --purge zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
sudo apt autoremove

Remove the Zabbix repository to prevent future package updates :

sudo rm /etc/apt/sources.list.d/zabbix.list
sudo apt update

Clean up configuration files and directories left behind by Zabbix :

sudo rm -rf /etc/zabbix /usr/share/zabbix /var/log/zabbix /var/lib/zabbix

If you want to completely remove all monitoring data, you can delete the Zabbix database and user from MySQL :

mysql -u root -p

Then, inside the MySQL shell, run the following commands to remove the Zabbix database and user :

DROP DATABASE zabbix;
DROP USER 'zabbix'@'localhost';