Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Step by Step Guide to Monitor PostGreSQL using Zabbix Agent

# 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
Code language: PHP (php)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x