Zabbix Proxy RAM config
Zabbix Proxy RAM config
2.1 Install Raspbian
You download NOOBS:
5 Configure the Zabbix proxy
We open the configuration file
nano /etc/zabbix/zabbix_proxy.conf
and adjust at least the following lines:
Server = IP or DNS name of the Zabbix server to be reported to # Hostname -> under this name we also have to create the proxy on the main server! Hostname = zabbixproxy # Increase command timeout. This is how long the proxy waits for replies from scripts, checks and agents Timeout = 30 # New 3.4 feature - RemoteCommands now also work behind proxies EnableRemoteCommands = 1 LogRemoteCommands = 1 # Database and log in the RAM disk (do not change the lines if not desired) LogFile = / var / ramdisk / zabbix_proxy.log LogFileSize = 4 DBName = / var / ramdisk / zabbixproxy.db
https://www.raspberrypi.org/downloads/noobs/
I recommend the normal variant, not the Lite - especially if you are on the go in company networks. Noobs (resp. Linux) zicks around if your DHCP server, for example, also distributes routes and then gets no internet connection. With the normal version you can always install Raspbian, even without an internet connection.
The microSD card must be formatted with FAT32. You could easily check this by going to the drive with the microSD card in File Explorer and calling the properties with the right mouse button:
2.2 Set fixed IP address
We log on to the Raspberry Pi and switch to root:
sudo -i
From the Raspbian stretch release, the IP address is specified in the following file (which we are processing):
nano /etc/dhcpcd.conf
Inserts the following lines there / changes the existing ones:
interface eth0 static ip_address = 10.100.20.166 / 24 static routers = 10.100.20.1 static domain_name_servers = 10.100.50.50 8.8.8.8
If you want to set the WLAN interface: just wlan0
take it instead eth0
(or additionally).
Save and restart the Raspberry:
reboot
2.3 restore root
I personally always work directly as root on the devices (always this sudo ...).
So that he can log in again - initially locally - he only needs a password:
sudo passwd root
and then 2 x the new password.
I also prefer the colored display of the bash prompt (as with user pi) and the use of aliases such as ll :
sudo cp /home/pi/.bashrc / root / nano /root/.bashrc
and adjust the following lines:
# some more ls aliases alias ll = 'ls -l' alias la = 'ls -A' alias l = 'ls -CF'
2.4 root login via SSH
2.4.2 By password
I am writing very thickly here:
NOT RECOMMENDED
but you know what you are doing:
sudo nano / etc / ssh / sshd_config
and find the following line and change it accordingly:
#PermitRootLogin prohibit-password change to PermitRootLogin yes
Then restart Raspberry and it should work.
2.4.1 Via SSH key
The root can already log in via SSH - but not with a password. I use PuTTY or KiTTY and so I simply leave the corresponding key.
You can find detailed instructions on how to set this up here if required
Ubuntu_16.04.x_2-factor_in_SSH_mit_Google_Authenticator_einrichten # R.C3.BCckversicherung_mit_SSH-Key
If you already have the key:
sudo -i mkdir ~ / .ssh chmod 700 ~ / .ssh touch ~ / .ssh / authorized_keys2 chmod 600 ~ / .ssh / authorized_keys2
and then insert the key into the file:
nano ~ / .ssh / authorized_keys2
Now you can log in - using the SSH key - directly to the Raspberry using SSH.
2.5 Import updates
- log back in as root
- Search for updates for operating system: (updates the catalog from the update sources)
apt update
- Import updates:
apt upgrade -y
- Remove unnecessary packages after update:
apt autoremove -y
2.6 Firmware updates
rpi update
and wait + restart
2.7 Install the required programs for Zabbix
The following packages are not installed automatically, at least this creates missing log entries:
apt install -y snmp-mibs-downloader
3 Install the Zabbix Proxy
In the meantime I always install Zabbix directly from the repository https://repo.zabbix.com
And there are also corresponding installation files for ARM processors + Debian.
We add the package sources (Rasbian Stretch):
wget wget https://repo.zabbix.com/zabbix/4.0/raspbian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb dpkg -i zabbix-release_4.0-2 + ​​stretch_all.deb apt update
And now the proxy with SQLite support
apt install -y zabbix-proxy-sqlite3 zabbix-agent zabbix-sender zabbix-get
The configuration files are now under
/ etc / zabbix /
The Zabbix user has already been created, the start scripts for systemd are in the right places.
4 RAM disk for the database
The proxy collects the data from its area and forwards it centrally to the Zabbix server. Nevertheless, each value is first written to a local database and then sent. By default, the values ​​are deleted from the database immediately, in the event of connection problems after one hour. You can see that in the log, there are corresponding maintenance entries:
483: 20180131: 141236.892 housekeeper [deleted 3981 records in 0.032466 sec, idle for 1 hour (s)]
The proxy is constantly in the process of writing values ​​to the database, cleaning up once an hour. With the increased use of Raspberry Pi as a Zabbix proxy, the microSD cards have now always died after one year. This is certainly related to the size of the microSD card on the one hand, and the number of items that run through the proxy on the other.
After a while, the database itself reaches a fixed size, usually only a few MByte.
In connection with Zabbix, the database of the Zabbix proxy has two special features:
- It is actually unimportant - the data is only buffered if the connection to the server is interrupted
- If the Zabbix proxy is used with SQLite, it automatically creates this database including the schema - if it does not exist
The idea is to simply put the database in a RAM disk. A Raspberry Pi 2 (512MByte) or 3/3 + (1024MByte) can easily rip off 100Mbyte for this.
And we also put the logs in with it.
In practice, 100 MB is probably much too large - but (almost) never too small.
nano / etc / fstab
and add the following line:
tmpfs / var / ramdisk tmpfs nodev, nosuid, relatime, size = 100M 0 0
Then create the folder:
mkdir / var / ramdisk
and set the rights
chmod 0777 / var / ramdisk
With
mount -a df -h
we can test whether the RAM disk is created.
Then perform a reboot and check whether it is available afterwards.
5 Configure the Zabbix proxy
We open the configuration file
nano /etc/zabbix/zabbix_proxy.conf
and adjust at least the following lines:
Server = IP or DNS name of the Zabbix server to be reported to # Hostname -> under this name we also have to create the proxy on the main server! Hostname = zabbixproxy # Increase command timeout. This is how long the proxy waits for replies from scripts, checks and agents Timeout = 30 # New 3.4 feature - RemoteCommands now also work behind proxies EnableRemoteCommands = 1 LogRemoteCommands = 1 # Database and log in the RAM disk (do not change the lines if not desired) LogFile = / var / ramdisk / zabbix_proxy.log LogFileSize = 4 DBName = / var / ramdisk / zabbixproxy.db
6 Set up automatic start at boot
systemctl enable zabbix-proxy.service
7 Start Zabbix proxy testing
systemctl start zabbix-proxy
The log file and the database should now be in the RAM disk:
ls -l / var / ramdisk /
Output:
3501: 20180131: 160550.657 Starting Zabbix Proxy (active) [TestPiProxy]. Zabbix 3.4.4 (revision 74338).
3501: 20180131: 160550.657 **** Enabled features ****
3501: 20180131: 160550.657 SNMP monitoring: YES
3501: 20180131: 160550.657 IPMI monitoring: YES
3501: 20180131: 160550.657 Web monitoring: YES
3501: 20180131: 160550.657 VMware monitoring: YES
3501: 20180131: 160550.657 ODBC: YES
3501: 20180131: 160550.657 SSH2 support: YES
3501: 20180131: 160550.657 IPv6 support: YES
3501: 20180131: 160550.657 TLS support: YES
3501: 20180131: 160550.657 **************************
3501: 20180131: 160550.658 using configuration file: /etc/zabbix/zabbix_proxy.conf
3501: 20180131: 160550.658 cannot open database file "/var/ramdisk/zabbixproxy.db": [2] No such file or directory
3501: 20180131: 160550.658 creating database ...
3501: 20180131: 160551.019 current database version (mandatory / optional): 03040000/03040005
3501: 20180131: 160551.019 required mandatory version: 03040000
3501: 20180131: 160551.057 proxy # 0 started [main process]
3502: 20180131: 160551.059 proxy # 1 started [configuration syncer # 1]
3504: 20180131: 160551.061 proxy # 3 started [data sender # 1]
3506: 20180131: 160551.064 proxy # 5 started [http poller # 1]
3503: 20180131: 160551.071 proxy # 2 started [heartbeat sender # 1]
3505: 20180131: 160551.073 proxy # 4 started [housekeeper # 1]
3509: 20180131: 160551.074 proxy # 8 started [history syncer # 2]
3513: 20180131: 160551.078 proxy # 12 started [task manager # 1]
3514: 20180131: 160551.080 proxy # 13 started [poller # 1]
3507: 20180131: 160551.081 proxy # 6 started [discoverer # 1]
3511: 20180131: 160551.086 proxy # 10 started [history syncer # 4]
3517: 20180131: 160551.087 proxy # 16 started [poller # 4]
3508: 20180131: 160551.091 proxy # 7 started [history syncer # 1]
3510: 20180131: 160551.093 proxy # 9 started [history syncer # 3]
3512: 20180131: 160551.101 proxy # 11 started [self-monitoring # 1]
3515: 20180131: 160551.102 proxy # 14 started [poller # 2]
3518: 20180131: 160551.102 proxy # 17 started [poller # 5]
3516: 20180131: 160551.111 proxy # 15 started [poller # 3]
3519: 20180131: 160551.112 proxy # 18 started [unreachable poller # 1]
3523: 20180131: 160551.120 proxy # 22 started [trapper # 4]
3524: 20180131: 160551.121 proxy # 23 started [trapper # 5]
3520: 20180131: 160551.141 proxy # 19 started [trapper # 1]
3525: 20180131: 160551.151 proxy # 24 started [icmp pinger # 1]
3521: 20180131: 160551.152 proxy # 20 started [trapper # 2]
3522: 20180131: 160551.161 proxy # 21 started [trapper # 3]
3502: 20180131: 160551.749 received configuration data from server at "test.leitungsen.de", data 3401
If it says something like:
3586: 20180131: 160848.872 cannot send heartbeat message to server at "ecetest.leitungsen.de": proxy "TestPiProxy" not found 3585: 20180131: 160849.468 cannot obtain configuration data from server at "ecetest.leitungsen.de": empty string received
Well, we have to put the proxy on our Zabbix server
Administration - proxies
still create - please use the exact same name as the zabbix_proxy.conf
one Hostname=
below - then the error is gone.
8 Configure and start the agent
We also want to monitor the proxy itself.
This too - as a host - must be created on the Zabbix server. The host name must be stored in the configuration file.
By default, the agent tries to return from the hostname command:
hostname
Output:
PiProxy01
Adaptation of the configuration:
nano /etc/zabbix/zabbix_agentd.conf
Changes:
# The name of the host on the Zabbix server Hostname = PiProxy01 # Log file in the RAM disk LogFile = / var / ramdisk / zabbix_agentd.log LogFileSize = 1 # Timeout for queries / scripts etc. Timeout = 30 # Allow special characters in the item keys UnsafeUserParameters = 1 # Execute commands on call EnableRemoteCommands = 1 LogRemoteCommands = 1
Activate automatic start at boat:
systemctl enable zabbix-agent.service
and start the agent:
systemctl start zabbix-agent.service
The log file shows the status
cat /var/ramdisk/zabbix_agentd.log
9 Reboot test
Reboots the system once
reboot
and checks if
- The ramdisk was created
- The Zabbix proxy has started, has created the database and the log file
- The agent has started and created the log file