Compile and Install Zabbix Agent on FreeBSD 12

|
Last Updated:
|
|

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 zabbix

Next, 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 no

Consult 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 wget

Create Zabbix downloads directory

mkdir /tmp/zabbix

Next, 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/zabbix

Extract Zabbix Agent Source Code

Once the download completes, navigate to the download directory and extract the Zabbix source code.

cd /tmp/zabbix
tar 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.6

To build Zabbix as the agent and and install Zabbix client utilities, pass the --enable-agent option to the configure script.

./configure --enable-agent

After that, compile and install Zabbix agent.

make install

Configure 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.conf

Set 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.com

Set the LogFile directory to /var/log/.

LogFile=/var/log/zabbix_agentd.log

Save 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.log
chown zabbix:zabbix /var/log/zabbix_agentd.log

Next, 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_agentd

Start Zabbix Agent service on FreeBSD

service zabbix_agentd onestart

If 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.conf

You can then start Zabbix Service as;

service zabbix_agentd start

If 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

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment