RPi

Installation of a Zabbix Proxy (RPi)

Throughout the below guide I will step you through how to set up a Zabbix Proxy service on a Raspberry Pi.

The guide will assume that you have already flashed the RPi SD Card with the latest version of Raspbian without the recommended software, however, not the lite version. At the time of writing this guide, it was Buster and can be downloaded from here: https://downloads.raspberrypi.org/raspbian_latest

So without any further information, let’s get started…

Step 1: Setup the RPi SD Card with Raspbian (see notes above) and then connect the RPi.

Step 2: Go through the initial setup prompts as follows:

  • Country – Australia
  • Timezone – Melbourne

Step 3: Open up Terminal and run the following commands to open the Raspi-Config Window.


sudo su
raspi-config

Step 4: Change the following options under the menu that comes up:

  • Network Options
    • Hostname = XXXXYYCNM01
    • Network Interface Names = On
  • Boot Options
    • Desktop / CLI – Desktop (No Autologon)
    • Wait for Network Boot = Yes
  • Interface Options
    • SSH = Enable
    • VNC = Enable
    • One other… (TO BE ADDED TO THIS GUIDE).

Step 5: Setting Proxy Settings for the APT service of the RPi.


cd /etc/apt/apt.conf.d/
nano 10proxy

Then paste in the below code (changing the port to suit your site)…


Acquire::http::Proxy "http://mdmproxy:9901";

Press Control + X then Y then Enter to save and close the file.

Step 6: Setting Proxy Settings for the WGET service of the RPi.


cd /etc/
nano wgetrc

Then scroll down in the file which is displayed. You need to then uncomment and set the following values (changing the port to suit your site):


https_proxy = http://mdmproxy:9901/
http_proxy = http://mdmproxy:9901/

Step 7: Setting up the Network Adaptor to have the correct DHCP and IP settings:


nano dhcpcd.conf

Then scroll down to the bottom of the file and uncomment and set the following values:


#define static profiles
 profile static_eth0
 static ip_address=10.138.128.101/22
 static routers=10.138.132.1
 static domain_name_servers=10.138.128.50 10.138.128.21 10.10.22.11 10.10.22.12
# fallback to static profile on eth0
 interface eth0
 fallback static_eth0

Step 8: Installation of the Zabbix Service. Making sure to type the commands in the following order:


cd /
wget https://repo.zabbix.com/zabbix/4.2/raspbian/pool/main/z/zabbix-release/zabbix-release_4.2-1+buster_all.deb
dpkg -i zabbix-release_4.2-1+buster_all.deb
apt update
apt install zabbix-proxy-mysql

Step 9: Setup the MySQL Database (The root password is black, so when prompted just press enter).


mysql -uroot
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
quit;

cd /usr/share/doc/zabbix-proxy-mysql/
zcat schema.sql.gz | mysql zabbix

Step 10: Verify that the Database is configured correctly.


mysql -uroot -p
show databases;   (Verify that there is a database called ‘zabbix’)
use zabbix;
show tables;   (Verify that there are a list of database tables listed)
quit;

Step 11: Change the Zabbix Proxy Configuration Files.


cd /
nano /etc/zabbix/zabbix_proxy.conf

Uncomment and set the following values;


Server=monitor.jamesmutch.tech
Hostname=XXXXYYCNM01
EnableRemoteCommands=1
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ProxyOfflineBuffer=24
HeartbeatFrequency=30
ConfigFrequency=1800
CacheSize=32M
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=XXXXYYCNM01
TLSPSKFile=/home/zabbix/secret.psk

Press Control + X then Y then Enter to save and close the file.

Step 12: Next you need to create a PSK File on the Zabbix Server Instance and copy to the Proxy for encrypted communications. This can be completed with the following instructions.


cd /zabbix-psk-keys/
openssl rand -hex 32 > XXXXYYCNM01.psk
cat XXXXYYCNM01.psk

The last command that you ran will show you the contents of the file, which you can then use below…

Step 13: Step the PSK File on the Zabbix Proxy RPi by running the following commands.


cd /home/
mkdir zabbix
cd ./zabbix/
nano secret.psk

You then need to paste in the PSK string and then press Control + X then Y then Enter to save and close the file.

Step 14: Secure the PSK File so that it can only be accessed by Zabbix services by running the following commands.


chown zabbix:zabbix secret.psk
chmod 640 secret.psk

Step 15: Next we need to add this Zabbix Proxy to the Central Zabbix Server so that it will accept communications from the Proxy. You can do this on the Zabbix Central Server’s Web Interface.

  • Go to: https://Monitor.JamesMutch.TECH
  • Administration -> Proxies -> Create Proxy (Top RHS).
  • Enter the following details on the Proxy tab:
    • Name: XXXXYYCNM01
    • Proxy Mode: Active
    • Proxy Description: Horsham Primary School – 298 Campus (554801)
  • Enter the following details on the Encryption tab:
    • Connections from Proxy: Make sure than only PSK is ticked.
    • PSK Identity: XXXXYYCNM01
    • PSK: Enter in the contents of the PSK File we created earlier on the server.
  • Click Add.

