Lesstion 3 - Zabbix Agent 2 on Ubuntu 22.04 monitors a PostgreSQL server
02/03/2023 - 1 phút
Step 1: Install Zabbix Agent 2
- Install Zabbix repository
# wget https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-4%2Bubuntu22.04_all.deb
# dpkg -i zabbix-release_6.2-4+ubuntu22.04_all.deb
# apt update
- Install Zabbix Agent2
apt install zabbix-agent2 zabbix-agent2-plugin-*
- Start Zabbix Agent2 process
# systemctl restart zabbix-agent2
# systemctl enable zabbix-agent2
Step 2: Configure Zabbix Agent 2 to point to Zabbix Server
As in the Zabbix server installation at address 10.19.2.1
Use the following command to open the Zabbix configuration file:
nano /etc/zabbix/zabbix_agent2.conf
Find and change the configuration:
ListenIP=0.0.0.0
Server=10.19.2.1
Hostname=Zabbix PostgreSQL
Save and restart the service:
systemctl restart zabbix-agent2
Step 2: Log in to Zabbix and add to hosts: http://10.19.2.1/zabbix/zabbix.php?action=host.view
Select as shown in the image
Step 3: Configure the PostgreSQL by Zabbix agent 2 template
- Create a PostgreSQL user for monitoring (password here is set to Password@123):
CREATE USER zbx_monitor WITH PASSWORD 'Password@123' INHERIT;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_dir(text) TO zbx_monitor;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_stat_file(text) TO zbx_monitor;
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_waldir() TO zbx_monitor;
- Edit pg_hba.conf to allow connections from Zabbix:
# TYPE DATABASE USER ADDRESS METHOD
host all zbx_monitor localhost md5
For more information, please refer to the PostgreSQL documentation https://www.postgresql.org/docs/civerse/auth-pg-hba-conf.html
- Set the system data source name of the PostgreSQL version in the {$PG.URI} macro, such as <protocol(host:port)>
- Set the username and password in the server macro ({$PG.USER} and {$PG.PASSWORD}) if you want to override the parameters from the Zabbix agent configuration file
Reference link: https://www.zabbix.com/integrations/postgresql#postgresql_agent2