Zabbix - Installation

  • Posted on: 24 November 2014
  • By: Ashley

About

This page is going to detail how I configure my VMs for a Zabbix installation. For this page I'm using Ubuntu 14.04 desktop as my OS of choice, but for production deployment I probably wouldn't go with a desktop version of Ubuntu. This page is a work in progress.

Preparing your VM

  1. Install OS, ensure updated.
    sudo apt-get update
  2. Install necessary addons to allow for full-screen/multi screen VM. Appendix 1
    sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
  3. Install a few pre-requisites
    sudo apt-get install logwatch logrotate ufw
  4. Configure our UFW Rules, our installation is going to have the Java Gateway enabled (for JMX application monitoring)
    sudo su
    
    ufw allow proto tcp from 0.0.0.0/0 to any port 22
    ufw allow proto tcp from 0.0.0.0/0 to any port 80
    ufw allow proto tcp from 0.0.0.0/0 to any port 443
    ufw allow proto tcp from 0.0.0.0/0 to any port 3333
    ufw allow proto udp from 0.0.0.0/0 to any port 3333
    ufw allow proto tcp from 0.0.0.0/0 to any port 10050
    ufw allow proto udp from 0.0.0.0/0 to any port 10050
    ufw allow proto tcp from 0.0.0.0/0 to any port 10051
    ufw allow proto udp from 0.0.0.0/0 to any port 10051
    
    ufw enable
    
    exit
  5. Set up NTP Servers, if you have them. For my home installation I do not have NTP servers, so I skipped this section, however for the installations at work this was part of the setup, to ensure I was always synchronising to the same place as my monitored hosts.
    sudo apt-get install ntp
    
    sudo nano /etc/ntp.conf
    
    ntp01.domain.com
    ntp02.domain.com
    
  6. Installing other required packages, take note, you will be asked to specify a MySQL root password during this step, memorise it!
    sudo apt-get install mysql-server php5-mysql libmysqlclient-dev php5 openssh-server build-essential fping apache2 libsnmp-dev libcurl4-openssl-dev libapache2-mod-php5 php5-gd libiksemel-dev libssh2-1-dev libpq-dev openipmi libopenipmi-dev dnsutils locate nmap wget openjdk-6-jdk php5-ldap
  7. Configuration of php.ini
    sudo nano /etc/php5/apache2/php.ini
    
    max_execution_time = 300
    memory_limit = 256M 
    post_max_size = 32M
    date.timezone = (Timezone, for me this was)Australia/Brisbane
    upload_max_filesize = 16M
    max_input_time = 300
    
    sudo service apache2 restart
    
  8. Create group and user account
    sudo addgroup --system sysmon
    
    sudo adduser --system --disabled-login --ingroup sysmon --no-create-home zabbix 
  9. Change permissions on fping/6 folders
    sudo chown zabbix:sysmon /usr/bin/fping
    sudo chmod 710 /usr/bin/fping
    sudo chmod ug+s /usr/bin/fping
    
    sudo chown zabbix:sysmon /usr/bin/fping6
    sudo chmod 710 /usr/bin/fping6
    sudo chmod ug+s /usr/bin/fping6 
    
  10. Create some files, directories, and assign permissions
    sudo mkdir /etc/zabbix
    sudo mkdir /var/log/zabbix
    sudo mkdir /usr/src/zabbix
    
    sudo touch /var/log/zabbix/zabbix_server.log
    sudo touch /var/log/zabbix/zabbix_agent.log
    
    sudo chown -R zabbix:sysmon /etc/zabbix
    sudo chown -R zabbix:sysmon /var/log/zabbix
    
  11. Modify /etc/services
    sudo nano /etc/services
    
    # Our Zabbix Ports
    zabbix_java    3333/tcp   # Zabbix Java Gateway  
    zabbix_java    3333/udp   # Zabbix Java Gateway
    zabbix-agent    10050/tcp   # Zabbix Agent
    zabbix-agent    10050/udp   # Zabbix Agent
    zabbix-trapper    10051/tcp   # Zabbix Trapper
    zabbix-trapper    10051/udp   # Zabbix Trapper 
    
  12. Set up the rotation of logs
    sudo nano /etc/logrotate.d/zabbix-server
    
    /var/log/zabbix/zabbix_server.log {
       daily 
       rotate 7
       compress 
       missingok
       notifempty
       create 0640 zabbix sysmon 
       sharedscripts
    } 
    
    sudo nano /etc/logrotate.d/zabbix-agent
    
    /var/log/zabbix/zabbix_agent.log {
       daily 
       rotate 7
       compress 
       missingok
       notifempty
       create 0640 zabbix sysmon 
       sharedscripts
    } 
    
    
  13. Restart the server

