Docker containers for Zabbix Server and Zabbix Web

dockerZabbix Logo

Since a few weeks I started using Docker and building containers and this is really fun to do. So one of my first public docker containers had to be something with Zabbix. 🙂

So I have created 2 docker containers;

  • zabbix-server
  • zabbix-web

So, here follows an description about the 2 containers.

Zabbix-Server

This container will run an zabbix-server. Jeah!

Its an Debian based container (As Debian is one of the smaller ones) and will only run the Zabbix Server. No database is running in this container, it is configured to use an MySQL database as backend. Before you can make use of this container, you’ll have to have an MySQL Server running somewhere in your environment. It will install Zabbix 3.0.1

How do we use this container? First we have to download it:

docker pull wdijkerman/zabbix-server

And this is how we start it:

docker run  -p 10051:10051 --name zabbix-server \
            -v /data/zabbix:/zabbix \
            -e ROOTPASSWORD=secretpassword \
            -e DBHOST=192.168.1.153 -e DBUSER=zabbix \
            -e DBPASSWORD="zabbix-pass" \
            -e DBPORT=3306 -e DBNAME=zabbix wdijkerman/zabbix-server

This docker container make use of an volume, mentioned with the -v parameter. This will mount the ‘/data/zabbix’ directory in the docker container as ‘/zabbix’. This directory contains the directories which are used for storing SSL (configuration) files, modules and scripts. With the -p option, we open the port on the host (10051) and forward it to the port to the docker container (10051).

The -e values which you see are environment settings that are passed into the docker container. These environment settings are the actual Zabbix Server configuration options but in uppercase. As you might see, the settings in the example are used for connecting to the database ‘zabbix’ on host ‘192.168.1.153’ with username ‘zabbix’ and password ‘zabbix-pass’. I also specified the ‘ROOTPASSWORD’ setting, this is the password for the MySQL root user. When this is supplied, it will create the database (DBNAME) and create the user (DBUSER). If you don’t specify it (Which can of course) an database and user should already be created.

With this in mind, if we want to set the StartPollers parameter to 10, we have to update the run command by adding the following:

-e STARTPOLLERS=10

Now you can configure the Zabbix Server exactly like you want, just by adding some environment parameters in the command line before starting it.

But this is only the Zabbix Server, not the frontend.

Zabbix Web

This container contains only the Zabbix Web part, or the ‘frontend’. (docker hub)

Like the Zabbix Server, this is also an Debian based docker container and will only work with MySQL as database. It is running Apache 2.4.

How do we use this container? First we have to download it:

docker pull wdijkerman/zabbix-web

And this is how we start it:

docker run  -p 80:80 --name zabbix-web \
            -e ZABBIXURL=zabbix.example.com \
            -e ZBXSERVERNAME=vserver-151 \
            -e ZBXSERVER=192.168.1.151 \
            -e DBHOST=192.168.1.153 -e DBUSER=zabbix \
            -e DBPASSWORD="zabbix-pass" \
            -e DBPORT=3306 -e DBNAME=zabbix wdijkerman/zabbix-web

The DB* settings are the same as for the Zabbix Server container, so I won’t describe them again. With the Zabbix Web container we open port 80 on the host and forward it to port 80 on the docker container.

With the ZABBIXURL setting, we specify the url on which the web interface is available. In this case, when we open ‘zabbix.example.com’ we get the login page of Zabbix. (Well, if you have access to the zabbix.example.com domain 😉 ) With the ZBXSERVERNAME setting we specify the name of the Zabbix Server and with ZBXSERVER we let the Zabbix Web know where it can find the Zabbix Server.

Please let me know if you find any issues with configuring it or encounter an bug. Also if you have improvements, please create an PR on github! 🙂

Links:

Advertisements

wdijkerman-zabbix 2.1.0 puppet module just released

Puppet Logo Zabbix Logo

I just released an new version of the wdijkerman-zabbix puppet module: 2.0.0.

This release was possible with the huge efforts that @rnelson0 made for this module. Did fixed some bugs, tests and made it possible to use travis-ci.org to validate the builds. When an Pull Request is created by someone, the PR will be build on travis-ci too! 🙂

