Network Monitoring with Zabbix

My home network is not the network normal people have.
I have 2 different locations which are booth equipped with Zyxel USG Firewalls and a Site-to-Site VPN. I do my Synology Backups into the other location or use the Smart Home over booth places. Often my mother in law (she is living in one of the locations too) is telling me that the network is not good. With this error message it is not very easy to discover the problem. Sometimes it is the internet itself but often it is the wifi or even her internet radio device (Bose Soundtouch) . After installing a RaspberryPi with the speedtest-cli its starting to get easier for me to discover if the internet is slow. But i want more 🙂 So I started to use Zabbix.
Zabbix is an Open-Source-Network-Monitoring-System. It is similar to Nagios but gives you the opportunity to manage everything over the web-interface. So my basic plans are:

  1. Install Zabbix on my Synology with Docker
  2. Install Zabbix Proxy on a RaspberryPi for the second location
  3. Create Backup from Zabbix Database

1 Install Zabbix on my Synology with Docker (via Terminal, if you want to do it with the GUI please follow this LINK. First you have to create the folders in the Folder „/volume1/docker/Zabbix/“. If you are using more than one Volume please make sure that you have the correct path. Create then Zabbix folder in the docker folder. Then download this folder-preset DOWNLOAD and load them into the Zabbix folder. Now you can access your Synology via SSH an copy following command.

sudo docker run -d --restart always --name Zabbix-Server -e PHP_TZ:Europe/Vienna -e ZBX_CACHESIZE=1000M -e ZBX_SERVER_NAME:VSZabbixServer -v /volume1/docker/Zabbix/alertscripts:/usr/lib/zabbix/alertscripts  -v /volume1/docker/Zabbix/externalscripts:/var/lib/zabbix/externalscripts  -v /volume1/docker/Zabbix/modules:/var/lib/zabbix/modules  -v /volume1/docker/Zabbix/enc:/var/lib/zabbix/enc  -v /volume1/docker/Zabbix/ssh_keys:/var/lib/zabbix/ssh_keys  -v /volume1/docker/Zabbix/ssl/certs:/var/lib/zabbix/ssl/certs  -v /volume1/docker/Zabbix/ssl/keys:/var/lib/zabbix/ssl/keys -v /volume1/docker/Zabbix/ssl/ssl_ca:/var/lib/zabbix/ssl/ssl_ca -v /volume1/docker/Zabbix/snmptraps:/var/lib/zabbix/snmptraps -v /volume1/docker/Zabbix/mibs:/var/lib/zabbix/mibs -v /volume1/docker/Zabbix/nginx:/etc/ssl/nginx -p 10052:443 -p 10050:80 -p 10051:10051 -d zabbix/zabbix-appliance:ubuntu-4.4-latest

Now you can login to the Zabbix Webinterface using the Synology IP and the port 10050
<Synology-IP>:10050

Username: Admin
Passwort: zabbix

Connecting to the Zabbix Docker via bash is able with following command:

docker exec -ti Zabbix-Server /bin/bash

Getting the logs with following

 docker logs Zabbix-Server

Backup the Database:
The most important settings are all stored in the Database. The easiest and most secure way to save them is to export all the Data at a specific time and store them on the Synology Raid. Please do not forget to follow this help LINK

Inhaltsverzeichnis

Zabbix PROXY

With a Zabbix Proxy you can monitore a network remote without having access to the lokal network from your Zabbix Server. If you are using hardware which can use Docker I would recommend to install it with this script DOWNLOAD. Then you can use following command. Do not forget to change
ZBX_HOSTNAME=“you have to set this name in the Zabbix Server too „
ZBX_SERVER_HOST=“IP Adress of the Zabbix Server“

docker run -d --restart always --name some-zabbix-proxy-sqlite3 -e ZBX_HOSTNAME=2100-BigMama-Proxy -e ZBX_SERVER_HOST=10.210.0.50 -d zabbix/zabbix-proxy-sqlite3:ubuntu-4.4-latest

If you want to use a RaspberryPi you have to install it without Docker. Here is my solution for a fast install including the setup for the agent Download
Do not forget to change
ZabbixDestinationServer=“10.210.0.50″
ZabbixProxyHostName=“2105-Proxy-01

#!/bin/bash
# automated install csript for zabbix 4.4 Install
# helped by https://znil.net/index.php/Raspberry_Pi_als_Zabbix-Proxy_-_Zabbix_Proxy_auf_Raspberry_Pi_mit_Raspbian_installieren
# check the client zabbix version with this link: https://repo.zabbix.com/
#Don't forget to change following:

hostname=$(hostname -s)
ZabbixDestinationServer="10.210.0.50"
ZabbixProxyHostName="2105-Proxy-01"

sudo apt install -y snmp-mibs-downloader
sudo wget https://repo.zabbix.com/zabbix/4.4/raspbian/pool/main/z/zabbix-release/zabbix-release_4.4-1%2Bbuster_all.deb
sudo dpkg -i zabbix-release_4.4-1+buster_all.deb
apt update
apt install -y zabbix-proxy-sqlite3 zabbix-agent zabbix-sender zabbix-get

#create RAM Disk
sudo echo "tmpfs /var/ramdisk tmpfs nodev,nosuid,relatime,size=100M 0 0" >> /etc/fstab
sudo mkdir -p /var/ramdisk
sudo chmod 0777 /var/ramdisk
sudo mount -a

#configure ProxyServer
sudo echo -e "Server=$ZabbixDestinationServer \nHostname=$ZabbixProxyHostName \nTimeout=30 \nEnableRemoteCommands=1 \nLogRemoteCommands=1 \nLogFile=/var/ramdisk/zabbix_proxy.log \nLogFileSize=4 \nDBName=/var/ramdisk/zabbixproxy.db" >> /etc/zabbix/zabbix_proxy.conf
sudo systemctl enable zabbix-proxy.service
sudo systemctl start zabbix-proxy
#LOG ls -l /var/ramdisk/

#confige Agent
#sudo sed -i 's/Server=127.0.0.1/Server='$ZabbixDestinationServer'/g' /etc/zabbix/zabbix_agentd.conf
sudo echo -e "Hostname=$hostname \nLogFile=/var/ramdisk/zabbix_agentd.log \nLogFileSize=1 \nTimeout=30 \nUnsafeUserParameters=1 \nEnableRemoteCommands=1 \nLogRemoteCommands=1" >> /etc/zabbix/zabbix_agentd.conf
sudo systemctl enable zabbix-agent.service
sudo systemctl start zabbix-agent.service
#LOG cat /var/ramdisk/zabbix_agentd.log

Zabbix Agent

You can easy install the Zabbix Agent on Linux (Ubuntu/Debian) machines by using following script
DOWNLOAD
Do not forget to change
zabbix_server=10.210.0.50

#!/bin/bash
# automated install script for zabbix agent
# helped by https://www.fontenay-ronan.fr/monitor-a-raspberry-pi-using-zabbix-agent-on-raspbian/
# check the client zabbix version with this link: https://repo.zabbix.com/
# Don't forget to change following:

hostname=$(hostname -s)
zabbix_server=10.210.0.50

sudo apt install -y zabbix-agent

sudo echo "tmpfs /var/ramdisk tmpfs nodev,nosuid,relatime,size=100M 0 0" >> /etc/fstab
sudo mkdir -p /var/ramdisk
sudo chmod 0777 /var/ramdisk
sudo mount -a

sudo sed -i 's/Server=127.0.0.1/Server='$zabbix_server'/g' /etc/zabbix/zabbix_agentd.conf
sudo echo -e "Hostname=$hostname \nLogFile=/var/ramdisk/zabbix_agentd.log \nLogFileSize=1 \nTimeout=30 \nUnsafeUserParameters=1 \nEnableRemoteCommands=1 \nLogRemoteCommands=1" >> /etc/zabbix/zabbix_agentd.conf
sudo systemctl enable zabbix-agent.service
sudo systemctl start zabbix-agent.service
#LOG cat /var/ramdisk/zabbix_agentd.log

If you want to create the folder from part 1 with a script you can use following:

# /bin/bash
# create folders for zabbix_server

mkdir -p \
/volume1/docker/Zabbix/alertscripts \
/volume1/docker/Zabbix/externalscripts \
/volume1/docker/Zabbix/modules \
/volume1/docker/Zabbix/enc \
/volume1/docker/Zabbix/ssh_keys \
/volume1/docker/Zabbix/ssl/certs \
/volume1/docker/Zabbix/ssl/keys \
/volume1/docker/Zabbix/ssl/ssl_ca \
/volume1/docker/Zabbix/snmptraps \
/volume1/docker/Zabbix/mibs \
/volume1/docker/Zabbix/nginx

Change 2020 07 16
After getting a lots of „[file:dbconfig.c,line:94] zbx_mem_malloc(): out of me mory “ Errors while starting the stopped Zabbix Server I recognised that it will be an issue with the Cache so i added „-e ZBX_CACHESIZE=1000M“ to the Zabbix Server command

Links
https://hub.docker.com/r/zabbix/zabbix-appliance
Thanks to Rainhardt Gabriel for the idea

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Time limit is exhausted. Please reload the CAPTCHA.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.