In this video we will configure a Postgresql (DB) instance from scratch to be able to monitor it in real time through Zabbix.
⏰ TIMESTAMPS:
Intro (0:00)
Install Postgresql (0:08)
Configure user and permissions in Postgresql (0:38)
Download required for Postgresql monitoring (1:19)
Necessary configurations in Linux (1:46)
Zabbix Frontend Configuration (4:56)
Solution to error: Special characters not allowed (6:58)
Check Postgres data in Zabbix (9:23)
✍ Instructions and commands:
Install Postgresql from Scratch
sudo apt install postgresql postgresql-contrib -y
systemctl restart postgresql
systemctl status postgresql
Enter the Postgresql instance
sudo -u postgres psql
Create User and permissions for Zabbix monitoring
CREATE USER zbx_monitor WITH PASSWORD 'Cyt.1234' INHERIT;
(If the role does not exist, create it with: CREATE ROLE pg_monitor;)
GRANT pg_monitor TO zbx_monitor;
\q
Download Zabbix repository that contains the queries necessary for its operation
git clone https://github.com/zabbix/zabbix.git
Create folder and move config
mkdir /var/lib/zabbix
cp -r ./zabbix/templates/db/postgresql/. /var/lib/zabbix/
cd /var/lib/zabbix
cp /var/lib/zabbix/template_db_postgresql.conf /etc/zabbix/zabbix_agentd.d/
Configure the postgres file
sudo nano /etc/postgresql/14/main/pg_hba.conf
Change in Postgres config
sudo nano /etc/postgresql/(version)/main/postgresql.conf
Open connection to postgres port: listen_addresses = '0.0.0.0'
sudo nano /etc/postgresql/(version)main/pg_hba.conf
Add to end of file
host all zbx_monitor 127.0.0.1/32 trust
host all zbx_monitor 0.0.0.0/0 md5
host all zbx_monitor ::0/0 md5
systemctl restart zabbix-agent.service
systemctl restart postgresql
ufw allow 5432
On Zabbix Frontend
Add Template to the host named: PostgreSQL by Zabbix agent 2
Modify Macros
Macro key value
{$PG.HOST} IpHost
{$PG.PORT} 5432
{$PG.USER} zbx_monitor
{$PG.PASSWORD} PasswordUserPostgresql
{$PG.DB} postgres
Bug fix: "Special characters are not allowed in the parameters."
Change our user's password without any special sign
sudo -u postgres psql
ALTER USER zbx_monitor WITH PASSWORD 'new_password';
\q