Step 16: Back on the Zabbix Proxy we will now start the Zabbix Proxy Service.


cd /
service zabbix-proxy start
systemctl enable zabbix-proxy
service zabbix-proxy status (You should now see that it's running)
tail -f /var/log/zabbix/zabbix_proxy.log

A log file will now be displayed and you should see the following lines:


Connection restored or something to that degreee
Received configuration data from server at "monitor.jamesmutch.tech"

Press Control + Z to exit the log as your Zabbix Proxy has now received it’s configurations and started monitoring the devices it has been told to monitor.

I would recommend that you now proceed to set up the Zabbix Agent Service on the RPi so that you can monitor that device. To complete that, proceed with this guide.

Step 17: To Install the Zabbix Agent Service, type in the following commands.


cd /
apt install zabbix-agent

Step 18: We now need to set up the Zabbix Agent Service Configurations by typing.


nano /etc/zabbix/zabbix_agentd.conf

Uncomment and set the following values;


EnableRemoteCommands=1
Server=127.0.0.1
Hostname= XXXXYYCNM01
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=XXXXYYCNM01
TLSPSKFile=/home/zabbix/secret.psk

Press Control + X then Y then Enter to save and close the file.

Step 19: Starting the Zabbix Agent Service with the following commands.


cd /
service zabbix-agent start
systemctl enable zabbix-agent
service zabbix-agent status (You should now see that it's running)
tail -f /var/log/zabbix/zabbix_agentd.log

A log file will now be displayed and you should see the following lines:


Agent Started

Press Control + Z to exit the log as your Zabbix Agent service has now started and awaiting monitoring by the Zabbix Proxy.

Step 20: Next we need to add this Zabbix Agent (Host) to the Central Zabbix Server so that it will ask the Zabbix Proxy Service to monitor this host. You can do this on the Zabbix Central Server’s Web Interface.

  • Go to: https://Monitor.JamesMutch.TECH
  • Configuration -> Hosts -> Create Host (Top RHS).
  • Enter the following details on the Host tab:
    • Name: XXXXYYCNM01
    • Groups: Zabbix Servers
    • Agent Interfaces: 127.0.0.1 (As this device is going to be monitoring itself)
    • Monitored by Proxy: Select the site proxy server from the drop-down.
  • Enter the following details on the Templates tab:
    • Link new Templates:
      • Template App Zabbix Proxy
      • Template DET Central Services
      • Template OS Linux
    • Click on the little blue Add button below the list to add the templates to the host.
  • Enter the following details on the Inventory tab:
    • Select Automatic in the top options.
  • Enter the following details on the Encryption tab:
    • Connections to host: PSK
    • Connections from host: Make sure than only PSK is ticked.
    • PSK Identity: XXXXYYCNM01
    • PSK: Enter in the contents of the PSK File we created earlier on the server.PSK
  • Click the Add button along the button to add the Host to Zabbix.

Step 21: As we will want to be monitoring switches and peripherals via SNMP, back on the Zabbix Proxy we need to run the following commands.


cd /
apt-get install snmp snmp-mibs-downloader

CONGRATULATIONS

You have now completed the installation of the Zabbix Proxy and Zabbix Agent services on the RPi and have successfully added these to the Zabbix Central Server for monitoring.

Extra Notes

Proxy Cache Reload – As the Zabbix Proxy only reloads it’s configurations from the Zabbix Central Server once in a 30-minute window, if you have made changes to configurations on the central server’s Web UI, it can take up to 30 mins to take effect on the proxy. If you would like to make the change effective immediately, just run the following command on the Zabbix Proxy RPi.


zabbix_proxy -R config_cache_reload

Installation of SMB File Server on RPi – It is extremely helpful in the installation of Zabbix Agent to servers across the network to have an Open File Server which does not require credentials to access files/run programs. I have accomplished this through the use of SAMBA Server Service on RPi’s. I have created a guide to install this on the same device as your Zabbix Proxy, you can find this guide here… Setting up Samba on an RPi

Installation of other Agents – You can install a range of Agents on Windows, Linux and Apple Devices to allow your proxy service to monitor and collate information, problems and data. I have created a guide to Bulk-Deploy the Zabbix Agent to Windows Devices via Group Policy and will link that guide here soon.

Additional Questions or Support – If you have any questions or need support with implementing this in a VIC GOV DET Site, please feel free to leave a comment below and I will assist wherever I can. For additional support on the Zabbix Proxy/Agent/Server Instances, check out the Zabbix Website at: https://www.zabbix.com/

As always, thanks for looking through this guide and until next time happy learning!

Comments: