Kategorie: Software

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


4 Replies

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


1 Reply

Synology – Backup to RaspberryPi

Using „HyperBackup“ to create Backups is the best and easiest way to save all your data and settings on your Synology. Finding a target to backup is not that easy. You can buy an other Synology Produkt or set up an Linux Server. My Solution is a Raspberry Pi with Raspbian / Raspberry Pi OS and an external USB Drive attached. Installing and mounting the USB drive has to be done before you can use this help to install the RSYNC-Server.

Mount your external device and make sure that it will be always mounted automatically after restarts.
In our example we use the path /mnt/USBDevice

First you have to install the rsync service, use following command:

sudo apt-get install rsync

After the successful installation you can change following config file.
/etc/default/rsync
you can do this by typing

sudo nano /etc/default/rsync

and change following lines

*
RSYNC_ENABLE=false
*
RSYNC_CONFIG_FILE=

to

*
RSYNC_ENABLE=true
*
RSYNC_CONFIG_FILE=/etc/rsyncd.conf

now exit the nano editor with „Control +x“ and accept the changes with „Y“ (if you are using a mac)

Now you can create the rsyncd.conf file by following command:

sudo nano /etc/rsyncd.conf

copy this content into the file and change the parameters to your settings

max connections = 2
log file = /var/log/rsync.log
timeout = 300
 [SYN-HyperBackup]
comment = This folder will be shared for rsync backups
path = /mnt/USBDevice
read only = no
list = yes
uid = root
gid = root # f├╝r PI
# gid = wheel # f├╝r macOS
auth users = syno
secrets file = /etc/rsyncd.secrets.syno

now we have to set the password for the user syno by typing

sudo nano /etc/rsyncd.secrets.syno

and add following: (please do not forget to change the password)

syno:password

exit the nano editor and change the user rights for the password file with following command:

sudo chmod 600 /etc/rsyncd.secrets.syno

and add the user to the system

sudo adduser syno --system --group --no-create-home --shell /bin/false

Restart the rsync service to load the new config

sudo systemctl restart rsync.service 

Now you can login to your Synology and Download the HyperBackup in the Package Center and add a new Data Backup task

Data Backup Task

Choose „rsync“ as option an clock on Next

Now you can choose „rsync-compatible server“ add the IP address, user and password. When you click on the Backup Module you should get the same name you have set in the /etc/rsyncd.conf file. Follow the the next steps like you want to have it.


Typical Error Messages:

  1. „Authentication failed. Please check your authentication credentials“

    Make sure that you have the right password and that you have created the same local user.
Authentication failed. Please check you authentication credentials
  1. Failed to establish the SSH connection. Please make sure that your credentials are correct, the SSH service of the destination server is normal, and the 2-step verfication is not enabled before trying again.

    May you have the wrong Port. Make sure that you use 873.
Failed to establish the SSH connection. Please make sure that your credentials are correct, the SSH service of the destination server is normal, and the 2-step verfication is not enabled before trying again.

Restoring files you can use follwing information
Restore Data from Synology Hyper Backup local




Thanks to following homepages helping me to create this manual:
Framp’s Linux Tips and Tricks
Synology-Forum.de

and thanks to following helpers:
Thomas B├Âhm (http://boehm.gl) for the Mac Version

If you want to backup to an Apple Device with you have to create an LaunchDaemon

/Library/LaunchDaemons/org.samba.rsync.plist

with following content

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>org.samba.rsync</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/rsync</string>
        <string>--daemon</string>
        <string>--no-detach</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
</dict>
</plist>

the default path for you rsync should be

<string>/usr/local/bin/rsync</string>

If not change it in the plist file to the correct one

now you can start the Deamon with

launchctl load /Library/LaunchDaemons/org.samba.rsync.plist

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