Monitoring Guide

    Self-Hosted Zabbix

    Deploy Zabbix, the enterprise-class open source monitoring solution, on RamNode VPS. Monitor servers, networks, applications, and cloud services.

    Ubuntu 22.04/24.04
    Zabbix 7.0 LTS
    ⏱️ 30-45 minutes

    Why Zabbix?

    Zabbix is a powerful open-source monitoring solution capable of tracking servers, networks, applications, and cloud services. It provides real-time monitoring, alerting, and visualization for your entire infrastructure.

    Monitor servers, networks, applications, cloud
    Flexible alerting with escalation policies
    Beautiful dashboards and visualizations
    Auto-discovery and template-based monitoring

    Prerequisites

    Small/Lab

    • • 1 vCPU
    • • 2 GB RAM
    • • 20 GB SSD
    • • Up to 50 hosts

    Medium

    • • 2 vCPUs
    • • 4 GB RAM
    • • 50 GB SSD
    • • 50-500 hosts

    Large

    • • 4+ vCPUs
    • • 8+ GB RAM
    • • 100+ GB SSD
    • • 500+ hosts
    1

    Update Your System

    Start by updating system packages and setting timezone:

    System Setup
    # Update system packages
    sudo apt update && sudo apt upgrade -y
    
    # Set timezone for accurate monitoring timestamps
    sudo timedatectl set-timezone America/New_York

    Install Dependencies

    1

    Install Required Packages

    Zabbix requires a web server, database, and PHP:

    Install Dependencies
    sudo apt install -y apache2 mysql-server php php-mysql php-gd php-xml \
        php-bcmath php-mbstring php-ldap php-curl libapache2-mod-php wget gnupg2

    Add Zabbix Repository

    1

    Install Zabbix Repository

    Download and install the official Zabbix repository:

    Ubuntu 24.04
    # For Ubuntu 24.04
    wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb
    sudo dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
    sudo apt update
    Ubuntu 22.04
    # For Ubuntu 22.04
    wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu22.04_all.deb
    sudo dpkg -i zabbix-release_latest_7.0+ubuntu22.04_all.deb
    sudo apt update

    Install Zabbix Components

    1

    Install Zabbix Server, Frontend, and Agent

    Install the complete Zabbix stack:

    Install Zabbix
    sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf \
        zabbix-sql-scripts zabbix-agent2

    Note: The zabbix-agent2 package is the newer Go-based agent with improved performance and plugin support.

    Configure MySQL Database

    1

    Secure MySQL Installation

    Run the security script:

    Secure MySQL
    sudo mysql_secure_installation
    
    # Follow the prompts:
    # - Set a root password
    # - Answer Y to all security questions
    2

    Create Zabbix Database

    Create the database and user:

    MySQL Commands
    # Log into MySQL
    sudo mysql -u root -p
    SQL Commands
    CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
    CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'YourSecurePassword';
    GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
    SET GLOBAL log_bin_trust_function_creators = 1;
    FLUSH PRIVILEGES;
    EXIT;
    3

    Import Database Schema

    Import the initial Zabbix schema (this may take a few minutes):

    Import Schema
    # Import schema and data
    sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
    
    # Enter the Zabbix database password when prompted
    
    # After importing, disable log_bin_trust_function_creators
    sudo mysql -u root -p -e "SET GLOBAL log_bin_trust_function_creators = 0;"

    Configuration

    1

    Configure Zabbix Server

    Edit the server configuration:

    Edit Configuration
    sudo nano /etc/zabbix/zabbix_server.conf
    zabbix_server.conf
    # Database password
    DBPassword=YourSecurePassword
    
    # Cache sizes (adjust based on your VPS RAM)
    CacheSize=128M
    HistoryCacheSize=64M
    TrendCacheSize=32M
    ValueCacheSize=64M
    
    # Increase pollers for more hosts
    StartPollers=10
    StartPollersUnreachable=5
    
    # Timeout settings
    Timeout=30
    2

    Configure PHP

    Set timezone and optimize PHP:

    Apache Config
    sudo nano /etc/zabbix/apache.conf
    
    # Uncomment and set your timezone:
    php_value date.timezone America/New_York
    PHP Settings
    sudo nano /etc/php/8.3/apache2/php.ini
    
    # Update these values:
    memory_limit = 256M
    upload_max_filesize = 16M
    post_max_size = 16M
    max_execution_time = 300
    max_input_time = 300
    3

    Configure Local Agent

    Configure the local Zabbix agent:

    Agent Configuration
    sudo nano /etc/zabbix/zabbix_agent2.conf
    zabbix_agent2.conf
    Server=127.0.0.1
    ServerActive=127.0.0.1
    Hostname=Zabbix server
    4

    Start Services

    Enable and start all services:

    Start Services
    # Restart and enable services
    sudo systemctl restart zabbix-server zabbix-agent2 apache2
    sudo systemctl enable zabbix-server zabbix-agent2 apache2
    
    # Verify services are running
    sudo systemctl status zabbix-server
    sudo systemctl status zabbix-agent2
    5

    Configure Firewall

    Open necessary ports:

    UFW Rules
    sudo ufw allow 80/tcp     # HTTP
    sudo ufw allow 443/tcp    # HTTPS
    sudo ufw allow 10050/tcp  # Zabbix Agent
    sudo ufw allow 10051/tcp  # Zabbix Server
    sudo ufw reload

    Complete Web Installation

    1

    Web Setup Wizard

    Open your browser and navigate to:

    Access URL
    http://your-server-ip/zabbix

    1. Welcome: Click "Next step"

    2. Prerequisites: Ensure all requirements show "OK"

    3. Database connection:

    • • Database type: MySQL
    • • Database host: localhost
    • • Database port: 0 (default)
    • • Database name: zabbix
    • • User: zabbix
    • • Password: YourSecurePassword

    4. Settings: Configure server name and timezone

    5. Summary: Review and click "Next step"

    6. Install: Click "Finish"

    2

    Default Login

    Log in with default credentials:

    Default Credentials
    Username: Admin
    Password: zabbix

    Important: Change the default password immediately after logging in via Administration → Users → Admin.

    SSL/TLS Setup

    1

    Enable SSL with Let's Encrypt

    Secure your installation with a free SSL certificate:

    Install Certbot
    # Install Certbot
    sudo apt install -y certbot python3-certbot-apache
    
    # Obtain and install certificate
    sudo certbot --apache -d your-domain.com
    
    # Follow the prompts to complete installation
    
    # Enable automatic renewal
    sudo systemctl enable certbot.timer

    Security Hardening

    1

    Restrict Web Access

    Limit access to Zabbix frontend by IP:

    Apache Config
    sudo nano /etc/apache2/conf-available/zabbix.conf
    IP Restrictions
    # Add within the <Directory> block:
    <RequireAny>
        Require ip 192.168.1.0/24
        Require ip YOUR_OFFICE_IP
    </RequireAny>
    2

    Enable Two-Factor Authentication

    Zabbix 7.0 supports TOTP-based 2FA:

    Navigate to: Administration → Authentication → MFA settings

    Enable TOTP and configure for administrator accounts.

    3

    Database Security

    Create a read-only user for reporting:

    Read-Only User
    CREATE USER 'zabbix_ro'@'localhost' IDENTIFIED BY 'ReadOnlyPassword';
    GRANT SELECT ON zabbix.* TO 'zabbix_ro'@'localhost';
    FLUSH PRIVILEGES;

    Performance Tuning

    1

    MySQL Optimization

    Create optimized MySQL configuration:

    Create Config
    sudo nano /etc/mysql/mysql.conf.d/zabbix.cnf
    zabbix.cnf
    [mysqld]
    innodb_buffer_pool_size = 512M
    innodb_log_file_size = 128M
    innodb_flush_log_at_trx_commit = 2
    innodb_flush_method = O_DIRECT
    Restart MySQL
    sudo systemctl restart mysql
    2

    Housekeeping Configuration

    Configure data retention in Administration → General → Housekeeping:

    History retention: 7-30 days (depending on needs)

    Trend retention: 365 days

    Event retention: 365 days

    Adding Remote Hosts

    1

    Install Agent on Remote Hosts

    Install the Zabbix agent on remote VPS instances:

    Install Remote Agent
    # On the remote host
    wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb
    sudo dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
    sudo apt update
    sudo apt install -y zabbix-agent2
    2

    Configure Remote Agent

    Point the agent to your Zabbix server:

    Edit Agent Config
    sudo nano /etc/zabbix/zabbix_agent2.conf
    Agent Settings
    Server=ZABBIX_SERVER_IP
    ServerActive=ZABBIX_SERVER_IP
    Hostname=unique-hostname-for-this-host
    Start Agent
    # Start and enable the agent
    sudo systemctl enable zabbix-agent2
    sudo systemctl start zabbix-agent2
    
    # Open firewall
    sudo ufw allow from ZABBIX_SERVER_IP to any port 10050

    Then add the host in the web interface: Data Collection → Hosts → Create Host

    3

    Useful Templates

    Apply these built-in templates to your hosts:

    Linux by Zabbix agent: CPU, memory, disk, network
    Apache by HTTP: Web server metrics
    MySQL by Zabbix agent: Database performance
    Docker by Zabbix agent 2: Container monitoring
    ICMP Ping: Basic availability checks

    Backup Strategy

    1

    Create Backup Script

    Create an automated backup script:

    backup-zabbix.sh
    #!/bin/bash
    BACKUP_DIR="/backup/zabbix"
    DATE=$(date +%Y%m%d)
    
    mkdir -p $BACKUP_DIR
    
    # Database backup
    mysqldump -uzabbix -pYourSecurePassword zabbix | gzip > $BACKUP_DIR/zabbix_db_$DATE.sql.gz
    
    # Configuration backup
    tar -czf $BACKUP_DIR/zabbix_config_$DATE.tar.gz /etc/zabbix/
    
    # Retain last 7 days
    find $BACKUP_DIR -type f -mtime +7 -delete
    Schedule Backup
    # Make executable
    chmod +x /path/to/backup-zabbix.sh
    
    # Add to cron for daily execution
    sudo crontab -e
    
    # Add this line:
    0 2 * * * /path/to/backup-zabbix.sh

    Troubleshooting

    1

    Check Logs

    Review logs for issues:

    Log Commands
    # Check Zabbix server logs
    sudo tail -f /var/log/zabbix/zabbix_server.log
    
    # Check agent logs
    sudo tail -f /var/log/zabbix/zabbix_agent2.log
    2

    Common Issues

    Database connection errors

    Verify credentials in /etc/zabbix/zabbix_server.conf match your MySQL user.

    Agent not connecting

    Check firewall rules and ensure agent hostname matches host configuration.

    High CPU usage

    Increase poller count or optimize item intervals in templates.

    Web interface slow

    Increase PHP memory limit and check MySQL performance.

    3

    Test Agent Connectivity

    Test agent communication from the server:

    Test Connection
    # Test agent connectivity
    zabbix_get -s 127.0.0.1 -k agent.ping
    
    # A response of "1" indicates successful communication

    Next Steps

    Configure custom triggers and alerts
    Create dashboards for visualization
    Integrate with Slack, PagerDuty, or email
    Set up auto-discovery for network devices