Leave a reply

Zabbix – Proxy (docker-compose)

You can easy install you Zabbix – Proxy with this docker-compose.yml file. Download LINK

Follow this steps:
– Make sure that you have the same path created if not use mkdir -p /volume1/docker/Zabbix/
– Generate PSK FILE by tipping this in your ssh session:“openssl rand -hex 32 >> /volume1/docker/Zabbix/zabbix_agentd.psk“
– change „XXX-IDENTITY“ to the Proxy Name
– change „xxx.xxx.xxx“ to the IP Adress or the DNS name of you Zabbix Server
– save the PSK Key (zabbix_agentd.psk) content and the „Proxy Name“ you will need it to install the proxy on you Zabbix Server

after downloading the docker-compose.yml you have to type:

sudo docker-compose up -d

Now you Proxy should start soon (depending on the Hardware it can take up to 5 minutes)

# Make sure that you have the same path created
# if not use mkdir -p /volume1/docker/Zabbix/
# Generate PSK FILE: 
# "openssl rand -hex 32 >> /volume1/docker/Zabbix/zabbix_agentd.psk"
# change "XXX-IDENTITY" to the Proxy Name 
# change "xxx.xxx.xxx" to the IP Adress or the DNS name of you Zabbix Server

version: "3"

services:
  Zabbix-Proxy:
    container_name: Zabbix-Proxy
    restart: always
    image: zabbix/zabbix-proxy-sqlite3:ubuntu-4.4-latest
    environment:
      ZBX_TLSCONNECT: psk
      ZBX_TLSACCEPT: psk
      ZBX_TLSPSKIDENTITY: XXX-IDENTITY
      ZBX_HOSTNAME: XXX-IDENTITY
      ZBX_SERVER_HOST: xxx.xxx.xxx
      ZBX_TLSPSKFILE: zabbix_agentd.psk
      ZBX_SERVER_PORT: 10051
    volumes:
      - /volume1/docker/Zabbix/zabbix_agentd.psk:/var/lib/zabbix/enc/zabbix_agentd.psk

Leave a reply

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

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


1 Reply

Synology Docker install ZABBIX Server with GUI

This manual will help you installing Zabbix Server in one Docker Container on your Synology by using the GUI.

  1. Install Docker (Package Center)
  2. Open Docker go to Registry and search for „zabbix-appliance“ the first hit should be: „zabbix/zabbix-appliance“ mark it and click on „Download“ choose the version you want to have. My default is ubuntu-4.4-latest
  3. Go to the Image section and choose your downloaded template click on „Launch“
  4. Choose the Container name you want to have and click on „Advanced Settings“
  1. Enable auto-restart
  1. Create the folder and link them in the section „Volume“
  1. Set the Ports you want to access the Zabbix installation
  1. Add the PHP Time Zone variable and change it to your location. In my case Europe/Vienna
  1. Apply all settings and the Container will start. This can take a long time. (on my DS918+ more than 30 Minutes)
  2. Now you can login to your Zabbix Installation using the ports we defined in Step 7. In my case <IP-Adress>:10050
    Username: Admin
    Passwort: Zabbix

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


2 Replies

Synology Docker Zabbix Backup and Restore

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. So this is my solution:

  1. Go to „Control Panel“ -> „Task Schedueler“ and create a „User-defined script“
  1. Choose the name you want to have and set the User to „root“
  1. Choose the time you want to have the script running
  1. Change the code to your settings.
docker exec Zabbix-Server /usr/bin/mysqldump -u root --password=zabbix zabbix > /volume1/docker/Zabbix/backup.sql

tar -zcvf /volume1/docker/Zabbix/$(date +%Y%m%d).tar.gz /volume1/docker/Zabbix/backup.sql
rm /volume1/docker/Zabbix/backup.sql

Restore Database
If you want to restore your Database you have to enable SSH and connect with your Terminal. Then you can paste following command: (Attention you have to unpack the tar file if you use my Backup scirpt

cat /volume1/docker/Zabbix/backup.sql | docker exec -i Zabbix-Server /usr/bin/mysql -u zabbix --password=zabbix zabbix

Links:
https://gist.github.com/spalladino/6d981f7b33f6e0afe6bb


2 Replies

Ubuntu 20.X fast Docker install

After installing Docker on lots of machines I automated this with following sh script. Just create a new script or download it with this link: DOWNLOAD install_docker.sh

You can use this command:

wget https://www.schaupper.at/Upload/scripts/installdocker.sh
chmod +x installdocker.sh
sudo ./installdocker.sh

Content of the script:

# /bin/bash
# install docker
sudo apt update
#remove older versions
sudo apt-get -y remove docker docker-engine docker.io
#install docker
sudo apt-get install docker.io
#enable docker at boot
sudo systemctl start docker
sudo systemctl enable docker

I am follwing this manual : Docker Manual


Durch die weitere Nutzung der Seite stimmst du der Verwendung von Cookies zu. Weitere Informationen

Die Cookie-Einstellungen auf dieser Website sind auf "Cookies zulassen" eingestellt, um das beste Surferlebnis zu erm├Âglichen. Wenn du diese Website ohne ├änderung der Cookie-Einstellungen verwendest oder auf "Akzeptieren" klickst, erkl├Ąrst du sich damit einverstanden.

Schlie├čen