Compilar el agent de Zabbix en macOS
Descripción general
Esta sección muestra cómo compilar los binarios del agente de Zabbix para macOS desde el código fuente con o sin TLS.
Requisitos previos
Necesitará herramientas de desarrollo de línea de comandos (Xcode no es necesario), Automake, pkg-config y PCRE (v8.x) o PCRE2 (v10.x). Si desea compilar binarios de agent con TLS, también necesitará OpenSSL o GnuTLS.
Para instalar Automake y pkg-config, necesitará el gestor de paquetes Homebrew de https://brew.sh/. Para instalarlo, abra la terminal y ejecute el siguiente comando:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Luego instale Automake y pkg-config:
brew install automake
brew install pkg-config
La preparación de las bibliotecas PCRE, OpenSSL y GnuTLS depende de la forma en que se vayan a enlazar con el agent.
Si tiene previsto ejecutar binarios de agent en un equipo macOS que ya tenga estas bibliotecas, puede usar bibliotecas precompiladas proporcionadas por Homebrew. Normalmente, se trata de equipos macOS que usan Homebrew para compilar binarios de Zabbix agent o para otros fines.
Si los binarios de agent se van a usar en equipos macOS que no tienen la versión compartida de las bibliotecas, debe compilar bibliotecas estáticas a partir del código fuente y enlazar Zabbix agent con ellas.
Compilar binarios del agente con bibliotecas compartidas
Instale PCRE2 (reemplace pcre2 por pcre en los comandos a continuación, si es necesario):
brew install pcre2
Al compilar con TLS, instale OpenSSL y/o GnuTLS:
brew install openssl
brew install gnutls
Descargue el código fuente de Zabbix:
git clone https://git.zabbix.com/scm/zbx/zabbix.git
Compile el agente sin TLS:
cd zabbix
./bootstrap.sh
./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6
make
make install
Compile el agente con OpenSSL:
cd zabbix
./bootstrap.sh
./configure --sysconfdir=/usr/local/etc/zabbix --enable-agent --enable-ipv6 --with-openssl=/usr/local/opt/openssl
make
make install
Compile el agente con 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
Compilar binarios del agente con bibliotecas estáticas sin TLS
Supongamos que las bibliotecas estáticas de PCRE se instalarán en
$HOME/static-libs. Usaremos PCRE2 10.39.
PCRE_PREFIX="$HOME/static-libs/pcre2-10.39"
Descargue y compile PCRE con soporte para propiedades Unicode:
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
Descargue el código fuente de Zabbix y compile el agente:
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
Compilando binarios del agente con bibliotecas estáticas con OpenSSL
Al compilar OpenSSL, se recomienda ejecutar make test después de una compilación exitosa. Incluso si la compilación fue exitosa, a veces las pruebas fallan. Si este es el caso, se deben investigar y resolver los problemas antes de continuar.
Supongamos que las bibliotecas estáticas de PCRE y OpenSSL se instalarán en $HOME/static-libs. Usaremos PCRE2 10.39 y OpenSSL 1.1.1a.
PCRE_PREFIX="$HOME/static-libs/pcre2-10.39"
OPENSSL_PREFIX="$HOME/static-libs/openssl-1.1.1a"
Compilaremos las bibliotecas estáticas en static-libs-source:
mkdir static-libs-source
cd static-libs-source
Descargue y compile PCRE con soporte para propiedades Unicode:
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 ..
Descargue y compile 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 ..
Descargue el código fuente de Zabbix y compile el agente:
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
Compilación de binarios del agente con bibliotecas estáticas con GnuTLS
GnuTLS depende del backend criptográfico Nettle y de la biblioteca aritmética GMP. En lugar de usar la biblioteca GMP completa, esta guía usará mini-gmp que está incluida en Nettle.
Al compilar GnuTLS y Nettle, se recomienda ejecutar make check
después de una compilación exitosa. Incluso si la compilación fue exitosa, las pruebas
a veces fallan. Si este es el caso, se deben investigar y resolver los problemas antes de continuar.
Supongamos que las bibliotecas estáticas de PCRE, Nettle y GnuTLS se
instalarán en $HOME/static-libs. Usaremos PCRE2 10.39, Nettle 3.4.1
y GnuTLS 3.6.5.
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"
Compilaremos las bibliotecas estáticas en static-libs-source:
mkdir static-libs-source
cd static-libs-source
Descargar y compilar 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 ..
Descargar y compilar 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 ..
Descargar el código fuente de Zabbix y compilar el agente:
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