Mac OS X – Install Zabbix Agent from Source

This isn’t too complicated, so let’s try to keep this short and sweet. In my case, I was installing version 2.4.7 of the Zabbix Agent at the time, but I’ve made it to where you can download the current version of the source if you want.

  • From the Apple developer website, download and install both the XCode and Command Line Tools package for your exact version of Mac OS.
  • If you don’t already have this directory or somewhere you want to build the software, create it at the terminal and change into the directory.
    sudo mkdir /usr/local/src
    sudo cd /usr/local/src
  • You can download the latest version of the Zabbix source like this:
    sudo curl -L "https://sourceforge.net/projects/zabbix/files/latest/download?source=files" -o "zabbix-cur.tar.gz"
  • Untar and change into directory substituting your directory name here
    sudo tar -zxvf zabbix-2.4.7.tar.gz
    sudo cd zabbix-2.4.7
  • Build it
    sudo ./configure --prefix=/usr/local --enable-agent --enable-ipv6 && sudo make install
  • Edit the config file and insert the IP Address of your Zabbix server and set your Hostname
    sudo nano /usr/local/etc/zabbix_agentd.conf
  • Create user account
    sudo dscl . -create Users zabbix
  • Append next available UniqueID to account
    sudo dscl . -append Users/zabbix UniqueID $(dscl . -list /Users UniqueID | awk 'BEGIN{i=0}{if($2>i)i=$2}END{print i+1}')
  • I’m not sure if this was always the case, but in older versions of Mac OS, I think the PrimaryGroupID was automatically created, but maybe I am wrong. At least on Mac OS version 10.10.5 Yosemite and above, it doesn’t create a PrimaryGroupID key automatically. If you don’t do this step, you will get an “illegal username” error when you try to set ownership on files later.
    sudo dscl . -append Users/zabbix PrimaryGroupID $(dscl . -read Users/zabbix UniqueID | awk '{ print $2 }')
  • Hide the user account
    sudo dscl . -append Users/zabbix IsHidden 1
  • Create the group
    sudo dscl . -create Groups zabbix
  • Get the next available PrimaryGroupID
    Please see my comment at the end of the post about this line.

    sudo dscl . -append Groups/zabbix PrimaryGroupID $(dscl . -list /Groups PrimaryGroupID | awk 'BEGIN{i=0}{if($2>i)i=$2}END{print i+1}')
  • Add group membership
    sudo dscl . -append Groups/zabbix GroupMembership zabbix
  • Set directory permissions
    sudo chown zabbix:wheel /usr/local/bin/zabbix*
    sudo chown zabbix:wheel /usr/local/etc/zabbix*
    sudo chown zabbix:wheel /usr/local/sbin/zabbix*
  • Create the following file
    sudo nano /Libray/LaunchDaemons/com.zabbix.zabbix_agentd.plist
  • Paste this 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>com.zabbix.zabbix_agentd</string>
                <key>RunAtLoad</key>
                <true/>
                <key>KeepAlive</key>
                <dict>
                        <key>SuccessfulExit</key>
                        <false/>
                </dict>
                <key>ProgramArguments</key>
                <array>
                        <string>/usr/local/sbin/zabbix_agentd</string>
                        <string>-c</string>
                        <string>/usr/local/etc/zabbix_agentd.conf</string>
                </array>
        </dict>
        </plist>
  • Launch the daemon
    sudo launchctl load /Library/LaunchDaemons/com.zabbix.zabbix_agentd.plist
  • Check and make sure the daemon is running
    ps aux | grep zabbix

2 Replies to “Mac OS X – Install Zabbix Agent from Source”

  1. It looks like System Integrity Protection (SIP) may be preventing this from working from the current install directory in El Capitan. Still looking into this at the moment.

  2. I realized after the fact that the IsHidden attribute does not work for groups. So, if your next available GID that it pulls using the method listed above is above 500, that group is able to be viewed inside the Users and Groups in the System Preferences. You would probably want to issue this command

    dscl . -list /groups PrimaryGroupID | awk '{print $2}' | sort -n

    to view all current GIDs on the system and then select the next available one below 500.

Leave a Reply