Building Zabbix agent on macOS

Overview

This section demonstrates how to build Zabbix macOS agent binaries from sources with or without TLS.

Prerequisites

You will need command line developer tools (Xcode is not required), Automake, pkg-config and PCRE (v8.x) or PCRE2 (v10.x). If you want to build agent binaries with TLS, you will also need OpenSSL or GnuTLS.

To install Automake and pkg-config, you will need a Homebrew package manager from https://brew.sh/. To install it, open terminal and run the following command:

  1. $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install Automake and pkg-config:

  1. $ brew install automake
  2. $ brew install pkg-config

Preparing PCRE, OpenSSL and GnuTLS libraries depends on the way how they are going to be linked to the agent.

If you intend to run agent binaries on a macOS machine that already has these libraries, you can use precompiled libraries that are provided by Homebrew. These are typically macOS machines that use Homebrew for building Zabbix agent binaries or for other purposes.

If agent binaries will be used on macOS machines that don’t have the shared version of libraries, you should compile static libraries from sources and link Zabbix agent with them.

Building agent binaries with shared libraries

Install PCRE2 (replace pcre2 with pcre in the commands below, if needed):

  1. $ brew install pcre2

When building with TLS, install OpenSSL and/or GnuTLS:

  1. $ brew install openssl
  2. $ brew install gnutls

Download Zabbix source:

  1. $ git clone https://git.zabbix.com/scm/zbx/zabbix.git

Build agent without TLS:

  1. $ cd zabbix
  2. $ ./bootstrap.sh
  3. $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6
  4. $ make
  5. $ make install

Build agent with OpenSSL:

  1. $ cd zabbix
  2. $ ./bootstrap.sh
  3. $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-openssl=/usr/local/opt/openssl
  4. $ make
  5. $ make install

Build agent with GnuTLS:

  1. $ cd zabbix-source/
  2. $ ./bootstrap.sh
  3. $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-gnutls=/usr/local/opt/gnutls
  4. $ make
  5. $ make install

Building agent binaries with static libraries without TLS

Let’s assume that PCRE static libraries will be installed in $HOME/static-libs. We will use PCRE2 10.39.

  1. $ PCRE_PREFIX="$HOME/static-libs/pcre2-10.39"

Download and build PCRE with Unicode properties support:

  1. $ mkdir static-libs-source
  2. $ cd static-libs-source
  3. $ curl --remote-name https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
  4. $ tar xf pcre2-10.39.tar.gz
  5. $ cd pcre2-10.39
  6. $ ./configure --prefix="$PCRE_PREFIX" --disable-shared --enable-static --enable-unicode-properties
  7. $ make
  8. $ make check
  9. $ make install

Download Zabbix source and build agent:

  1. $ git clone https://git.zabbix.com/scm/zbx/zabbix.git
  2. $ cd zabbix
  3. $ ./bootstrap.sh
  4. $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-libpcre2="$PCRE_PREFIX"
  5. $ make
  6. $ make install

Building agent binaries with static libraries with OpenSSL

When building OpenSSL, it’s recommended to run make test after successful building. Even if building was successful, tests sometimes fail. If this is the case, problems should be researched and resolved before continuing.

Let’s assume that PCRE and OpenSSL static libraries will be installed in $HOME/static-libs. We will use PCRE2 10.39 and OpenSSL 1.1.1a.

  1. $ PCRE_PREFIX="$HOME/static-libs/pcre2-10.39"
  2. $ OPENSSL_PREFIX="$HOME/static-libs/openssl-1.1.1a"

Let’s build static libraries in static-libs-source:

  1. $ mkdir static-libs-source
  2. $ cd static-libs-source

Download and build PCRE with Unicode properties support:

  1. $ curl --remote-name https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
  2. $ tar xf pcre2-10.39.tar.gz
  3. $ cd pcre2-10.39
  4. $ ./configure --prefix="$PCRE_PREFIX" --disable-shared --enable-static --enable-unicode-properties
  5. $ make
  6. $ make check
  7. $ make install
  8. $ cd ..