The change log for this release:

  • Removed a debug entry #156 (By pull request: hkumarmk (Thanks!))
  • Add Puppet Forge Version and Downloads badges #163 (By pull request: rnelson0 (Thanks!))
  • Travis CI setup: ensure all rspec tests pass #162 (By pull request: rnelson0 (Thanks!))
  • Update proxy.pp, fix Error: …install zabbix-proxy- .. #159 (By pull request: subkowlex (Thanks!))
  • Puppetgem #158 (By pull request: rnelson0 (Thanks!))

The “#<NUM>” is a reference to an Github issue. The release can now also be found on and downloaded from the forge.

If you find an bug or have an improvement for this Zabbix puppet module, please create pull requests!

wdijkerman-zabbix version 1.7.0 puppet module released

Puppet LogoZabbix Logo

I just released an new version of the wdijkerman-zabbix puppet module: 1.7.0.

This is an “Pull requests” release, as this release only contains pull requests created by users of this module. 🙂

The change log for this release:

  • misspelled parameter path #116 (By pull request: karolisc (Thanks!))
  • Update template.pp #121 (By pull request: claflico (Thanks!))
  • add support for CloudLinux #122 (By pull request: bastelfreak (Thanks!))
  • Fping wrong path in debian #124 (By pull request: Oyabi (Thanks!))
  • refactoring of repo.pp #126 (By pull request: bastelfreak (Thanks!))
  • Added supporting new Zabbix params #128 (By pull request: akostetskiy (Thanks!))
  • Generalise the zabbix_url #129 (By pull request: DjxDeaf (Thanks!))

The “#<NUM>” is a reference to an Github issue. The release can now also be found on and downloaded from the forge.

If you find an bug or have an improvement for this Zabbix puppet module, please create pull requests!

wdijkerman-zabbix puppet module now on release 1.2.0

puppetzabbix_logo

Almost a month ago, the wdijkerman-zabbix version 1.1.0 was released. I didn’t do much myself since this release 1.1.0 till now, but I did receive some pull requests. So I figured it is time to create a new release: 1.2.0.

Whats in this release? (I’m lazy, so this is copied from the CHANGELOG.md 🙂 )

  • Support for RedHat/CentOS/OracleLinux 7
  • Fixed bug with listenip & add lxc interface #46 (By pull request: meganuke19 (Thanks!))
  • Bad syntax in manifests/proxy.pp #50 (By pull request: fredprod (Thanks!))
  • Fix agent listenip #52 (By pull request: JvdW (Thanks!))
  • Fix in params.pp with default parameter of zabbix proxy for ubuntu #56 (By pull request: fredprod (Thanks!))
  • notify zabbix-agent service when userparameters change #57 (By pull request: rleemorlang (Thanks!))
  • Fix for: “Cannot Load Such File — zabbixapi” despite installation #54
  • Fix for correct order, so 1 puppet run installs the proxy again

The “#<NUM>” is a reference to an github issue. The release can now also be found on and downloaded from the forge.

If you find an bug or have an improvement for this zabbix puppet module, please create pull requests!

One node vs multi node setup zabbix module zabbix-proxy

zabbix_logo

With the previous post I showed you how you can use the zabbix-server on one or multiple machines with my wdijkerman-zabbix puppet module. At the end I said that you could also do this with the zabbix-proxy. So this blog item is showing how to setup the zabbix-proxy on 1 or 2 nodes. I don’t know if people are using it like this, but when I was busy for the zabbix-server, I thought that I also had to do this for the zabbix-proxy. 🙂

So sit back and watch the show. 🙂

Single node

PostgreSQL

So, we first show you have to do this with the PostgreSQL as backend.

node 'proxy.example.com'
 class { 'postgresql::server': }

 class { 'zabbix::proxy':
   zabbix_server_host => '192.168.20.11',
   zabbix_server_port => '10051',
 }
}

