Zabbix is Open Source cross platform Monitoring Tool for network and application, which provide fairly good features for various platforms.which can able to collect data from various hosts through various ways like SNMP, Zabbix agents, SSH, IPMI, HTTP and JMX etc.
zabbix_logo
In this post, we would see how we could install Zabbix 3.2 in Ubuntu 17.04. In earlier posts, we saw how we could install it in CentOS6. we would also cover how we could install it on CentOS7 later.
We are considering, that readers know how to install ubuntu17.04

Setup

root@srvU:~# lsb_release -d
Description:    Ubuntu 17.04
root@srvU:~# uname -r
4.10.0-19-generic

root@srvU:~# /usr/local/sbin/zabbix_server -V
zabbix_server (Zabbix) 3.2.7
Revision 70298 18 July 2017

root@srvU:~# mysql -V
mysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using  EditLine wrapper

root@srvU:~# php -v
PHP 7.0.18-0ubuntu0.17.04.1 (cli) (built: Apr 26 2017 23:59:48) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.18-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies

Installation

For Zabbix. we need to configure Apache – For hosting Zabbix Site, MySQL – For storing Zabbix database, PHP – Zabbix frontend written in PHP.
So installing it on Linux is configure LAMP (Linux Apache MySQL PHP) on one Host.

We can Install it with Ubuntu repositories, That will automatically resolve all dependencies and install Zabbix packages in one command. But I always recommend to install it from tar bundle downloaded from Zabbix website.

Installation of packages

Let’s Install some basic packages involved in the setup. Apache, Mysql-server and PHP. There are some other packages required for proper function of which we would see later during Zabbix code compilation.

# apt-get install apache2 
# apt-get install mysql-server 
# apt-get install  libapache2-mod-php php php-bcmath php-cli php-common php-gd php-json php-ldap php-mbstring php-mysql php-opcache php-readline php-xml

During installation of MySQL, it will also ask for root password, which would work in MySQL for the various administrative task. please keep that password safe

Start apache service and add it to boot.

root@srvU:~# systemctl start apache2
root@srvU:~# /etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.

root@srvU:~# systemctl enable apache2
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2

Creation of MySQL Database

For Zabbix, we need to create Zabbix database that will store data collected from monitoring devices and Host and will fetch from Apache2 running on Zabbix Apache machine to display on the browser.
So let’s start creating Zabbix database. For this, we need to login on MySQL and run below commands.

root@srvU:~/zabbix-3.2.7# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19-0ubuntu0.17.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>  CREATE DATABASE zabbix character set utf8 collate utf8_bin;;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL on zabbix.* to zabbix@localhost IDENTIFIED BY 'passw0rd';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

Now we have zabbix database, in MySQL with zabbix user as defined above. Now we could download Zabbix tar ball from website, this need to extract and export database sql in database as below.

root@srvU:~# pwd
/root
root@srvU:~# ls
zabbix-3.2.7.tar.gz
root@srvU:~# tar -xzf zabbix-3.2.7.tar.gz
root@srvU:~# ls
zabbix-3.2.7  zabbix-3.2.7.tar.gz
root@srvU:~# cd zabbix-3.2.7/database/mysql/
root@srvU:~/zabbix-3.2.7/database/mysql# ls
data.sql  images.sql  schema.sql
root@srvU:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < schema.sql
Enter password:
root@srvU:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < images.sql
Enter password:
root@srvU:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < data.sql
Enter password:

So this way, Zabbix database updates and create required tables in the database. Now we could work on Apache and PHP.

Zabbix code compilation

As we already have zabbix tar ball in system. we should compile tar ball and install Zabbix binares.

root@srvU:~/zabbix-3.2.7# pwd
/root/zabbix-3.2.7
root@srvU:~/zabbix-3.2.7# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ldap --with-openipmi  --with-libxml2  --with-ssh2 --with-unixodbc

We take various options as per my required setup, you can choose yours. But it’s important to know dependencies with options. we faced many issues while configuring, it always needs some packages. like below.

gcc

configure: error: MySQL library not found
libmysqld-dev

