Installing Zabbix Agent (1.6.4) on Free BSD 7.1


Quick Introduction

This article is a HOWTO  to ease the pain of setting up a Zabbix Agent on Free BSD (7.1) Server.  Zabbix is a monitoring platform that has a server, proxy  and agent architecture. I really don’t want to get into an explanation of what Zabbix is or whether you should use it. Hopefully you should have already discovered its usefulness and just need to do a little installation. That said, you can read about it on their website

This HOWTO covers the installation of the Zabbix Agent from source. Please note: I am keeping it fairly general so I am not discussing all the options that you can shove in the Zabbix Agent Config File. Zabbix do that pretty well themselves in their quick starts and configuration guides



  • Root access of some sort to your Free BSD Server ( sudo or somesuch)
  • A working knowledge of Free BSD Administration


  • you have a working zabbix server
  • you know all the other fiddly config options
  • you have punched holes in your firewall to allow the server and agent to talk

Step by Step

Ok, get yourself a shell and go to the directory where you build software. It’s time to fetch the source code. For today’s little HOWTO I am going to use one of my FreeBSD Servers – dr.nick.

 dr# wget

Unpack your tarball

 dr# tar xzf zabbix-1.6.4.tar.gz

Pop into the unpacked directory

 dr# cd zabbix-1.6.4

This might seem a little out of order but I think you should create a zabbix user. The usual warnings apply so I will just pop the text from the Install guide here:

This is the user the Agent will run as. For production use you should create a
dedicated unprivileged account (‘zabbix’ is commonly used). Running ZABBIX
Agent as ‘root’,’bin’, or any other account with special rights is a security risk. Do
not do it!
 dr# adduser
 Username: zabbix
 Full name: zabbix agent
 Uid (Leave empty for default):
 Login group [zabbix]:
 Login group is zabbix. Invite zabbix into other groups? []:
 Login class [default]:
 Shell (sh csh tcsh bash rbash nologin) [sh]: bash
 Home directory [/home/zabbix]:
 Home directory permissions (Leave empty for default):
 Use password-based authentication? [yes]:
 Use an empty password? (yes/no) [no]:
 Use a random password? (yes/no) [no]:
 Enter password:
 Enter password again:
 Lock out the account after creation? [no]:
 Username   : zabbix
 Password   : *****
 Full Name  : zabbix agent
 Uid        : 1002
 Class      :
 Groups     : zabbix
 Home       : /home/zabbix
 Home Mode  :
 Shell      : /usr/local/bin/bash
 Locked     : no
 OK? (yes/no): yes
 adduser: INFO: Successfully added (zabbix) to the user database.
 Add another user? (yes/no): no

Now it’s time to configure and compile the agent. Yippy!

 dr# ./configure --enable-agent
( ........I took all the other gumf out from here........)
 Detected OS:           freebsd7.1
 Install path:          /usr/local
 Compilation arch:      freebsd
 Compiler:              gcc
 Compiler flags:        -g -O2
 Enable server:         no
 Enable proxy:          no
 Enable agent:          yes
 Linker flags:
 Libraries:             -lkvm -lm -ldevstat
 LDAP support:          no
 IPv6 support:          no

Looks good let’s build…. HANG ON … it broke on my install …. I didn’t get that far! OK, so if you didn’t get this far I can’t really help you.  dr.nick is a pretty vanilla install and it worked out of the box. From memory the only package I had to add was wget. You can email us here at KND and I can have a squiz for you, but that’s all I can do for now.

So as I was saying, on with the install:

dr# make install

You should a whole bunch of compilation stuff here – with no errors i hope. It’s time to get into the server configuration.

You don’t need to do the next step but I think it is a good idea.

Add the following lines to the /etc/services file:

zabbix_agent 10050/tcp
zabbix_trap 10051/tcp

Zabbix expects it’s config files in /etc/zabbix but I want to keep this install as BSD-like as possible. So let’s put the config in the right spot!

dr# mkdir /usr/local/etc/zabbix

There is an example config file that needs minimal hacking to get right

dr# cp (wherever the source code was unpacked)/misc/conf/zabbix_agentd.conf /usr/local/etc/zabbix/zabbix_agentd.conf

Open the zabbix agentd conf file /usr/local/etc/zabbix_agentd.conf

dr# vi /usr/local/etc/zabbix/agentd.conf

Change Pidfile value to:

PidFile=/var/run/ (This is a BSD Location)

Change Logfile value to:


Save the changes you have made. There is just a little housekeeping to do to ensure these changes work.

dr# touch /var/run/
dr# chown zabbix /var/run/
dr# touch /var/log/zabbix_agentd.log
dr# chown zabbix /var/log/zabbix_agentd.log

Now it’s time to put in an init script so that the Agent comes up on boot. The init script provided with the Zabbix source code is a bit janky. So you can use mine if you want.

# PROVIDE: zabbix-agent
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable zabbix-agent:
# zabbix_agent_enable (bool):      Set to "NO" by default.
#                             Set it to "YES" to enable zabbix-agent
# zabbix_agent_config (str):       Set to "" by default.
#                             Define your zabbix-agent configuration file here.
. /etc/rc.subr
load_rc_config $name
: ${zabbix_agent_enable="NO"}
: ${zabbix_agent_pidfile="/var/run/"}
: ${zabbix_agent_config="/usr/local/etc/zabbix/zabbix_agentd.conf"}
: ${zabbix_agent_flags="-c"}
[ -n "$zabbix_agent_config" ] && zabbix_agent_flags="$zabbix_agent_flags $zabbix_agent_config"
       run_rc_command stop
extra_commands="reload quit"
run_rc_command "$1"

Now add following line /etc/rc.conf, this let’s the system that we are ready to rock and also ensures that the agent will start on boot.


If have decided to put your config file somewhere else you can use the following rc variable. Otherwise don’t put it in at all.


Now it’s test time:

dr# /usr/local/etc/rc.d/zabbix-agent start
Starting zabbix_agent.

Better check that the agent is running:

dr# ps aux | grep zabbix
zabbix 91278  0.0  0.1  8812  1696  ??  IN    9:50PM   0:00.00 zabbix_agentd: main process (zabbix_agentd)
zabbix 91279  0.0  0.1  8812  1944  ??  SN    9:50PM   0:00.00 zabbix_agentd: main process (zabbix_agentd)
zabbix 91280  0.0  0.1  8812  1676  ??  IN    9:50PM   0:00.00 zabbix_agentd: main process (zabbix_agentd)
zabbix 91281  0.0  0.1  8812  1676  ??  IN    9:50PM   0:00.00 zabbix_agentd: main process (zabbix_agentd)
zabbix 91282  0.0  0.1  8812  1676  ??  IN    9:50PM   0:00.00 zabbix_agentd: main process (zabbix_agentd)
zabbix 91283  0.0  0.1  8812  1736  ??  SN    9:50PM   0:00.00 zabbix_agentd: poller [sleeping for 1 seconds] (zabbix_agentd)

Cool, now let’s make sure we can stop it.

dr# /usr/local/etc/rc.d/zabbix-agent stop
Stopping zabbix_agent.
Waiting for PIDS: 87712.

That’s it we are done. You saw my caveats about things going wrong, so if I can help you I will.

I will be adding a BSD Package for this in the not too distant future, so watch this space.


Related Articles