This document describes the requirements and steps to create a Zabbix proxy host.
Figure 1: (Demo) project structure |
In the above image (Figure 1) the project structure is displayed, this is to get a full view and understanding of what will be built in the next chapters.
The Zabbix master will communicate with the Ubuntu host using port 10050
and 10051
on the UDP protocol. The proxy host itself will be running three services;
These services are internally connected and will communicate with each other.
The Zabbix
could and possible will be monitord by the local Zabbix proxy, but that would be an issue when the host itself goes offline. There for the Zabbix agent shall also be connected to the original Zabbix master.
Before hardware can be purchased, there needs to be knowledge about the needs of a basic Zabbix configuration. Therefore, in the next subchapter, the steps to configure a Zabbix proxy are documented. That way, once the virtual machine is configured, the machine can be diagnosed for its resource usage.
Before any form (server, proxy, agent) of Zabbix can be installed the public Zabbix repository is required on the target host.
This can be installd using the following commands (for Ubuntu distro):
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo apt update
sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.debsudo apt-get update
The above commands do the following;
Chapter Source
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget –quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-13 postgresql-doc-13
Enable Postgresql (start on system startup):
sudo systemctl enable postgresql.service
Login as default postgres user (sudo -i -u postgres
) or create new user form current account.
sudo -u postgres createuser --interactive
Postgres user creation |
Creating a database:
sudo -u postgres createdb zabbix_proxy
Postgres database added |
Granting user delaware all privileges on the created database (zabbix_proxy):
GRANT ALL PRIVILEGES ON DATABASE zabbix_proxy TO delaware;
Postgres grant all privileges to user |
Note: The Postgresql version used here (13) is to be compatible with Zabbix 6.0! If a newer version is available and compatible with the latest Zabbix version, installation steps maybe different!
Chapter Source
Because the database engine is Postgresql and already installed we can perform the following command;
sudo apt install zabbix-proxy-pgsql
(These two commands need to be preformed seperately, otherwise this will result in one of the two not installing properly!)
sudo apt install zabbix-sql-scripts
This will install the Zabbix-proxy and its packages.
The last command will import the Zabbix schema in to the just created database.
sudo cat /usr/share/doc/zabbix-sql-scripts/postgresql/proxy.sql | psql -U delaware zabbix_proxy
Result when command whas successfull |
Once the schema has been imported, the trap-receiver needs to be installed. The trap-receiver will make sure there is active monitoring instead of passive monitoring.
This means that once there is a change on the monitored devices a trap is sent with a change allert to the zabbix-proxy. This is more efficient than constantly polling all devices for any changes.
sudo wget https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/misc/snmptrap/zabbix_trap_receiver.pl -O /usr/bin/zabbix_trap_receiver.pl
sudo chmod a+x /usr/bin/zabbix_trap_receiver.pl
Note: the $SNMPTrapperFile value in the zabbix_trap_receiver pearlscript needs be the same as the SNMPTrapperFile path in the zabbix_proxy.conf (value there will be "/tmp/zabbix_traps.tmp")
Snmptrapd is an SNMP application that receives and logs SNMP TRAP and INFORM messages
sudo apt install snmp
sudo apt install snmp-mibs-downloader
sudo apt install snmptrapd
sudo apt install snmptt
Edit the snmptrapd configuration (sudo vim etc/snmp/snmptrapd.conf) and add the following:
authCommunity execute DLWReadOnly
perl do "/usr/bin/zabbix_trap_receiver.pl";
Save, restart and check snmptrapd status:
service snmptrapd restart
service snmptrapd status
Enable the service to start on system startup:
systemctl enable snmptrapd
Once the database is created and schema importedand all previous steps where successfull, the file zabbix_proxy.conf
needs to be configured to match our database properties.
sudo vim /etc/zabbix/zabbix_proxy.conf
Server=zabbix.gsinet.be
LogFileSize=1024
DebugLevel=3
Hostname=system.hostname
DBUser=zabbixadmin
DBPassword=<ZABBIX PROXY SQL SA ACCOUNT password>
ConfigFrequency=60
SNMPTrapperFile=/tmp/zabbix_traps.tmp
StartSNMPTrapper=1
Timeout=30
Once that is finished the Zabbix proxy can be startd/restarted.
sudo systemctl restart zabbix-proxy
sudo systemctl enable zabbix-proxy
Zabbix proxy service up and running |
Once the proxy is installed the agent needs to be installed.
sudo apt install zabbix-agent
Configuring the agent:
sudo vim /etc/zabbix/zabbix_agentd.conf`
Server=gsi-em-az1-0047.gsinet.be
Hostname=system.hostname
Restart service:
sudo systemctl restart zabbix-agent
Enable start on system startup:
sudo systemctl enable zabbix-agent
To check if the installation and configuration was successfull, you can view the log files of the proxy and agent. If both do not give any error messages the configuration is correct.
Example of log files with a good configuration:
zabbix_proxy.log:
Command tail -f /var/log/zabbix/zabbix_proxy.log |
zabbix_agentd.log:
Command tail -f /var/log/zabbix/zabbix_agentd.log |
To monitor an Ubuntu server in Zabbix there needs to be an SNMP configuration accordingly. In chapter 3.1 we installed all required packages for SNMP.
In the full configuration file, we changed the rocommunity secret to testProxyServer and the agentAddress to 'udp:161'. This means the SNMP service will be accessible from all IP-addresses when they provide the right secret (testProxyServer).
On the Zabbix interface, we then add a host with a macro provided. This macro is called "{$SNMP_COMMUNITY}" and corresponds to the secret defined 'testProxyServer'.
If all when well the host is available via SNMP:
Full configuration file (snmpd.conf):
https://www.jeffgeerling.com/blog/2020/how-flash-raspberry-pi-os-compute-module-4-emmc-usbboot
Source of documentation.
Update system:
sudo apt-get update
Upgrade system:
sudo apt-get upgrade
Check installed python3 version (if installed):
python3 -V
Install python-pip:
sudo apt-get install python3-pip
Install selenium using pip:
pip3 install selenium
Download zip package with driver:
wget https://chromedriver.storage.googleapis.com/102.0.5005.61/chromedriver_linux64.zip
Beware of the driver version! All versions can be found here: https://chromedriver.storage.googleapis.com/index.html
Unzip zip file:
unzip chromedriver_linux64.zip -d drivers/
Creation of folder to save scripts:
sudo mkdir webchecks
Create file with script:
touch wikiCheck.py
Install chrome:
sudo apt-get install google-chrome-stable
The chrome driver will not work if chrome it self is not installed! Also do not forget to mention the driver location in your script!
After all this you can run the script;
python3 wikiCheck.py
200 is pritend because there is a print statement defined in the script. This gives an indication that the site being tested is UP and running and in turn our test has completed successfully!
When the configuration is succesfull the agent looks like the following;
When the configuration is succesfull the proxy looks like the following;