As you see in this manifests file, we have configured to use the postgresql-server class and the zabbix-proxy class. This zabbix-proxy class needs 1 parameter: ‘zabbix_server_host’. This is the ip address or fqdn of the zabbix-server host. The parameter ‘zabbix_server_port’ is optional, you only have to use this parameter when the zabbix-server is running on a different port than 10051.

MySQL

Okay, so you want to use MySQL as database backend? No worries, take a look at this:

node 'proxy.example.com'
 class { 'mysql::server': }

 class { 'zabbix::proxy':
   zabbix_server_host => '192.168.20.11',
   zabbix_server_port => '10051',
   database_type      => 'mysql',
 }
}

Like the zabbix-server, the zabbix-proxy uses the PostgreSQL as default database. So we have to use the ‘database_type’ parameter for specifying mysql.

Multi node

With the following example, we have 2 servers:

  • server11.example.com, which will be running the zabbix-proxy.
  • server12.example.com, which will be running the database.

MySQL

Lets start the manifests file again with the MySQL as ‘database_type’:

node 'server11.example.com' {
# My ip: 192.168.30.11
  class { 'mysql::client': }
  class { 'zabbix::proxy':
    zabbix_server_host => '192.168.20.11',
    manage_database    => false,
    database_host      => 'server12.example.com',
    database_type      => 'mysql',
  }
}

node 'server12.example.com' {
# My ip: 192.168.30.12
  class { 'mysql::server':
    override_options => {
      'mysqld'       => {
        'bind_address' => '192.168.30.12',
      },
    },
  }
  class { 'zabbix::database':
    database_type     => 'mysql',
    zabbix_type       => 'proxy',
    zabbix_proxy      => 'server11.example.com',
    database_name     => 'zabbix-proxy',
    database_user     => 'zabbix-proxy',
    database_password => 'zabbix-proxy',
  }
}

On the node of the zabbix-proxy, we had to add a new parameter: ‘manage_database’. We had to set it to false, the proxy class isn’t responsible for creating the database and loading the files. Thats what the ‘zabbix::database’ will do on the 2nd host.

PostgreSQL

Now with the PostgreSQL as ‘database_type’:

node 'server11.example.com' {
# My ip: 192.168.30.11
  class { 'postgresql::client': }
  class { 'zabbix::proxy':
    zabbix_server_host => '192.168.20.11',
    manage_database    => false,
    database_host      => 'server12.example.com',
  }
}

node 'server12.example.com' {
# My ip: 192.168.30.12
  class { 'postgresql::server':
    listen_addresses => '192.168.30.12'
  }
  class { 'zabbix::database':
    zabbix_type       => 'proxy',
    zabbix_proxy_ip   => '192.168.30.11',
    database_name     => 'zabbix-proxy',
    database_user     => 'zabbix-proxy',
    database_password => 'zabbix-proxy',
  }
}

With the above setup for both MySQL as PostgreSQL as ‘database_type’, we had to use the ‘database_name’ and ‘database_password’ parameters. The default values for the ‘zabbix::database’ class is for both parameters ‘zabbix-server’. Which is a kind of strange for the proxy. 🙂

Note

With the default installation on both the single as the multi node setup, the password for the database is ‘zabbix-server’. I would strongly recommend that you use the parameter: ‘database_password’ and give it a nice password.

One node vs multi node setup zabbix module zabbix-server

zabbix_logo
So it was quiet the last few months for posting stuff on the site, so I’ll try to do it now. I also moved the wordpress.com instead of hosting the site myself.
At the moment on writing this blog item, the wdijkerman-zabbix puppet module is at release 1.1.0. One of the biggest changes which came with release 1.0.0, is that you can choose whether your want everything one to run on a single host (Single Node, Like most of us) or running it on different servers (Multi node).

 

Up to release 1.0.0 you could only use the wdijkerman-zabbix puppet module if everything was running on the same host. Yes, from release > 0.5.0 you could even with some ‘hacking’ run the database on an other host, but that was not something I would document let alone it was a little bit confusing to do.

 

First, we start with the Single node setup. Apache, Zabbix-web, Zabbix-server and the database is installed on 1 system.

Single node

PostgreSQL

