Zabbix on macOS(Draft)

Zabbix on Mac

For some reasons, I needed to prepare and run a monitoring service(both server and agent) which runs on Mac (and Linux). I found Zabbix and Nagios are one of the best choices, and I chose Zabbix this time.

Per my quick check, it is very easy to setup an agent on macOS, but not so easy on server side. So I ended up setting up a Zabbix server and its related components(Web, DB servers) using Docker.

In Short,

  • Use Docker for Server (and related components, Web, DB Servers)
  • Use HomeBrew for Agent


  • Homebrew
  • Docker for Mac

Configure and Run Zabbix Server using Docker

You can configure/setup Zabbix and its related components/containers individually, but I’d suggest to use Docker Compose to handle everything needed to run Docker Server/Service.

Prepare docker-compose.yaml file in the directory of your choice, then run containers using docker-compose.

version: '2'
    image: monitoringartist/zabbix-db-mariadb
      - zabbix-db-storage:/var/lib/mysql
      - backups:/backups
      - /etc/localtime:/etc/localtime:ro
      - MARIADB_USER=zabbix
      - MARIADB_PASS=my_password
    image: monitoringartist/zabbix-3.0-xxl:latest
      - zabbix-db
      - "80:80"
      - "10051:10051"
      - /etc/localtime:/etc/localtime:ro
      - zabbix-db:zabbix.db
      - ZS_DBHost=zabbix.db
      - ZS_DBUser=zabbix
      - ZS_DBPassword=my_password
    driver: local
    driver: local
Run Zabbix server
$ docker-compose up -d # -d option indicates that the containers are run in detached mode/background


Install and Run Zabbix Agent on macOS

Install Zabbix Agent

Install Zabbix
$ brew install zabbix

This does install all the zabbix components, incl Server, Proxy, and Agent.
If you only need to install Zabbix Agent on a target system, you can do,

Install Zabbix Agent
$ brew install --agent-only zabbix # Zabbix 2.x
$ brew install --without-server-proxy zabbix  # Zabbix 3.x

Run Zabbix Agent

You can run Zabbix Agent simply by doing,

Run Zabbix Agent from Command Line
$ /usr/local/sbin/zabbix_agentd

But this is only for 1 time run, and we want it to be started automatically when the system is rebooted, so it’s better to prepare an init script for the agent.

With the init script, you can start/stop the agent manually, or from any service management systems, such as, initd, systemd, launchd.

Traditional Unix init script style
case $1 in
    $agentd -c $conf;;
    kill -TERM `cat $pid`;;
    $0 stop
    sleep 10
    $0 start
    echo "Usage: $0 start|stop|restart"
    exit 1

Or if you like it to be more macOS-ish(but too traditional/obsoleted actually tho),

StartupItems style (obsoleted)
. /etc/rc.common
StartService() {
        $AGENTD -c $CONF
StopService() {
     kill -TERM $(GetPID $program)
RestartService() {
    sleep 3
RunService "$1"


Save the above script then run

start/stop zabbix_agentd using init script
# Assuming the saved script name is "zabbix_agent".
$ zabbix_agent start
$ zabbix_agent stop
$ zabbix_agent restart 

As described above, using a shell script to start/stop/restart a service, is not the officially recommended way for macOS, so if you like, please consider preparing plist and use launchctl[d].

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s