The Zabbix Part

  1. Download the source files. For my latest Ubuntu 14.04 installations, I've download the v2.4 sources: Source
    cd $(yourDownloadLocation)
    tar xzf zabbix.X.X.tar.gz
    mv ./zabbix.X.X /usr/src/zabbix/
    
  2. Set up your MySQL Database:
    sudo mysql -uroot -p
    
    At this point you will be asked for the password you specified earlier for the root MySQL password, type it in.
    CREATE DATABASE zabbix CHARACTER SET utf8;
    CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '$(ZabbixMySQLPassword)';
    GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
    quit;
    
    cd /usr/src/zabbix/(zabbix build)/database/mysql
    
    cat schema.sql | mysql -uzabbix -p$(ZabbixMySQLPassword) zabbix;
    cat images.sql | mysql -uzabbix -p$(ZabbixMySQLPassword) zabbix;
    cat data.sql | mysql -uzabbix -p$(ZabbixMySQLPassword) zabbix;
    
    cd ../..
    
  3. Compile your installer. This is going to install our server, agent and the Java gateway, to allow us to do JMX monitoring.
    ./configure --enable-server --enable-agent --with-mysql --enable-java --with-net-snmp --with-ssh2 --with-openipmi --with-libcurl --with-ldap --enable-ipv6 --prefix=/etc/zabbix
    
    make install
  4. Modify the server config, this deployment is quite small, only a handful of servers and applications, it's worth assessing what you're doing and your needs before looking at this part of the setup. For this install I'm going to be doing web checks, agent checks and JMX checking.
    sudo nano /etc/zabbix/etc/zabbix_server.conf
    
    LogFile=/var/log/zabbix/zabbix_server.log
    DBName=zabbix
    DBUser=zabbix
    DBPassword=$(MySQLPassword)
    
    StartPollers=30
    StartPingers=10
    StartDiscoverers=3
    StartHTTPPollers=10
    JavaGateway=127.0.0.1
    JavaGatewayPort=3333
    StartJavaPollers=10
    
    Timeout=5 
    
    AlertScriptsPath=/usr/local/bin/zabbix 
    FpingLocation=/usr/bin/fping
    Fping6Location=/usr/bin/fping6
    
    AllowRoot=0
    
  5. Modify the settings for the Zabbix agent.
    sudo nano /etc/zabbix/etc/zabbix_agentd.conf
    
    LogFile=/var/log/zabbix/zabbix_agent.log
    Server=127.0.0.1, (Other Server IPs if present) 
    Hostname=(Hostname of Machine). 
    
  6. Setting up the init.d scripts. I took copies of the Debian init.d scripts, as they were perfect for our Ubuntu installation, for the most part.
    sudo cp /usr/src/zabbix/zabbix.X.X/misc/init.d/debian/zabbix-server /etc/init.d
    sudo cp /usr/src/zabbix/zabbix.X.X/misc/init.d/debian/zabbix-agent /etc/init.d/zabbix-agent
    
    sudo nano /etc/init.d/zabbix-server
    DAEMON=/etc/zabbix/sbin/${NAME}
    
    sudo nano /etc/init.d/zabbix-agent
    DAEMON=/etc/zabbix/sbin/${NAME}
    
  7. Modify the setting for the listen port for Java Gateway
    sudo nano /etc/zabbix/sbin/zabbix_java/settings.sh
    
    LISTEN_PORT=3333
    
  8. Copy the web front-end from the /usr/src/zabbix/zabbixBuild directory to your /var/www/ directory
    sudo cp -R /usr/src/zabbix/zabbix.X.X/frontends/php/ /var/www/html/
    
  9. Start the engines, starting with the Java Gateway
    sudo /etc/zabbix/sbin/zabbix_java/startup.sh
    sudo /etc/init.d/zabbix-server start
    sudo /etc/init.d/zabbix-agent start
    

Appendices

Appendix 1)

http://askubuntu.com/questions/451805/screen-resolution-problem-with-ubuntu-14-04-and-virtualbox