Zabbix 3.0 agent on FreeBSD

As you may have noticed: the folk at this blog recently started to play around with FreeBSD (mainly as FreeNAS jails). And since I recently started to <3 Zabbix. Here is an explanation on how to compile and use the agent on such a jail. First you need to give the jail certain privileges. So log into the FreeNAS web admin-interface and add allow.sysvipc=1 to the (comma separated) list of Sysctls under Jails > JAILNAME > Edit > Advanced Mode (if you make a mistake in that field, the jail won't start up anymore without any helpful log message afait). Then log into the jail via SSH and create a user and group for zabbix:
pw groupadd zabbix
pw useradd zabbix -c "Daemon user for Zabbix agent" -d /nonexistent -s /usr/sbin/nologin -w no -g zabbix
This is necessary, because all Zabbix daemon, that are started as a privileged user, will automaticcaly drop to a user account named zabbix. Then download the Zabbix Source code (I used zabbix-3.0.5.tar.gz), unpack it and compile it:
./configure --enable-agent --with-gnutls
make install #grabacoffee
I'm using Zabbix authentication. If you don't want that, you don't need the switch --with-gnutls. Finally, configure the Zabbix agent as normally (configuration file is located at /usr/local/etc/zabbix_agentd.conf) and add zabbix_agentd_enable="YES" to /etc/rc.conf after creating a file /etc/rc.d/zabbix_agentd with the following content:

# PROVIDE: zabbix_agentd
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to
# enable zabbix_agentd:
# zabbix_agentd_enable (bool): Set to NO by default.  Set it to YES to
#         enable zabbix_agentd.

. /etc/rc.subr


# read configuration and set defaultsc
load_rc_config "$name"
: ${zabbix_agentd_enable="NO"}
#: ${zabbix_agentd_pre:=/usr/local/etc/${name}}

if [ ! -z "$zabbix_agentd_conf" ] ; then
        zabbix_agentd_flags="${zabbix_agentd_flags} -c ${zabbix_agentd_conf}"

        if [ ! -z "$zabbix_agentd_pre" ] ; then
                if [ -e $zabbix_agentd_pre ] ; then
                        . $zabbix_agentd_pre



run_rc_command "$1"

Leave a Reply

Your email address will not be published. Required fields are marked *