Installing Zabbix Agent On MacOS

If you use Zabbix for monitoring your systems, and have any MacOS systems, you may be disappointed to find out that the precompiled binaries for zabbix_agent are not made available for download. Lucky for us setup of zabbix_agent on macos doesn’t need to be painful.

First we need to install homebrew. If you do not already have it installed, simply open the terminal and enter the following:

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

Next we can install the zabbix agent. Make sure you specify the –without-server-proxy to force the installer to only install the agent.

brew install zabbix --without-server-proxy

Brew will go on to install a bunch of stuff for us. Double check if any of the warnings apply to you.

==> Installing dependencies for zabbix: openssl, pcre
==> Installing zabbix dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_2.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs

and run
/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2o_2: 1,792 files, 12.2MB
==> Installing zabbix dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.42.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pcre-8.42.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/pcre/8.42: 204 files, 5.4MB
==> Installing zabbix --without-server-proxy
==> Downloading https://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz
==> Downloading from https://ayera.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/zabbix/3.4.11 --sysconfdir=/usr/local/etc/zabbix --enable-agent --with-iconv=/usr --with-libpcre=/usr/local/opt/pcre --with-openssl=/usr/local/opt/openssl
==> make install
🍺 /usr/local/Cellar/zabbix/3.4.11: 13 files, 1.4MB, built in 1 minute 8 seconds
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs

and run
/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

If everything went will you should have zabbix_agentd installed. The setup also installs zabbix_get and zabbix_sender for you as well.

Next you will need to edit the /usr/local/etc/zabbix/zabbix_agentd.conf.

You can now start the agent by issueing the following command at the terminal

/usr/local/sbin/zabbix_agentd

After you have set the zabbix_agent the way you want, you will need to build a .plist file so that you can set the agent to start on boot.  The zabbix_agent does not like to launch as root, so in System Preferences, go to Users & Groups and create a Standard user. called “zabbix_agentd” with no home directory or password or email.

sudo nano /Library/LaunchDaemons/org.zabbix.zabbix_agent.plist

Paste the following information into the file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>org.zabbix.zabbix_agent</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/sbin/zabbix_agentd</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>UserName</key>
	<string>zabbix-agent</string>
</dict>
</plist>

You can now create your host in the zabbix web admin. What to do there is a topic for another day.

Hope this has helped you, let me know!

Leave a Reply