Download and build OpenSSL:

  1. $ curl --remote-name https://www.openssl.org/source/openssl-1.1.1a.tar.gz
  2. $ tar xf openssl-1.1.1a.tar.gz
  3. $ cd openssl-1.1.1a
  4. $ ./Configure --prefix="$OPENSSL_PREFIX" --openssldir="$OPENSSL_PREFIX" --api=1.1.0 no-shared no-capieng no-srp no-gost no-dgram no-dtls1-method no-dtls1_2-method darwin64-x86_64-cc
  5. $ make
  6. $ make test
  7. $ make install_sw
  8. $ cd ..

Download Zabbix source and build agent:

  1. $ git clone https://git.zabbix.com/scm/zbx/zabbix.git
  2. $ cd zabbix
  3. $ ./bootstrap.sh
  4. $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-libpcre2="$PCRE_PREFIX" --with-openssl="$OPENSSL_PREFIX"
  5. $ make
  6. $ make install

Building agent binaries with static libraries with GnuTLS

GnuTLS depends on the Nettle crypto backend and GMP arithmetic library. Instead of using full GMP library, this guide will use mini-gmp which is included in Nettle.

When building GnuTLS and Nettle, it’s recommended to run make check after successful building. Even if building was successful, tests sometimes fail. If this is the case, problems should be researched and resolved before continuing.

Let’s assume that PCRE, Nettle and GnuTLS static libraries will be installed in $HOME/static-libs. We will use PCRE2 10.39, Nettle 3.4.1 and GnuTLS 3.6.5.

  1. $ PCRE_PREFIX="$HOME/static-libs/pcre2-10.39"
  2. $ NETTLE_PREFIX="$HOME/static-libs/nettle-3.4.1"
  3. $ GNUTLS_PREFIX="$HOME/static-libs/gnutls-3.6.5"

Let’s build static libraries in static-libs-source:

  1. $ mkdir static-libs-source
  2. $ cd static-libs-source

Download and build Nettle:

  1. $ curl --remote-name https://ftp.gnu.org/gnu/nettle/nettle-3.4.1.tar.gz
  2. $ tar xf nettle-3.4.1.tar.gz
  3. $ cd nettle-3.4.1
  4. $ ./configure --prefix="$NETTLE_PREFIX" --enable-static --disable-shared --disable-documentation --disable-assembler --enable-x86-aesni --enable-mini-gmp
  5. $ make
  6. $ make check
  7. $ make install
  8. $ cd ..

Download and build GnuTLS:

  1. $ curl --remote-name https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.5.tar.xz
  2. $ tar xf gnutls-3.6.5.tar.xz
  3. $ cd gnutls-3.6.5
  4. $ PKG_CONFIG_PATH="$NETTLE_PREFIX/lib/pkgconfig" ./configure --prefix="$GNUTLS_PREFIX" --enable-static --disable-shared --disable-guile --disable-doc --disable-tools --disable-libdane --without-idn --without-p11-kit --without-tpm --with-included-libtasn1 --with-included-unistring --with-nettle-mini
  5. $ make
  6. $ make check
  7. $ make install
  8. $ cd ..

Download Zabbix source and build agent:

  1. $ git clone https://git.zabbix.com/scm/zbx/zabbix.git
  2. $ cd zabbix
  3. $ ./bootstrap.sh
  4. $ CFLAGS="-Wno-unused-command-line-argument -framework Foundation -framework Security" \
  5. > LIBS="-lgnutls -lhogweed -lnettle" \
  6. > LDFLAGS="-L$GNUTLS_PREFIX/lib -L$NETTLE_PREFIX/lib" \
  7. > ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-libpcre2="$PCRE_PREFIX" --with-gnutls="$GNUTLS_PREFIX"
  8. $ make
  9. $ make install