# Step 1: Install Zabbix Agent on the PostgreSQL Server
# Install Zabbix repository (Ubuntu example)
sudo wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo apt update
# Install Zabbix Agent
sudo apt install zabbix-agent
# Step 2: Configure Zabbix Agent
# Edit Zabbix agent configuration
sudo nano /etc/zabbix/zabbix_agentd.conf
# Make changes to the file:
# Server=<Zabbix server IP>
# ServerActive=<Zabbix server IP>
# Hostname=<Name of the PostgreSQL server>
# Restart Zabbix Agent
sudo systemctl restart zabbix-agent
# Step 3: Configure PostgreSQL for Monitoring
# Edit PostgreSQL configuration file
sudo nano /etc/postgresql/12/main/postgresql.conf
# Add or uncomment the following lines:
# shared_preload_libraries = 'pg_stat_statements'
# pg_stat_statements.track = all
# Restart PostgreSQL to apply changes
sudo systemctl restart postgresql
# Create a monitoring role in PostgreSQL
sudo -u postgres psql -c "CREATE ROLE zabbix WITH LOGIN PASSWORD 'zabbix_password';"
sudo -u postgres psql -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO zabbix;"
# Step 4: Set up the Zabbix Template and Items
# Import PostgreSQL monitoring template in Zabbix server (manually via Zabbix UI)
# Path: Configuration > Templates > Import
# Link the template to your host in Zabbix server
# Path: Configuration > Hosts > select your host > Templates tab > Add the PostgreSQL template > Update
# Step 5: Test and Validate
# Check if data is being collected in Zabbix server
# Path: Monitoring > Latest Data > Filter by your PostgreSQL server's name
# Troubleshoot any issues by checking logs
# Check Zabbix Agent logs
cat /var/log/zabbix/zabbix_agentd.log
# Check PostgreSQL logs
cat /var/log/postgresql/postgresql-12-main.log
Latest posts by Rajesh Kumar (see all)
- Discover the Heart of India with Mera Apna Bihar - December 20, 2024
- Experience the Pulse of Bangalore with Bangalore Orbit - December 20, 2024
- Discover the City of Lakes with Bhopal Orbit - December 20, 2024