So, lets install the zabbix-server on one host:
node 'zabbix.example.com'
  class { 'apache':
    mpm_module => 'prefork',
  }
  include apache::mod::php
 
  class { 'postgresql::server': }
 
  class { 'zabbix':
    zabbix_url    => 'zabbix.example.com',
  }
}
With this manifest setup, you have configured an complete zabbix-server on one host.

 

It will install and configure Apache, postgresql (Default database for zabbix) and both zabbix components zabbix-web and zabbix-server. There is only one parameter needed for zabbix-server and it is the ‘zabbix_url’. This is the url on which the zabbix web interface is available, the rest of the parameters are optional.

MySQL

Oh, you want to run it on MySQL? No problem, this would be an very basic setup to begin with:
node 'zabbix.example.com'
  class { 'apache':
    mpm_module => 'prefork',
  }
  include apache::mod::php

  class { 'mysql::server': }

  class { 'zabbix':
    zabbix_url    => 'zabbix.example.com',
    database_type => 'mysql',
  }
}

multi node

Now, the multi node setup. This example consists of 3 nodes:
  • server01.example.com, which will be running Apache and the zabbix-web component.
  • server02.example.com, which will be running the zabbix-server component
  • server03.example.com, which will be running the database.

First we give an example of using this setup with the MySQL database.

MySQL

The following example will be given with the usage of MySQL as database backend. You can also choose to use the PostgreSQL database, but  than you have to change the setup a little bit. This will be described after the example:
node 'server01.example.com' {
  # My ip: 192.168.20.11
  class { 'apache':
    mpm_module => 'prefork',
  }
  class { 'apache::mod::php': }
  class { 'zabbix::web':
    zabbix_url => 'zabbix.example.com',
    zabbix_server => 'server02.example.com',
    database_host => 'server03.example.com',
    database_type => 'mysql',
  }
}

node 'server02.example.com' {
  # My ip: 192.168.20.12
  class { 'mysql::client': }
  class { 'zabbix::server':
    database_host => 'server03.example.com',
    database_type => 'mysql',
  }
}

node 'server03.example.com' {
  # My ip: 192.168.20.13
  class { 'mysql::server':
    override_options => {
      'mysqld' => {
      'bind_address' => '192.168.20.13',
      },
    },
  }
  class { 'zabbix::database':
  database_type => 'mysql',
    zabbix_server => 'server02.example.com',
    zabbix_web => 'server01.example.com',
  }
}
We have to fill in some ip’s or hostnames for this setup. Both the zabbix-web and -server needs to know where the database is and the zabbix-web needs to know where to find the zabbix-server.

PostgreSQL

When you want to use the PostgreSQL as backend in an multinode setup, you can use something like this:
node 'server01.example.com' {
# My ip: 192.168.20.11
 class { 'apache':
   mpm_module => 'prefork',
 }
 class { 'apache::mod::php': }
 class { 'zabbix::web':
   zabbix_url => 'zabbix.example.com',
   zabbix_server => 'server02.example.com',
   database_host => 'server03.example.com',
   database_type => ‘postgresql',
 }
}

node 'server02.example.com' {
# My ip: 192.168.20.12
 class { 'postgresql::client': }
 class { 'zabbix::server':
   database_host => 'server03.example.com',
   database_type => ‘postgresql',
 }
}

node 'server03.example.com' {
# My ip: 192.168.20.13
 class { 'postgresql::server':
   listen_addresses => '192.168.20.13'
 }
 class { 'zabbix::database':
   database_type => ‘postgresql',
   zabbix_web_ip => '192.168.20.12',
   zabbix_server_ip => '192.168.20.13',
 }
}
The PostgreSQL class accepts different values than MySQL: PostgreSQL accepts ipaddresses and MySQL accepts fqdn.

 

On a next item, I’ll go into the zabbix-proxy component. Like the zabbix-server, this can also be installed on a single node or multi node.

Note

With the default installation on both the single as the multi node setup, the password for the database is ‘zabbix-server’. I would strongly recommend that you use the parameter: ‘database_password’ and give it a nice password.