3 Zabbix-agent bouwen op macOS

Overzicht

Dit gedeelte laat zien hoe je Zabbix macOS-agentbinaries kunt compileren vanuit bronnen met of zonder TLS-ondersteuning.

Vereisten

Je hebt opdrachtregel ontwikkelaarstools nodig (Xcode is niet vereist), Automake, pkg-config en PCRE (v8.x) of PCRE2 (v10.x). Als je agent-binaries wilt compileren met TLS, heb je ook OpenSSL of GnuTLS nodig.

Om Automake en pkg-config te installeren, heb je een Homebrew-pakketbeheerder nodig vanaf https://brew.sh/. Om het te installeren, open je Terminal en voer je de volgende opdracht uit:

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

Installeer vervolgens Automake en pkg-config:

$ brew install automake
       $ brew install pkg-config

Het voorbereiden van de PCRE-, OpenSSL- en GnuTLS-bibliotheken hangt af van de manier waarop ze aan de agent worden gekoppeld.

Als je van plan bent om agent-binaries op een macOS-machine uit te voeren die al over deze bibliotheken beschikt, kun je vooraf gecompileerde bibliotheken gebruiken die worden geleverd door Homebrew. Dit zijn meestal macOS-machines die Homebrew gebruiken om Zabbix agent-binaries of voor andere doeleinden te compileren.

Als agent-binaries zullen worden gebruikt op macOS-machines die niet beschikken over de gedeelde versie van bibliotheken, dien je statische bibliotheken te compileren uit bronnen en Zabbix agent eraan te koppelen.

Compileren van agent-binaries met gedeelde bibliotheken

Installeer PCRE2 (vervang pcre2 door pcre in de onderstaande opdrachten, indien nodig):

$ brew install pcre2

Bij het compileren met TLS, installeer OpenSSL en/of GnuTLS:

$ brew install openssl
       $ brew install gnutls

Download de Zabbix-broncode:

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

Compileer agent zonder TLS:

$ cd zabbix
       $ ./bootstrap.sh
       $ ./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6
       $ make
       $ make install

Compileer agent met OpenSSL:

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

Compileer agent met GnuTLS:

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

Compileren van agent-binaries met statische bibliotheken zonder TLS

Laten we aannemen dat de statische bibliotheken van PCRE worden geïnstalleerd in $HOME/static-libs. We zullen PCRE2 10.39 gebruiken.

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

Download en compileer PCRE met ondersteuning voor Unicode-eigenschappen:

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

Download de Zabbix-broncode en compileer de agent:

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

Compileren van agent-binaries met statische bibliotheken met OpenSSL

Bij het compileren van OpenSSL wordt aanbevolen om make test uit te voeren na een succesvolle compilatie. Zelfs als de compilatie succesvol was, mislukken tests soms. Als dit het geval is, moeten problemen worden onderzocht en opgelost voordat u doorgaat.

Laten we aannemen dat de statische bibliotheken van PCRE en OpenSSL worden geïnstalleerd in $HOME/static-libs. We zullen PCRE2 10.39 en OpenSSL 1.1.1a gebruiken.

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

Laten we statische bibliotheken bouwen in static-libs-source:

$ mkdir static-libs-source
       $ cd static-libs-source

Download en compileer PCRE met ondersteuning voor Unicode-eigenschappen:

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

Download en compileer OpenSSL:

$ curl --remote-name https://www.openssl.org/source/openssl-1.1.1a.tar.gz
       $ tar xf openssl-1.1.1a.tar.gz
       $ cd openssl-1.1.1a
       $ ./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
       $ make
       $ make test
       $ make install_sw
       $ cd ..

Download de Zabbix-broncode en compileer de agent:

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

Compileren van agent-binaries met statische bibliotheken met GnuTLS

GnuTLS is afhankelijk van de Nettle-crypto-backend en de GMP-rekenbibliotheek. In plaats van de volledige GMP-bibliotheek te gebruiken, zal deze handleiding mini-gmp gebruiken, die is opgenomen in Nettle.

Bij het compileren van GnuTLS en Nettle wordt aanbevolen om na een succesvolle compilatie make check uit te voeren. Zelfs als de compilatie succesvol was, mislukken tests soms. Als dit het geval is, moeten problemen worden onderzocht en opgelost voordat u doorgaat.

Laten we aannemen dat de statische bibliotheken van PCRE, Nettle en GnuTLS worden geïnstalleerd in $HOME/static-libs. We zullen PCRE2 10.39, Nettle 3.4.1 en GnuTLS 3.6.5 gebruiken.

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

Laten we statische bibliotheken bouwen in static-libs-source:

$ mkdir static-libs-source
       $ cd static-libs-source

Download en compileer Nettle:

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

Download en compileer GnuTLS:

$ curl --remote-name https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.5.tar.xz
       $ tar xf gnutls-3.6.5.tar.xz
       $ cd gnutls-3.6.5
       $ 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
       $ make
       $ make check
       $ make install
       $ cd ..

Download de Zabbix-broncode en compileer de agent:

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