configure: error: LIBXML2 library not found
libxml2-devel

configure: error: unixODBC library not found
unixodbc-dev

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
libsnmp-dev

Processing triggers for libc-bin (2.24-9ubuntu2) ...
make

configure: error: SSH2 library not found
libssh2-1-dev

configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
libopenipmi-dev

configure: error: Invalid LDAP directory - unable to find ldap.h
libldap2-dev

Compilation completed of Zabbix, will show below output

Configuration:

  Detected OS:           linux-gnu
  Install path:          /usr/local
  Compilation arch:      linux

  Compiler:              gcc
  Compiler flags:         -g -O2

  Library-specific flags:
    database:               -I/usr/include/mysql
    libXML2:               -I/usr/include/libxml2
    Net-SNMP:               -I/usr/local/include -I/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -I. -I/usr/include
    OpenIPMI:              -I/usr/include
    libssh2:               -I/usr/include
    LDAP:                  -I/usr/include

  Enable server:         yes
  Server details:
    With database:         MySQL
    WEB Monitoring:        cURL
    Native Jabber:         no
    SNMP:                  yes
    IPMI:                  yes
    SSH:                   yes
    TLS:                   no
    ODBC:                  yes
    Linker flags:             -L/usr/lib/x86_64-linux-gnu        -L/usr/lib/x86_64-linux-gnu -L/usr/lib -L/usr/lib  -L/usr/lib  -rdynamic
    Libraries:               -lmysqlclient      -lxml2  -lodbc  -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix  -lldap -llber   -lcurl -lm -ldl  -lresolv

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    TLS:                   no
    Linker flags:            -L/usr/lib  -rdynamic
    Libraries:               -lldap -llber   -lcurl -lm -ldl  -lresolv

  Enable Java gateway:   no

  LDAP support:          yes
  IPv6 support:          yes

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

Now run make install as shown in above output

#make install

We can see further that Zabbix nstalled properly.

root@srvU:~/zabbix-3.2.7# ls -l /usr/local/sbin/zabbix_*
-rwxr-xr-x 1 zabbix zabbix 1576728 Jul 24 15:05 /usr/local/sbin/zabbix_agentd
-rwxr-xr-x 1 zabbix zabbix 5412136 Jul 24 15:05 /usr/local/sbin/zabbix_server
root@srvU:~/zabbix-3.2.7# zabbix_
zabbix_agentd  zabbix_get     zabbix_sender  zabbix_server

Create Zabbix user and group which run Zabbix Server binary.

groupadd zabbix
useradd -g zabbix zabbix

Now we should need to edit Zabbix Server and Zabbix Agent configuration file.

DBPassword needd to mention in Zabbix_Server configuration file, otherwise Zabbix Server process can’t able to connect MySQL to fill-up databases.

First edit Zabbix_server configuration file “/usr/local/etc/zabbix_server.conf”, These are very common changes that effect Zabbix Server function.

[root@srv7-master ~]# egrep -v "^#|^$" /usr/local/etc/zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Passw0rd
DBSocket=/tmp/mysql.sock
DBPort=3306

Let’s talk some of above derivatives, except DBPassword all derivatives are default and very well drafted in file like
port(Server listening port)
log-file(Zabbix Server log-file )
pid-file(Zabbix Server pid file)
DBHost(Database Host)
DBName(Database Name)
DBUser(Database User name, which has all access on mentioned database name)
DBPassword(Database User password through which it will going to access Database)
DOSocket(Database Server Socket file)
DBPort(Database Sever port on which we need to connect).

So These derivatives are very important to match with you setup, otherwise your Zabbix Server will not work accordingly.

Let’s edit Agent configuration file. It’s important to work on this file because of this Agent process Zabbix server will collect details and show on Zabbix Server web console.

[root@srv7-master ~]# egrep -v "^#|^$" /usr/local/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=srv7-master

I didn’t change any derivatives except Hostname, its always good to mention correct Hostname in this file. Now we could start Zabbix Server and Zabbix agent process.

Now we sould run Zabbix server with below command.

