Zabbix Agent Install

Jump to: navigation, search

This page provide basic instructions for installing Zabbix Agent 3.0 LTS from source on OpenSUSE 42.3. Will probably work on more versions.

Add user and group

First add user and group to run the zabbix-agent as.
Note: run this as root (sudo -i) or add sudo in front of every command.

groupadd zabbix
useradd -g zabbix zabbix


Install dependencies

Install dependencies to be able to compile the source

zypper in gcc-c++ libopenssl-devel make


Download source

Download the source from Zabbix.com under "Zabbix Sources" (https://www.zabbix.com/download)

wget https://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.10/zabbix-3.0.10.tar.gz

and the extract it.

tar xvf zabbix-3.0.10.tar.gz

and enter that directory.


Compiling

Start to compile

./configure --enable-agent --with-openssl

After the exited without any errors

make install


Edit the configuration

Edit the Zabbix-agent configuration file to suit your setup.
Here i will set it up as an active only agent with Pre-Shared-Key as encryption.

vim /usr/local/etc/zabbix_agentd.conf

Change/add/uncomment the following:

- LogFile=/var/log/zabbix/zabbix_agentd.log
- Server=<zabbix server>
- StartAgents=0
- ServerActive=<zabbix server>
- Hostname=<hostname>
- User=zabbix
- TLSConnect=psk 
- TLSAccept=psk
- TLSPSKIdentity=<hostname>
- TLSPSKFile=/usr/local/etc/zabbix_agentd.psk

Create the .psk file.

openssl rand -hex 32 > /usr/local/etc/zabbix_agentd.psk

We moved the location of logfile, so we need to create a folder for it

mkdir /var/log/zabbix
chown root:zabbix /var/log/zabbix
chmod 775 /var/log/zabbix


Add SystemD startup

Create the systemd .service file

vim /etc/systemd/system/zabbix-agentd.service

Enter this:

[Unit]
Description=Zabbix Agent 3.0 LTS
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/usr/local/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
KillMode=control-group
ExecStart=/usr/local/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s

[Install]
WantedBy=multi-user.target

Reload daemons, enable and start

systemctl daemon-reload
systemctl enable zabbix-agentd
systemctl start zabbix-agentd

Check that the service is running OK

tail /var/log/zabbix/zabbix_agentd.log

Should look something like this

Starting Zabbix Agent [<hostname>]. Zabbix 3.0.10 (revision 70208).
**** Enabled features ****
IPv6 support:           NO
TLS support:           YES
**************************
using configuration file: /usr/local/etc/zabbix_agentd.conf
agent #0 started [main process]
agent #2 started [active checks #1]
agent #1 started [collector]

All done!


Reference