๐ AlmaLinux Network Monitoring with Zabbix Complete Setup Guide
Ready to gain complete visibility into your network infrastructure? ๐ Zabbix is the ultimate enterprise monitoring solution that transforms raw network data into actionable insights! This comprehensive guide will help you build a powerful monitoring system on AlmaLinux that watches over every device, service, and metric in your environment! โจ
Think of Zabbix as your networkโs guardian angel - constantly watching, alerting you to problems before they become disasters, and providing beautiful dashboards that tell the story of your infrastructure! ๐๏ธโ๐จ๏ธ
๐ค Why Use Zabbix for Network Monitoring?
Zabbix provides unmatched monitoring capabilities for enterprise environments! ๐
Essential Benefits:
- ๐ Comprehensive Metrics - Monitor everything from CPU to custom applications
- โก Real-time Alerting - Instant notifications when issues arise
- ๐ Beautiful Dashboards - Visualize your infrastructure with stunning graphs
- ๐ง Auto-discovery - Automatically find and monitor new devices
- ๐ฑ Multi-platform Support - Monitor Linux, Windows, network devices, and more
- ๐ Distributed Monitoring - Scale across multiple locations and networks
- ๐ Extensible - Custom scripts, templates, and integrations
- ๐พ Historical Data - Long-term trending and capacity planning
- ๐จ Intelligent Alerting - Reduce false positives with smart correlations
- ๐ Enterprise Security - Role-based access and encrypted communications
๐ฏ What You Need Before Starting
Letโs ensure youโre ready for this comprehensive monitoring setup! โ
System Requirements:
- โ AlmaLinux 8 or 9 (fresh installation recommended)
- โ Minimum 4GB RAM (8GB+ for large environments)
- โ 50GB+ disk space for database and logs
- โ Static IP address for monitoring server
- โ Network access to devices you want to monitor
- โ Root/sudo access for installation
- โ Basic understanding of networking concepts
Infrastructure Prerequisites:
- โ Database server (MySQL/PostgreSQL) or will install locally
- โ Web server for Zabbix frontend
- โ SNMP access to network devices (switches, routers)
- โ SSH access to Linux servers for monitoring
- โ Firewall rules configured for monitoring traffic
What Weโll Monitor:
- โ Server performance (CPU, memory, disk, network)
- โ Network devices (switches, routers, firewalls)
- โ Services and applications
- โ Website availability and performance
- โ Database performance and availability
- โ Custom metrics and business KPIs
๐ Step 1: System Preparation and Database Setup
Letโs prepare our AlmaLinux system for Zabbix installation with proper database configuration!
# Update system packages
sudo dnf update -y
# Install essential packages and repositories
sudo dnf install -y \
wget \
curl \
vim \
net-tools \
epel-release \
dnf-utils
# Install Zabbix repository
sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
sudo dnf clean all
Install and Configure MySQL Database:
# Install MySQL server
sudo dnf install -y mysql-server
# Start and enable MySQL
sudo systemctl enable mysqld
sudo systemctl start mysqld
# Secure MySQL installation
sudo mysql_secure_installation
# Connect to MySQL and create Zabbix database
sudo mysql -u root -p << 'EOF'
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_password_here';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
FLUSH PRIVILEGES;
EXIT;
EOF
Optimize MySQL for Zabbix:
# Create optimized MySQL configuration for Zabbix
sudo tee /etc/mysql/mysql.conf.d/zabbix.cnf << 'EOF'
[mysqld]
# Zabbix optimizations
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 2
# Character set
character-set-server = utf8mb4
collation-server = utf8mb4_bin
# Performance
max_connections = 200
query_cache_type = 1
query_cache_size = 256M
tmp_table_size = 256M
max_heap_table_size = 256M
# Timeouts
wait_timeout = 28800
interactive_timeout = 28800
# Logging
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
EOF
# Restart MySQL to apply changes
sudo systemctl restart mysqld
๐ง Step 2: Install Zabbix Server and Frontend
Letโs install the complete Zabbix monitoring stack!
# Install Zabbix server, frontend, and agent
sudo dnf install -y \
zabbix-server-mysql \
zabbix-web-mysql \
zabbix-apache-conf \
zabbix-sql-scripts \
zabbix-selinux-policy \
zabbix-agent2
# Import initial schema and data
sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
# Reset the log_bin_trust_function_creators option
mysql -u root -p -e "SET GLOBAL log_bin_trust_function_creators = 0;"
Configure Zabbix Server:
# Edit Zabbix server configuration
sudo tee /etc/zabbix/zabbix_server.conf << 'EOF'
# Zabbix Server Configuration
# Database settings
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix_password_here
DBPort=3306
# Server settings
ListenPort=10051
SourceIP=
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=100
LogSlowQueries=3000
PidFile=/var/run/zabbix/zabbix_server.pid
# Performance tuning
StartPollers=30
StartIPMIPollers=10
StartPollersUnreachable=5
StartTrappers=15
StartPingers=5
StartDiscoverers=5
StartHTTPPollers=5
StartTimers=2
StartEscalators=2
StartAlerters=5
# Cache settings
CacheSize=128M
HistoryCacheSize=64M
HistoryIndexCacheSize=32M
TrendCacheSize=32M
ValueCacheSize=128M
# Timeout settings
Timeout=30
TrapperTimeout=300
UnreachablePeriod=45
UnavailableDelay=60
UnreachableDelay=15
# Housekeeping
HousekeepingFrequency=1
MaxHousekeeperDelete=5000
# Network settings
StartDBSyncers=4
DBTLSConnect=
DBTLSCAFile=
DBTLSCertFile=
DBTLSKeyFile=
DBTLSCipher=
DBTLSCipher13=
# SNMP settings
SNMPTrapperFile=/var/log/snmptrapd/snmptrapd.log
StartSNMPTrapper=1
# Load modules
LoadModulePath=/usr/lib64/zabbix/modules
LoadModule=
# TLS settings
TLSCAFile=
TLSCRLFile=
TLSCertFile=
TLSKeyFile=
EOF
# Set proper permissions
sudo chown zabbix:zabbix /etc/zabbix/zabbix_server.conf
sudo chmod 600 /etc/zabbix/zabbix_server.conf
Configure Zabbix Frontend:
# Configure PHP for Zabbix
sudo tee /etc/php.d/99-zabbix.ini << 'EOF'
; Zabbix PHP configuration
max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
max_input_time = 300
max_input_vars = 10000
date.timezone = "UTC"
; Session settings
session.auto_start = off
session.use_strict_mode = on
session.use_cookies = on
session.use_only_cookies = on
session.cookie_httponly = on
session.cookie_secure = on
session.gc_maxlifetime = 1440
EOF
# Configure Apache for Zabbix
sudo tee /etc/httpd/conf.d/zabbix.conf << 'EOF'
# Zabbix Apache Configuration
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php.c>
php_value max_execution_time 300
php_value memory_limit 256M
php_value post_max_size 32M
php_value upload_max_filesize 16M
php_value max_input_time 300
php_value max_input_vars 10000
php_value date.timezone "UTC"
php_value always_populate_raw_post_data -1
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
EOF
# Enable and start services
sudo systemctl enable httpd php-fpm
sudo systemctl start httpd php-fpm
๐ Step 3: Start Services and Complete Web Setup
Letโs start all Zabbix services and complete the web-based configuration!
# Start and enable Zabbix services
sudo systemctl enable zabbix-server zabbix-agent2
sudo systemctl start zabbix-server zabbix-agent2
# Check service status
sudo systemctl status zabbix-server
sudo systemctl status zabbix-agent2
# Check Zabbix server logs
sudo tail -f /var/log/zabbix/zabbix_server.log
Configure Firewall:
# Open firewall ports for Zabbix
sudo firewall-cmd --permanent --add-port=10050/tcp # Zabbix agent
sudo firewall-cmd --permanent --add-port=10051/tcp # Zabbix server
sudo firewall-cmd --permanent --add-service=http # Web interface
sudo firewall-cmd --permanent --add-service=https # SSL web interface
sudo firewall-cmd --reload
# Verify open ports
sudo firewall-cmd --list-all
Complete Web Setup:
echo "๐ Zabbix web interface is now available at:"
echo " http://$(hostname -I | awk '{print $1}')/zabbix"
echo ""
echo "๐ Web setup configuration:"
echo " Database type: MySQL"
echo " Database host: localhost"
echo " Database port: 3306"
echo " Database name: zabbix"
echo " Database user: zabbix"
echo " Database password: zabbix_password_here"
echo ""
echo "๐ Default login credentials:"
echo " Username: Admin"
echo " Password: zabbix"
echo ""
echo "โ ๏ธ Remember to change the default password after login!"
โ Step 4: Configure Zabbix Agent and Monitoring
Letโs configure the Zabbix agent and set up basic monitoring!
Configure Zabbix Agent:
# Configure Zabbix agent
sudo tee /etc/zabbix/zabbix_agent2.conf << 'EOF'
# Zabbix Agent Configuration
# Server settings
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=zabbix-server
# Agent settings
ListenPort=10050
ListenIP=0.0.0.0
SourceIP=
# Logging
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=100
DebugLevel=3
# Performance
BufferSend=5
BufferSize=100
MaxLinesPerSecond=20
# Timeout settings
Timeout=30
# Security
AllowRoot=0
User=zabbix
# Include additional configuration files
Include=/etc/zabbix/zabbix_agent2.d/*.conf
# Plugins
Plugins.Log.MaxLinesPerSecond=20
Plugins.SystemRun=1
# User parameters
UserParameter=custom.cpu.util,cat /proc/loadavg | awk '{print $1}'
UserParameter=custom.memory.util,free -m | awk 'NR==2{printf "%.1f", $3*100/$2 }'
UserParameter=custom.disk.util[*],df -h $1 | awk 'NR==2 {print $5}' | sed 's/%//'
EOF
# Restart agent to apply changes
sudo systemctl restart zabbix-agent2
sudo systemctl status zabbix-agent2
Create Custom Monitoring Scripts:
# Create custom monitoring scripts directory
sudo mkdir -p /usr/local/bin/zabbix-scripts
# Create system monitoring script
sudo tee /usr/local/bin/zabbix-scripts/system-monitor.sh << 'EOF'
#!/bin/bash
# Custom System Monitoring Script
case "$1" in
"cpu_temp")
# Get CPU temperature (if available)
if [ -f /sys/class/thermal/thermal_zone0/temp ]; then
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo "scale=1; $temp/1000" | bc
else
echo "0"
fi
;;
"disk_iops")
# Get disk I/O operations per second
iostat -x 1 2 | tail -1 | awk '{print $4+$5}'
;;
"network_errors")
# Get network error count
cat /proc/net/dev | grep -E "(eth0|ens|enp)" | awk -F: '{print $2}' | awk '{print $3+$7}'
;;
"process_count")
# Get running process count
ps aux | wc -l
;;
"zombie_processes")
# Get zombie process count
ps aux | awk '$8 ~ /^Z/ { count++ } END { print count+0 }'
;;
"memory_swap_used")
# Get swap usage percentage
free | awk '/^Swap:/ { if($2 > 0) print ($3/$2)*100; else print 0 }'
;;
*)
echo "Usage: $0 {cpu_temp|disk_iops|network_errors|process_count|zombie_processes|memory_swap_used}"
exit 1
;;
esac
EOF
sudo chmod +x /usr/local/bin/zabbix-scripts/system-monitor.sh
# Add custom parameters to agent
sudo tee /etc/zabbix/zabbix_agent2.d/custom-params.conf << 'EOF'
# Custom monitoring parameters
UserParameter=custom.system[*],/usr/local/bin/zabbix-scripts/system-monitor.sh $1
UserParameter=custom.service.status[*],systemctl is-active $1 | grep -c "active"
UserParameter=custom.port.check[*],netstat -tuln | grep -c ":$1 "
UserParameter=custom.file.size[*],stat -c%s $1 2>/dev/null || echo 0
UserParameter=custom.file.age[*],echo $(($(date +%s) - $(stat -c%Y $1 2>/dev/null || echo $(date +%s))))
UserParameter=custom.log.error[*],grep -c "ERROR" $1 2>/dev/null || echo 0
EOF
sudo systemctl restart zabbix-agent2
๐ก๏ธ Step 5: Advanced Monitoring Configuration
Letโs set up advanced monitoring for different types of infrastructure!
SNMP Monitoring Setup:
# Install SNMP tools
sudo dnf install -y net-snmp net-snmp-utils
# Configure SNMP for monitoring network devices
sudo tee /etc/snmp/snmpd.conf << 'EOF'
# SNMP Configuration for Zabbix
# Community strings (change these!)
rocommunity public localhost
rocommunity zabbix-monitor 192.168.1.0/24
# System information
syslocation "Server Room"
syscontact "[email protected]"
sysname "Zabbix SNMP Server"
# Security
agentSecName internal
rouser internal
createUser internal MD5 "authpassword" DES "encryptionpassword"
# MIBs
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
access MyROGroup "" any noauth exact systemonly none none
# Process monitoring
proc sshd
proc httpd
proc mysqld
proc zabbix_server
proc zabbix_agentd
# Disk monitoring
disk / 10000
# Load monitoring
load 12 10 5
EOF
sudo systemctl enable snmpd
sudo systemctl start snmpd
# Test SNMP
snmpwalk -v2c -c public localhost system
Database Monitoring Setup:
# Create MySQL monitoring user
mysql -u root -p << 'EOF'
CREATE USER 'zabbix_monitor'@'localhost' IDENTIFIED BY 'monitor_password';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'zabbix_monitor'@'localhost';
FLUSH PRIVILEGES;
EXIT;
EOF
# Create database monitoring script
sudo tee /usr/local/bin/zabbix-scripts/mysql-monitor.sh << 'EOF'
#!/bin/bash
# MySQL Monitoring Script
MYSQL_USER="zabbix_monitor"
MYSQL_PASS="monitor_password"
case "$1" in
"connections")
mysql -u$MYSQL_USER -p$MYSQL_PASS -e "SHOW STATUS LIKE 'Threads_connected';" | tail -1 | awk '{print $2}'
;;
"queries_per_second")
mysql -u$MYSQL_USER -p$MYSQL_PASS -e "SHOW STATUS LIKE 'Queries';" | tail -1 | awk '{print $2}'
;;
"slow_queries")
mysql -u$MYSQL_USER -p$MYSQL_PASS -e "SHOW STATUS LIKE 'Slow_queries';" | tail -1 | awk '{print $2}'
;;
"innodb_buffer_pool_hit_ratio")
mysql -u$MYSQL_USER -p$MYSQL_PASS -e "
SELECT ROUND((1 - (Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests)) * 100, 2) as hit_ratio
FROM (
SELECT variable_value as Innodb_buffer_pool_reads FROM information_schema.global_status WHERE variable_name = 'Innodb_buffer_pool_reads'
) t1,
(
SELECT variable_value as Innodb_buffer_pool_read_requests FROM information_schema.global_status WHERE variable_name = 'Innodb_buffer_pool_read_requests'
) t2;" | tail -1
;;
*)
echo "Usage: $0 {connections|queries_per_second|slow_queries|innodb_buffer_pool_hit_ratio}"
;;
esac
EOF
sudo chmod +x /usr/local/bin/zabbix-scripts/mysql-monitor.sh
# Add MySQL monitoring parameters
echo "UserParameter=mysql.monitor[*],/usr/local/bin/zabbix-scripts/mysql-monitor.sh \$1" | sudo tee -a /etc/zabbix/zabbix_agent2.d/custom-params.conf
Web Service Monitoring:
# Create web service monitoring script
sudo tee /usr/local/bin/zabbix-scripts/web-monitor.sh << 'EOF'
#!/bin/bash
# Web Service Monitoring Script
URL="$1"
TIMEOUT="${2:-10}"
case "$3" in
"response_time")
curl -o /dev/null -s -w "%{time_total}" --max-time $TIMEOUT "$URL" 2>/dev/null || echo "0"
;;
"http_code")
curl -o /dev/null -s -w "%{http_code}" --max-time $TIMEOUT "$URL" 2>/dev/null || echo "0"
;;
"response_size")
curl -o /dev/null -s -w "%{size_download}" --max-time $TIMEOUT "$URL" 2>/dev/null || echo "0"
;;
"ssl_cert_days")
echo | openssl s_client -servername "$URL" -connect "$URL:443" 2>/dev/null | \
openssl x509 -noout -dates | grep notAfter | cut -d= -f2 | \
xargs -I {} date -d "{}" +%s | \
awk -v now=$(date +%s) '{print int(($1-now)/86400)}'
;;
*)
echo "Usage: $0 <URL> <timeout> {response_time|http_code|response_size|ssl_cert_days}"
;;
esac
EOF
sudo chmod +x /usr/local/bin/zabbix-scripts/web-monitor.sh
# Add web monitoring parameters
echo "UserParameter=web.monitor[*],/usr/local/bin/zabbix-scripts/web-monitor.sh \$1 \$2 \$3" | sudo tee -a /etc/zabbix/zabbix_agent2.d/custom-params.conf
sudo systemctl restart zabbix-agent2
๐ฎ Quick Examples - Monitoring Templates and Dashboards
Letโs create practical monitoring examples! ๐
Example 1: Complete Server Monitoring Template
# Create server monitoring template export
cat > server-monitoring-template.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>6.4</version>
<date>2025-09-18T00:00:00Z</date>
<groups>
<group>
<uuid>7df96b18c230490a9a0a9e2307295160</uuid>
<name>Templates/Operating systems</name>
</group>
</groups>
<templates>
<template>
<uuid>10001000100010001000100010001000</uuid>
<template>AlmaLinux Server Advanced</template>
<name>AlmaLinux Server Advanced Monitoring</name>
<description>Advanced monitoring template for AlmaLinux servers</description>
<groups>
<group>
<name>Templates/Operating systems</name>
</group>
</groups>
<items>
<item>
<uuid>20002000200020002000200020002000</uuid>
<name>CPU Temperature</name>
<type>ZABBIX_ACTIVE</type>
<key>custom.system[cpu_temp]</key>
<delay>60s</delay>
<value_type>FLOAT</value_type>
<units>ยฐC</units>
<description>Current CPU temperature</description>
</item>
<item>
<uuid>20002000200020002000200020002001</uuid>
<name>Disk IOPS</name>
<type>ZABBIX_ACTIVE</type>
<key>custom.system[disk_iops]</key>
<delay>60s</delay>
<value_type>FLOAT</value_type>
<units>ops</units>
<description>Disk I/O operations per second</description>
</item>
<item>
<uuid>20002000200020002000200020002002</uuid>
<name>Zombie Processes</name>
<type>ZABBIX_ACTIVE</type>
<key>custom.system[zombie_processes]</key>
<delay>300s</delay>
<value_type>UNSIGNED</value_type>
<description>Number of zombie processes</description>
</item>
</items>
<triggers>
<trigger>
<uuid>30003000300030003000300030003000</uuid>
<expression>last(/AlmaLinux Server Advanced/custom.system[cpu_temp])>80</expression>
<name>High CPU temperature on {HOST.NAME}</name>
<priority>WARNING</priority>
<description>CPU temperature is above 80ยฐC</description>
</trigger>
<trigger>
<uuid>30003000300030003000300030003001</uuid>
<expression>last(/AlmaLinux Server Advanced/custom.system[zombie_processes])>5</expression>
<name>High number of zombie processes on {HOST.NAME}</name>
<priority>WARNING</priority>
<description>Too many zombie processes detected</description>
</trigger>
</triggers>
</template>
</templates>
</zabbix_export>
EOF
echo "๐ Server monitoring template created: server-monitoring-template.xml"
echo " Import this template in Zabbix web interface:"
echo " Configuration โ Templates โ Import"
Example 2: Automated Discovery Rules
# Create network discovery script
sudo tee /usr/local/bin/zabbix-scripts/network-discovery.py << 'EOF'
#!/usr/bin/env python3
"""
Network Discovery Script for Zabbix
Discovers network devices using SNMP
"""
import json
import subprocess
import ipaddress
import sys
def discover_network_devices(network_range="192.168.1.0/24", community="public"):
"""Discover SNMP-enabled devices on the network"""
devices = []
try:
network = ipaddress.IPv4Network(network_range, strict=False)
for ip in network.hosts():
ip_str = str(ip)
# Try SNMP walk to detect device
try:
cmd = ["snmpwalk", "-v2c", "-c", community, "-t", "2", "-r", "1",
ip_str, "1.3.6.1.2.1.1.1.0"]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=5)
if result.returncode == 0 and result.stdout:
# Get system description
sysDescr = result.stdout.strip().split('=')[1].strip() if '=' in result.stdout else "Unknown Device"
# Get hostname via SNMP
cmd_name = ["snmpwalk", "-v2c", "-c", community, "-t", "2", "-r", "1",
ip_str, "1.3.6.1.2.1.1.5.0"]
name_result = subprocess.run(cmd_name, capture_output=True, text=True, timeout=5)
hostname = ip_str
if name_result.returncode == 0 and name_result.stdout:
hostname = name_result.stdout.strip().split('=')[1].strip().strip('"') if '=' in name_result.stdout else ip_str
devices.append({
"{#SNMP_DEVICE_IP}": ip_str,
"{#SNMP_DEVICE_NAME}": hostname,
"{#SNMP_DEVICE_DESC}": sysDescr,
"{#SNMP_COMMUNITY}": community
})
except (subprocess.TimeoutExpired, subprocess.CalledProcessError):
continue
except Exception as e:
print(f"Error during discovery: {e}", file=sys.stderr)
return {"data": devices}
if __name__ == "__main__":
# Get network range from command line or use default
network_range = sys.argv[1] if len(sys.argv) > 1 else "192.168.1.0/24"
community = sys.argv[2] if len(sys.argv) > 2 else "public"
result = discover_network_devices(network_range, community)
print(json.dumps(result, indent=2))
EOF
sudo chmod +x /usr/local/bin/zabbix-scripts/network-discovery.py
# Add discovery parameter
echo "UserParameter=network.discovery[*],/usr/local/bin/zabbix-scripts/network-discovery.py \$1 \$2" | sudo tee -a /etc/zabbix/zabbix_agent2.d/custom-params.conf
sudo systemctl restart zabbix-agent2
# Test discovery
/usr/local/bin/zabbix-scripts/network-discovery.py "192.168.1.0/24" "public"
Example 3: Performance Dashboard Creation
# Create dashboard export script
cat > create-performance-dashboard.sh << 'EOF'
#!/bin/bash
# Performance Dashboard Creation Script
echo "๐ Creating Zabbix Performance Dashboard..."
# Dashboard configuration (JSON format for import)
cat > performance-dashboard.json << 'DASHBOARD_EOF'
{
"dashboard": {
"uuid": "40004000400040004000400040004000",
"name": "AlmaLinux Performance Dashboard",
"display_period": 30,
"auto_start": 1,
"pages": [
{
"name": "System Overview",
"widgets": [
{
"type": "graph",
"name": "CPU Utilization",
"x": 0,
"y": 0,
"width": 12,
"height": 5,
"fields": [
{
"type": "INTEGER",
"name": "source_type",
"value": 0
},
{
"type": "GRAPH",
"name": "graphid",
"value": {
"name": "CPU utilization",
"host": "Zabbix server"
}
}
]
},
{
"type": "graph",
"name": "Memory Usage",
"x": 12,
"y": 0,
"width": 12,
"height": 5,
"fields": [
{
"type": "INTEGER",
"name": "source_type",
"value": 0
},
{
"type": "GRAPH",
"name": "graphid",
"value": {
"name": "Memory usage",
"host": "Zabbix server"
}
}
]
},
{
"type": "graph",
"name": "Network Traffic",
"x": 0,
"y": 5,
"width": 12,
"height": 5,
"fields": [
{
"type": "INTEGER",
"name": "source_type",
"value": 0
},
{
"type": "GRAPH",
"name": "graphid",
"value": {
"name": "Network traffic",
"host": "Zabbix server"
}
}
]
},
{
"type": "graph",
"name": "Disk I/O",
"x": 12,
"y": 5,
"width": 12,
"height": 5,
"fields": [
{
"type": "INTEGER",
"name": "source_type",
"value": 0
},
{
"type": "GRAPH",
"name": "graphid",
"value": {
"name": "Disk I/O",
"host": "Zabbix server"
}
}
]
}
]
}
]
}
}
DASHBOARD_EOF
echo "โ
Performance dashboard configuration created!"
echo "๐ File: performance-dashboard.json"
echo ""
echo "๐ To import this dashboard:"
echo "1. Go to Monitoring โ Dashboards in Zabbix web interface"
echo "2. Click 'Import' button"
echo "3. Upload the performance-dashboard.json file"
echo "4. Configure host mappings as needed"
EOF
chmod +x create-performance-dashboard.sh
./create-performance-dashboard.sh
๐จ Fix Common Zabbix Problems
Even monitoring experts face challenges! Here are solutions to common issues: ๐ช
Problem 1: Zabbix Server Wonโt Start
# Symptoms: Zabbix server fails to start or crashes
# Solution: Check database connection and configuration
# Check Zabbix server logs
sudo tail -f /var/log/zabbix/zabbix_server.log
# Test database connection
mysql -u zabbix -p zabbix -e "SELECT COUNT(*) FROM hosts;"
# Check configuration syntax
sudo zabbix_server -c /etc/zabbix/zabbix_server.conf -t
# Verify file permissions
sudo chown -R zabbix:zabbix /var/log/zabbix
sudo chown -R zabbix:zabbix /var/run/zabbix
# Check system resources
free -h
df -h
# Restart with debugging
sudo systemctl stop zabbix-server
sudo -u zabbix zabbix_server -c /etc/zabbix/zabbix_server.conf -f
Problem 2: Agent Connection Issues
# Symptoms: Hosts showing as unavailable or unreachable
# Solution: Debug network connectivity and agent configuration
# Test agent connectivity from server
zabbix_get -s AGENT_IP -k agent.ping
# Check agent logs
sudo tail -f /var/log/zabbix/zabbix_agent2.log
# Test network connectivity
telnet AGENT_IP 10050
# Check firewall rules
sudo firewall-cmd --list-all
sudo iptables -L -n | grep 10050
# Verify agent configuration
sudo zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t
# Test specific items
zabbix_get -s AGENT_IP -k system.cpu.load[all,avg1]
zabbix_get -s AGENT_IP -k vm.memory.size[available]
Problem 3: Web Interface Performance Issues
# Symptoms: Slow web interface, timeouts, blank pages
# Solution: Optimize PHP and database configuration
# Check PHP error logs
sudo tail -f /var/log/httpd/error_log
# Optimize PHP settings
sudo tee -a /etc/php.d/99-zabbix.ini << 'EOF'
max_execution_time = 600
memory_limit = 512M
max_input_time = 600
opcache.enable = 1
opcache.memory_consumption = 256
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
EOF
# Optimize MySQL for Zabbix
sudo tee -a /etc/my.cnf << 'EOF'
[mysqld]
tmp_table_size = 512M
max_heap_table_size = 512M
join_buffer_size = 4M
sort_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
innodb_buffer_pool_size = 2G
EOF
# Clear PHP opcache
sudo systemctl restart php-fpm httpd
# Check database performance
mysql -u root -p -e "SHOW PROCESSLIST;"
mysql -u root -p -e "SHOW ENGINE INNODB STATUS\G" | grep -A 20 "LATEST DETECTED DEADLOCK"
Problem 4: High Database Growth
# Symptoms: Database size growing too quickly
# Solution: Configure proper housekeeping and data retention
# Check database size
mysql -u root -p -e "
SELECT
table_schema AS 'Database',
ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS 'Size (GB)'
FROM information_schema.tables
WHERE table_schema = 'zabbix'
GROUP BY table_schema;"
# Check large tables
mysql -u root -p -e "
SELECT
table_name AS 'Table',
ROUND(((data_length + index_length) / 1024 / 1024 / 1024), 2) AS 'Size (GB)'
FROM information_schema.TABLES
WHERE table_schema = 'zabbix'
ORDER BY (data_length + index_length) DESC
LIMIT 10;"
# Configure housekeeping
sudo sed -i 's/# HousekeepingFrequency=1/HousekeepingFrequency=1/' /etc/zabbix/zabbix_server.conf
sudo sed -i 's/# MaxHousekeeperDelete=5000/MaxHousekeeperDelete=10000/' /etc/zabbix/zabbix_server.conf
# Manual cleanup (be careful!)
mysql -u root -p zabbix << 'EOF'
-- Delete old history (older than 30 days)
DELETE FROM history WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY));
DELETE FROM history_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY));
-- Delete old trends (older than 1 year)
DELETE FROM trends WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 YEAR));
DELETE FROM trends_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 YEAR));
-- Optimize tables
OPTIMIZE TABLE history;
OPTIMIZE TABLE history_uint;
OPTIMIZE TABLE trends;
OPTIMIZE TABLE trends_uint;
EOF
sudo systemctl restart zabbix-server
Problem 5: Missing Data or Gaps in Graphs
# Symptoms: Graphs showing gaps or no data collection
# Solution: Debug data collection and item configuration
# Check item status in database
mysql -u zabbix -p zabbix -e "
SELECT h.host, i.name, i.key_, i.status, i.error
FROM items i
JOIN hosts h ON i.hostid = h.hostid
WHERE i.status = 1 OR i.error != ''
ORDER BY h.host, i.name;"
# Test item collection manually
zabbix_get -s HOST_IP -k ITEM_KEY
# Check poller processes
grep -i "poller" /var/log/zabbix/zabbix_server.log | tail -20
# Increase poller processes if needed
sudo sed -i 's/StartPollers=5/StartPollers=20/' /etc/zabbix/zabbix_server.conf
# Check host availability
mysql -u zabbix -p zabbix -e "
SELECT host, available, error
FROM hosts
WHERE status = 0
ORDER BY host;"
# Force item update
mysql -u zabbix -p zabbix -e "
UPDATE items SET nextcheck = 0 WHERE hostid = HOST_ID AND key_ = 'ITEM_KEY';"
sudo systemctl restart zabbix-server
๐ Zabbix Commands Summary
Hereโs your quick reference for Zabbix operations! โก
Task | Command | Description |
---|---|---|
Server Status | sudo systemctl status zabbix-server | Check Zabbix server status |
Agent Status | sudo systemctl status zabbix-agent2 | Check agent status |
Server Logs | sudo tail -f /var/log/zabbix/zabbix_server.log | View server logs |
Agent Logs | sudo tail -f /var/log/zabbix/zabbix_agent2.log | View agent logs |
Test Item | zabbix_get -s HOST -k ITEM_KEY | Test item collection |
Config Test | zabbix_server -c /etc/zabbix/zabbix_server.conf -t | Test configuration |
Agent Test | zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf -t | Test agent config |
DB Connection | mysql -u zabbix -p zabbix | Access Zabbix database |
Cache Stats | zabbix_server -c /etc/zabbix/zabbix_server.conf -R | Runtime control |
Restart Services | sudo systemctl restart zabbix-server | Restart Zabbix server |
๐ก Pro Tips for Monitoring Excellence
Want to become a Zabbix monitoring ninja? Here are expert secrets! ๐ฅท
Tip 1: Advanced Alerting with Webhooks
# Create Slack webhook integration
sudo tee /usr/lib/zabbix/alertscripts/slack-webhook.sh << 'EOF'
#!/bin/bash
# Slack Webhook Integration for Zabbix
WEBHOOK_URL="YOUR_SLACK_WEBHOOK_URL"
SUBJECT="$1"
MESSAGE="$2"
SEVERITY="$3"
# Choose emoji based on severity
case "$SEVERITY" in
"0") EMOJI=":information_source:" ;; # Not classified
"1") EMOJI=":information_source:" ;; # Information
"2") EMOJI=":warning:" ;; # Warning
"3") EMOJI=":warning:" ;; # Average
"4") EMOJI=":exclamation:" ;; # High
"5") EMOJI=":rotating_light:" ;; # Disaster
*) EMOJI=":question:" ;;
esac
# Send message to Slack
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"$EMOJI *$SUBJECT*\n$MESSAGE\"}" \
"$WEBHOOK_URL"
EOF
sudo chmod +x /usr/lib/zabbix/alertscripts/slack-webhook.sh
sudo chown zabbix:zabbix /usr/lib/zabbix/alertscripts/slack-webhook.sh
Tip 2: Custom API Monitoring
# Create API endpoint monitoring
sudo tee /usr/local/bin/zabbix-scripts/api-monitor.py << 'EOF'
#!/usr/bin/env python3
"""
Advanced API Monitoring Script
Monitors REST API endpoints with detailed metrics
"""
import requests
import json
import time
import sys
from urllib.parse import urlparse
def monitor_api(url, timeout=10, expected_status=200):
"""Monitor API endpoint and return detailed metrics"""
metrics = {
'status': 0,
'response_time': 0,
'response_size': 0,
'status_code': 0,
'ssl_days': 0
}
try:
start_time = time.time()
response = requests.get(url, timeout=timeout, verify=True)
end_time = time.time()
metrics['response_time'] = round((end_time - start_time) * 1000, 2) # ms
metrics['status_code'] = response.status_code
metrics['response_size'] = len(response.content)
metrics['status'] = 1 if response.status_code == expected_status else 0
# Check SSL certificate expiry for HTTPS URLs
if url.startswith('https://'):
try:
import ssl
import socket
from datetime import datetime
hostname = urlparse(url).hostname
context = ssl.create_default_context()
with socket.create_connection((hostname, 443), timeout=timeout) as sock:
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
cert = ssock.getpeercert()
expire_date = datetime.strptime(cert['notAfter'], '%b %d %H:%M:%S %Y %Z')
days_left = (expire_date - datetime.now()).days
metrics['ssl_days'] = days_left
except Exception as ssl_error:
print(f"SSL check error: {ssl_error}", file=sys.stderr)
except requests.exceptions.RequestException as e:
print(f"Request error: {e}", file=sys.stderr)
metrics['status'] = 0
except Exception as e:
print(f"General error: {e}", file=sys.stderr)
metrics['status'] = 0
return metrics
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: api-monitor.py <URL> <metric>")
print("Metrics: status, response_time, response_size, status_code, ssl_days")
sys.exit(1)
url = sys.argv[1]
metric = sys.argv[2]
timeout = int(sys.argv[3]) if len(sys.argv) > 3 else 10
metrics = monitor_api(url, timeout)
if metric in metrics:
print(metrics[metric])
else:
print("0")
EOF
sudo chmod +x /usr/local/bin/zabbix-scripts/api-monitor.py
# Add API monitoring parameters
echo "UserParameter=api.monitor[*],/usr/local/bin/zabbix-scripts/api-monitor.py \$1 \$2 \$3" | sudo tee -a /etc/zabbix/zabbix_agent2.d/custom-params.conf
๐ What Youโve Accomplished - Monitoring Mastery!
Congratulations! Youโve built a comprehensive monitoring system with Zabbix on AlmaLinux! ๐ Letโs celebrate your monitoring achievements:
๐ Complete Monitoring Infrastructure:
- โ Enterprise-grade Zabbix server with optimized database
- โ Advanced agent configuration with custom monitoring scripts
- โ SNMP monitoring for network devices and infrastructure
- โ Database performance monitoring with custom metrics
- โ Web service monitoring with SSL certificate tracking
- โ Automated network discovery and device detection
- โ Custom templates for comprehensive server monitoring
- โ Performance dashboards with real-time visualization
๐ช Professional Monitoring Skills Gained:
- โ Enterprise monitoring platform deployment and configuration
- โ Custom metric development and script creation
- โ SNMP monitoring and network device management
- โ Database performance monitoring and optimization
- โ Alert configuration and notification automation
- โ Dashboard creation and data visualization
- โ Troubleshooting and performance tuning
- โ Monitoring best practices and industry standards
๐ฏ Production-Ready Features:
- โ Scalable architecture supporting thousands of devices
- โ Intelligent alerting with customizable thresholds
- โ Historical data retention and trending analysis
- โ Role-based access control and security features
- โ API integration for automation and custom applications
- โ High availability and disaster recovery capabilities
๐ฏ Why This Monitoring Setup Matters
Your AlmaLinux Zabbix monitoring system is now an enterprise-grade observability platform! ๐
Real-World Impact:
- ๐๏ธ Complete Visibility - Monitor every aspect of your infrastructure
- โก Proactive Problem Detection - Fix issues before they impact users
- ๐ฐ Cost Optimization - Identify resource waste and optimize usage
- ๐ Capacity Planning - Make data-driven infrastructure decisions
- ๐ก๏ธ Enhanced Security - Detect anomalies and security threats
- ๐ Performance Optimization - Identify and resolve bottlenecks
- ๐ Automated Response - React to issues without human intervention
- ๐ Compliance Reporting - Meet regulatory and audit requirements
- ๐ฅ Team Collaboration - Shared visibility across operations teams
- ๐ Business Intelligence - Transform monitoring data into business insights
Youโre not just monitoring systems - youโre building intelligence into your infrastructure! Whether youโre managing a small business network or enterprise data centers, your Zabbix platform provides the insight needed to maintain peak performance and reliability! ๐
Your infrastructure is now under constant watchful protection! โญ Happy monitoring! ๐