root@srvU:~/zabbix-3.2.7# /usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf
root@srvU:~/zabbix-3.2.7# ps -fC zabbix_server
UID        PID  PPID  C STIME TTY          TIME CMD
zabbix    3433     1  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf
zabbix    3435  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: configuration syncer [synced configuration in 0.020410 sec, idle 60 sec]
zabbix    3436  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: db watchdog [synced alerts config in 0.001903 sec, idle 60 sec]
zabbix    3437  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    3438  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #2 [got 0 values in 0.000007 sec, idle 5 sec]
zabbix    3439  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #3 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    3440  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #4 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    3441  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #5 [got 0 values in 0.000007 sec, idle 5 sec]
zabbix    3442  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000004 sec, idle 5 sec]
zabbix    3443  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #1 [processed data in 0.000009 sec, waiting for connection]
zabbix    3444  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #2 [processed data in 0.000012 sec, waiting for connection]
zabbix    3445  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #3 [processed data in 0.000013 sec, waiting for connection]
zabbix    3446  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #4 [processed data in 0.000007 sec, waiting for connection]
zabbix    3447  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #5 [processed data in 0.000012 sec, waiting for connection]
zabbix    3448  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000006 sec, idle 5 sec]
zabbix    3449  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000952 sec, idle 30 sec]
zabbix    3450  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.066011 sec, idle for 1 hour(s)]
zabbix    3451  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000018 sec, 0 maintenances in 0.002034 sec, idle 30 sec]
zabbix    3452  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: http poller #1 [got 0 values in 0.001501 sec, idle 5 sec]
zabbix    3456  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.001073 sec, idle 60 sec]
zabbix    3457  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    3458  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    3459  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix    3460  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix    3461  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.001577 sec, idle 3 sec]
zabbix    3467  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000003 sec, idle 5 sec]
zabbix    3468  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: self-monitoring [processed data in 0.000007 sec, idle 1 sec]
zabbix    3469  3433  0 12:45 ?        00:00:00 /usr/local/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000465 sec, idle 5 sec]

Now we should also start Zabbix Agent as well.

[root@srv7-master ~]# /usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
[root@srv7-master ~]# ps -fC zabbix_agentd
UID        PID  PPID  C STIME TTY          TIME CMD
zabbix    9153     1  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
zabbix    9154  9153  0 13:49 ?        00:00:01 /usr/local/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix    9155  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix    9156  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix    9157  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix    9158  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

As we alreay install Apache and PHP already above and started Apache service, now we need to see how things works for Zabbix. We need to copy Zabbix PHP frontend file in “/var/www/html”.

root@srvU:~/zabbix-3.2.7/frontends/php# pwd
/root/zabbix-3.2.7/frontends/php
root@srvU:~/zabbix-3.2.7/frontends/php# cp -rfp * /var/www/html/
root@srvU:~/zabbix-3.2.7/frontends/php# chown -R www-data:www-data /var/www/html/

Now the time comes when we could start work on Zabbix web console for its configuration. So open http://IP-Address from local browser.
Installation_1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click on Next.
Installation_2

 

 

 

 

 

 

 

 

 

 

 

 

 

This might show you some errors, which could resolve with following ways.

1. PHP settings

Edit /etc/php/7.0/apache2/php.ini file for below derivatives. On Error window as well it shows you clearly about derivatives and their required values.

date.timezone = 'Asia/Kolkata'
max_execution_time = 300
post_max_size = 32M
max_input_time = 300

Installation of required PHP addons packages

php-bcmath
php-gd 
php-json 
php-ldap 
php-mbstring
php-xml

Restart Apache service and again. reload again.

Installation_3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

provide MySQL Zabbix password and click Next

Installation_4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Put Zabbix Hostname, Better to have the good significant hostname or DNS Record. Click Next

Installation_5

 

 

 

 

 

 

 

 

 

 

 

 

 

installation Summary, Click Next.

Installation_6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Congratulations, It’s Done.

 

Installation_7

 

 

 

 

 

 

 

 

 

 

 

 

Now we could open Zabbix Admin Panel.

User     - admin
Password - Zabbix