For the complete documentation index, see llms.txt. This page is also available as Markdown.

39.1 Zabbix Monitoring System (with PostgreSQL)

Zabbix is an enterprise-grade distributed open-source monitoring solution that provides real-time monitoring and alerting for network devices, servers, applications, and cloud services. This section uses the Ports method and provides complete installation and configuration steps based on PostgreSQL.

Installing zabbix7-server

zabbix7-server is the server-side component (Zabbix Server), responsible for receiving and processing monitoring data. It should be installed on the monitoring server.

Installing via pkg will additionally introduce MySQL dependencies and may cause binding conflicts. Therefore, it is recommended to use the Ports method for installation to more precisely control dependencies and configuration options.

# cd /usr/ports/net-mgmt/zabbix7-server/
# make config
Zabbix Ports Configuration

Configure as shown in the figure, select the PGSQL option and confirm, then execute the build and install commands. The build process is time-consuming:

Installing PostgreSQL

Zabbix requires a database to store monitoring data.

For the installation, initialization, and service auto-start configuration of PostgreSQL 16, please refer to the relevant chapter in this book.

Installing Nginx

The Zabbix frontend needs to be accessed through a web server. This section uses Nginx as the web server. For the installation and service auto-start configuration of Nginx, please refer to the relevant chapter in this book.

Installing zabbix7-frontend

zabbix7-frontend is the web frontend (Zabbix Frontend), providing a graphical monitoring management interface.

Install via pkg:

The above installation process will automatically install PHP. The version installed in this section is PHP 8.3. Zabbix 7.0.10 and later also officially supports PHP 8.4. If needed, you can use zabbix7-frontend-php84 and the corresponding php84 extension packages. For available versions, please refer to zabbix7-frontend, which provides the latest package information and compatibility notes.

You can also install via the Ports method:

PDO

The Zabbix frontend needs to access the PostgreSQL database via PHP, so the corresponding PHP database extensions must be installed. PDO (PHP Data Objects) is the unified interface for PHP to access databases. The PHP version must be compatible with the Zabbix frontend.

Install PHP database extensions using pkg:

You can also install PHP database extensions via the Ports method:

Installing zabbix7-agent

zabbix7-agent is the Zabbix client agent program, responsible for collecting monitoring data on the monitored host and sending it to the Zabbix Server. It should be installed on the hosts that need to be monitored and can be deployed on multiple hosts to achieve distributed monitoring.

Install zabbix7-agent using pkg:

You can also install zabbix7-agent via the Ports method:

Daemons

The related services need to be configured to start automatically at system boot.

Setting Up the PostgreSQL Database

You need to create a dedicated database and user in PostgreSQL for Zabbix, and import the initial Zabbix data. After the PostgreSQL database initialization is complete, execute the following commands:

Tip

The your_strong_password in the above example is a placeholder and must be replaced with an actual strong password.

You must exit the current session first, then continue with the subsequent operations using the correct user permissions:

References

Configuring Zabbix Server

You need to configure the main configuration file of Zabbix Server to connect to the PostgreSQL database.

Directory structure:

The main configuration file for Zabbix Server is located at /usr/local/etc/zabbix7/zabbix_server.conf.

Add the following content:

Configuring Zabbix Agent

You need to configure the main configuration file of Zabbix Agent to communicate with Zabbix Server. The Zabbix Agent configuration file is located at /usr/local/etc/zabbix7/zabbix_agentd.conf.

Add the following content:

Configuring the Zabbix Frontend

You need to configure the Zabbix frontend configuration file to connect to the PostgreSQL database. The Zabbix frontend configuration template is located at /usr/local/www/zabbix7/conf/zabbix.conf.php.example (Zabbix Frontend configuration template).

Copy the Zabbix example configuration file to the active configuration file:

Edit the /usr/local/www/zabbix7/conf/zabbix.conf.php file, changing:

to the following:

Note

The above configuration is suitable for local development and testing environments. For production environments, it is recommended to:

  • Enable TLS encryption for communication between Zabbix Server, Agent, and the web frontend

  • Configure HTTPS using an Nginx reverse proxy to avoid transmitting monitoring data and login credentials in plain text

Configuring Nginx

You need to configure Nginx to provide web access for the Zabbix frontend. Back up the original Nginx main configuration file:

Edit the /usr/local/etc/nginx/nginx.conf file, replacing the original content with the following:

Configuring PHP

You need to configure PHP to meet the runtime requirements of the Zabbix frontend.

Editing the /usr/local/etc/php.ini-production File

Copy the production PHP configuration file as the default configuration file:

Edit the /usr/local/etc/php.ini file:

  • Find ;date.timezone = and change it to date.timezone = Asia/Shanghai (you need to remove the leading semicolon ;)

  • Find post_max_size = 8M and change it to post_max_size = 16M

  • Find max_execution_time = 30 and change it to max_execution_time = 300

  • Find max_input_time = 60 and change it to max_input_time = 300

Starting Services

After all configurations are complete, you need to start the related services in order to ensure the Zabbix monitoring system runs properly.

Logging In

After the services start successfully, you can access the Zabbix web frontend through a browser to complete login and configuration. The default username and password for the Zabbix web frontend are as follows:

  • Username: Admin

  • Password: zabbix

Note

The default password is public information. Please change it to a strong password immediately after logging in via "User settings → Change password".

Zabbix Login Interface

Configuring Chinese Language

After logging in to Zabbix, you can set the interface language to Chinese.

Zabbix Interface
Zabbix Chinese Configuration
Zabbix Chinese Interface

Troubleshooting and Outstanding Issues

If anomalies occur during Zabbix operation, you can check the relevant log files for troubleshooting. This section also lists several items that need improvement.

Logs

Zabbix log files are located at the following paths.

  • Agent: /var/log/zabbix/zabbix_agentd.log file

  • Server: /var/log/zabbix/zabbix_server.log file

  • PHP-related errors: /var/log/nginx/error.log file

Unresolved Issues

The following are issues that need further investigation:

  • Chinese text displays garbled characters;

  • Some monitoring items are not displayed;

  • HTTP and other security configurations need improvement.

References

Last updated