Monday, February 2, 2015

How to compile Zabbix agent on OSX Yosemite 10.10.3

So, after much debate, and a lot of searching, I couldn't turn up a reliable way to install a binary of the latest version of the zabbix agent on OSX (OS X) Yosemite 10.10.3.  The following is the quick approach I took and it works beautifully.

First, install xcode.  I know, groans abound, but it's required so just do it unless you feel like you want to trust my binaries. Secondly, grab the zabbix source code, it's free and relatively small.

Next, follow the sequence of steps exactly, it is easy, fast and relatively pain-free.  From a shell as an administrative user:

Install command-line tools:

user:Downloads user$ xcode-select --install

Untar/uncompress the latest tarball (2.4.5)

user:Downloads user$ tar -zxvpf zabbix-2.4.5.tar.gz

Switch to the tarball directory

user:~ user$ cd zabbix-2.4.5

Run the configure script with the --enable-agent switch

user:zabbix-2.4.5 user$ ./configure --enable-agent

Make the executable

user:zabbix-2.4.5 user$ make

Make the necessary local directories

user:zabbix-2.4.5 user$ sudo mkdir -p /usr/local/etc /usr/local/sbin

Copy the configuration file to the local etc directory

user:zabbix-2.4.5 user$ sudo cp ./conf/zabbix_agentd.conf /usr/local/etc/

Copy the daemon file to the local sbin directory

user:zabbix-2.4.5 user$ sudo cp ./src/zabbix_agentd /usr/local/sbin

Edit the agent daemon file (beyond the scope of this document)

user:zabbix-2.4.5 user$ vi /usr/local/etc/zabbix_agentd.conf

Start the agent, and enjoy!

user:zabbix-2.4.5 user$ /usr/local/sbin/zabbix_agentd

I'm working on a clean way to install this as a system daemon and should have that done very soon, as well as a script that automates the entire process, save for the XCode installation.  There is also a 'make install' target, I just wasn't sure what that was going to do, so I'd rather do it manually for the time being.  I'll update this space as I have time soon!


  1. This comment has been removed by the author.

  2. Hey Steph.
    Great article. works like a charm.
    We are seeing some issues though, we push this out to macs in our lab using puppet. Every now and again. the dies, but listeners are still up and running.
    Nothing really in the log file during the even the zabbix_agentd dies either.
    trying to restart using /usr/local/sbin/zabbix_agentd without manually killing all the listeners results in this in the log

    Starting Zabbix Agent [Host123]. Zabbix 2.2.9 (revision 52686).
    using configuration file: /usr/local/etc/zabbix_agentd.conf
    listener failed: bind() for [[-]:10050] failed: [48] Address already in use

    any thoughts and or comments would be appreciated.

    1. Hey Eric, thanks for the feedback. I don't know if I'll be able to reproduce the error or not, but for sure it's trying to re-bind to the same address/port where the listener is attached. I'm pretty sure you'll have to manually kill the listeners. I've not checked, but is there a switch to increase logfile verbosity?

  3. The command "make install" also needs to run. Also the daemon must be ran as non-root user. When trying to execute it as root I get:
    sh-3.2# /usr/local/sbin/zabbix_agentd
    zabbix_agentd [14438]: user zabbix does not exist
    zabbix_agentd [14438]: cannot run as root!
    sh-3.2# ls -l !$

  4. Hi Steph any idea why i get permission denied when i try to run the agent file

    1. Hi Terry, what user are you trying to run as? (/usr/bin/id -pa)

    2. This comment has been removed by the author.

    3. When i try to run as normal user

      CAA-AAIT-S122:~ tlm5410a$ /usr/local/sbin/zabbix_agentd
      CAA-AAIT-S122:~ tlm5410a$ zabbix_agentd [1099]: cannot open [usr/local/etc/zabbix_agentd.log]: [13] Permission denied

      second attempt when trying to run as sudo
      CAA-AAIT-S122:~ tlm5410a$
      CAA-AAIT-S122:~ tlm5410a$
      CAA-AAIT-S122:~ tlm5410a$ sudo /usr/local/sbin/zabbix_agentd
      zabbix_agentd [1104]: user zabbix does not exist
      zabbix_agentd [1104]: cannot run as root!
      CAA-AAIT-S122:~ tlm5410a$

    4. Hey Terry -- the error is that /usr/local/etc/zabbix_agentd.log does not have write permissions by the user executing it (tlm5410a). Try setting the log file to /var/log or to /tmp/zabbix_agentd.log and it should work!

      It will be in /usr/local/etc/zabbix_agentd.conf

      look for this line: 'LogFile=/tmp/zabbix_agentd.log'

      Make sure that file doesn't already exist, or if it does, is writeable by your user.

  5. This comment has been removed by the author.

  6. Hi steph. This article is what I was looking for for a long time.
    I'll give it a go on my Mac, with version 3beta of Zabbix.
    And I'll post back a comment.
    Thank you very much for sharing.
    (in my opinion, it is a shame that zabbix doesn't have a binary distribution of the agent for Mac...)

  7. Good morning,

    I just wanted to say that, although I am not a developper at all, I succeeded in compiling the agent on my Mac, and it starts sucessfully.
    Many thanks for the very simple et effective article.

  8. Anyway to get this to start at boot? I have been messing around with a plist in /Library/LaunchDaemons but have not had any luck.

  9. This comment has been removed by the author.