Welcome to our guide on how to compile and install Zabbix Agent on FreeBSD 12. We have covered the installation of Zabbix Agent using the PKG package manager in our previous guide.
Install Zabbix Agent on FreeBSD 12
Install Zabbix Agent on FreeBSD 12
Well, if you need to install zabbix agent on FreeBSD 12, this guide is for you.
Create Zabbix System Account
To run Zabbix daemon, you need an unprivileged system user account. Therefore, before you can proceed, ensure that zabbix system account is available. Run the command below to create the account.
Create Zabbix group
pw groupadd zabbixNext, create the zabbix system account with the above group being its primary group,
pw adduser zabbix -g zabbix -d /nonexistent -s /usr/sbin/nologin -w noConsult man adduser to learn more about command line options used above.
Download Zabbix Source Code
Navigate to Zabbix sources download page and grab the source code. You can simply get the download link and use wget command to download to the server.
pkg install wgetCreate Zabbix downloads directory
mkdir /tmp/zabbixNext, pull the agent to directory above.
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz -P /tmp/zabbixExtract Zabbix Agent Source Code
Once the download completes, navigate to the download directory and extract the Zabbix source code.
cd /tmp/zabbixtar xzf zabbix-4.2.6.tar.gz Installing Zabbix Agent on FreeBSD 12
The next step is to configure, compile and install Zabbix. This can be done as shown below.
cd zabbix-4.2.6To build Zabbix as the agent and and install Zabbix client utilities, pass the --enable-agent option to the configure script.
./configure --enable-agentAfter that, compile and install Zabbix agent.
make installConfigure Zabbix Agent
After the installation, the next step is to configure Zabbix agent so that it can communicate with the server. The Zabbix agent configuration file is /usr/local/etc/zabbix_agentd.conf.
Open the configuration file for editing;
vim /usr/local/etc/zabbix_agentd.confSet the Zabbix server IP for both the passive and active checks and Zabbix agent hostname.
...
Server=192.168.43.62 ## IP for Zabbix Server
...
ServerActive=192.168.43.62
...
Hostname=freebsd12.example.comSet the LogFile directory to /var/log/.
LogFile=/var/log/zabbix_agentd.logSave and quit the configuration file.
Next, create and set the user and group ownership of the Zabbix agent log file to zabbix.
touch /var/log/zabbix_agentd.logchown zabbix:zabbix /var/log/zabbix_agentd.logNext, copy the Zabbix agent service file located in the misc/init.d/freebsd/ of the source code directory to the startup directory.
cp misc/init.d/freebsd/zabbix_agentd /usr/local/etc/rc.d/Make the service startup script executable.
chmod +x /usr/local/etc/rc.d/zabbix_agentdStart Zabbix Agent service on FreeBSD
service zabbix_agentd onestartIf you need to enable Zabbix agent to run on system on boot, set zabbix_agentd_enable to YES in /etc/rc.conf.
echo 'zabbix_agentd_enable="yes"' >> /etc/rc.confYou can then start Zabbix Service as;
service zabbix_agentd startIf there is any firewall in between the Zabbix agent, open ports 10050 and 10051 which is used for both passive and active checks respectively.
Once you are done with Zabbix agent configuration, login to Zabbix server and add the host for monitoring.
Related Guides
Install Zabbix Agent on Debian 10 Buster
Install Zabbix Agent on FreeBSD 12
Install Zabbix Agent on CentOS 7 for Zabbix Monitoring
How to Install and Configure Zabbix 4.0 from Source on Fedora 29/Fedora 28/CentOS 7

