Zabbix proxy raspberry

Установка Zabbix на Raspberry Pi 3 Model B

Это просто эксперимент, как будет работать система мониторинга на базе приложения Zabbix (Version: 3.0.2) на моем миникомпьютере Raspberry Pi 3 Model B. Просто у меня в наличии их два и один дома я могу приспособить к уже имеющему использованию, как сервер видеонаблюдения MotionEye, OwnCloud, PLEX и т. д., а если его будет хватать для моих задач, то прикуплю еще один и сделаю из них особую сеть. Но это пока в планах.

Сперва действия по настройке операционной системы Raspbian, а уже затем шаги самой задачи:

$ sudo apt-get install mysql-server php5 apache2 php5-gd php5-mysql php5-ldap snmpd libiksemel3 libodbc1 libopenipmi0 fping ttf-dejavu-core ttf-japanese-gothic -y

New password for the MySQL «root» user: 712mbddr@

Repeat password for the MySQL «root» user: 712mbddr@

Создаю базу, пользователя и пароль для работы сервиса Zabbix:

$ mysql -u root -p712mbddr@ -e «create database dbzabbix character set utf8 collate utf8_bin»

$ mysql -u root -p712mbddr@ -e «grant all privileges on dbzabbix.* to ‘uzabbix’@’localhost’ identified by ‘612mbddr@'»

$ mysql -u root -p712mbddr@ -e «flush privileges»

Скачиваю откомпилированные файлы под архитектуру используемую на миникомпьютере:

На заметку: данный архив я также себе сохранил в персональное облако (на базе OwnCloud), а то мало ли что может случиться с проектом в интернете:

/zabbix3-rpi-master $ sudo dpkg -i zabbix-server-mysql_3.0.2-1+jessie_armhf.deb

/zabbix3-rpi-master $ sudo dpkg -i zabbix-frontend-php_3.0.2-1+jessie_all.deb

/zabbix3-rpi-master $ sudo dpkg -i zabbix-agent_3.0.2-1+jessie_armhf.deb

Теперь нужно созданную базу dbzabbix наполнить структурой — это таблицы, поля, строки:

/zabbix3-rpi-master $ sudo zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uuzabbix -p612mbddr@ dbzabbix

  • uzabbix — это пользователь
  • 612mbddr@ — это пароль для пользователя uzabbix
  • dbzabbix — база данных для сервиса Zabbix и доступом к ней с использованием uzabbix & 612mbddr@

$ sudo nano /etc/zabbix/zabbix_server.conf

Скачать содержимое zabbix.conf можно zabbix.conf.tar:

$ sudo nano /etc/apache2/conf-enabled/zabbix.conf

$ sudo service apache2 restart

$ sudo service zabbix-server start

$ sudo service zabbix-agent start

После нужно пройтись по шагам мастера через URL ссылку для окончательной настройки сервиса мониторинга Zabbix на Raspberry Pi 3 Model B => http://IP&DNS/zabbix, где

  • Username: Admin
  • Password: zabbix
  • и нажать Sign In

Шаг №1: Welcome, нажимаю на кнопку Next step

Шаг №2: Check of pre-requisites: по всем строчкам должен быть статус OK и только после нажимаю на кнопку Next stеp

Шаг №3: Zabbix server details: заполняю

  • Database type: MySQL
  • Database host: localhost
  • Database port: 3306
  • Database name: dbzabbix
  • User: uzabbix
  • Password: 612mbddr@

и нажимаю на кнопку Next step

Шаг №4: Pre-installation summary

  • Host: localhost
  • Port: 10051
  • Name: 10.7.8.53

и нажимаю на кнопку Next step.

Шаг №5: Install, проверяю результирующую информацию по указанным настройкам и если Вас все устраивает, то нажимаем на кнопку Next step.

После окончательных шагов мастер поздравляет с успешным завершением разворачивания Web-сервиса Zabbix на текущем железе, в роли железа выступает Raspberry Pi 3 Model B и нажимаем Finish дабы перейти к окну авторизации.

  • Username: Admin
  • Password: zabbix
  • Remember me for 30 days: отмечаем галочкой

И нажимаем заветную кнопку Sing in и вот я внутри успешно установленного сервиса и все что необходимо в домашнем использовании на него заводить.

По сути действия один в один аналогичны действия по разворачиванию Zabbix на Ubuntu Precise, Trusty, Xenial что не может не радовать. Но мне в первую очередь хотелось самим пройтись по шагам установки на операционную систему Raspbian и у меня все получилось. В дальнейшем я покажу, что мне нужно было анализировать через такой миникомпьютер с таким удобным сервисом как Zabbix. А пока я прощаюсь, с уважением автор блога Олло Александр aka ekzorchik.

Источник

Wizard.(b)log

Linux and black magic

Zabbix proxy on a raspberry Pi

#Backup databases on raspberry pi in case of power outage (no ups / power bank supplied)

#Create the database:
CREATE DATABASE zabbix_proxy character set utf8 collate utf8_bin;

#Create the zabbix_proxy user:
CREATE USER ‘zabbix’@’localhost’ IDENTIFIED BY ‘your_zabbix_user_password’;

#Grant privileges
GRANT ALL PRIVILEGES ON zabbix_proxy.* TO ‘zabbix’@’localhost’ IDENTIFIED BY ‘our_zabbix_user_password’;

#Create the database schema:
zcat /usr/share/doc/zabbix-proxy-mysql/ schema.sql.gz | mysql -uzabbix -p zabbix_proxy

#Create the data mountpoint

#In /etc/fstab
tmpfs /var/log tmpfs defaults,noatime,size=50m 0 0
tmpfs /var/db_storage tmpfs defaults,noatime, size=200m 0 0

#I do also have a pendrive for backig up my data once in a while and for some swap:

UUID=f8671d68-403c-449b-94a7-9b80e2f7dd88 none swap sw,pri=5 0 0
UUID=d3f1712b-d53e-487a-9b2c-09d74bdc517c /mnt/data xfs defaults 0 0

#Short disclaimer:
#As I’ve killed my two of SD cards with the read/write operations, I’ve decided to go for tmpfs in the memory.
#That’s why I suggest a tmpfs for /var/log and a custom localisation for the databases (/var/db_storage).

#Of course you need to create the directory:
mkdir -p /var/db_storage

also you need to change your /etc/mysql/my.cnf line:

#datadir = /var/lib/mysql
datadir = /var/db_storage

#Now we need to secure our files.

crontab -e #edit users crontab file

# Every day at 2AM I’ll get a dump of all my databases
#The best and safest choice would be creating a dedicated user for backing up your #data. Such user should have read-only privileges to all databases.
#You can use, instead of zabbix_proxy (database name) this: –all-databases and back #up all your databases. This is good as long as your database is quite small. If #it’s a large database than this will take ages on such a machine like raspberryPi

0 2 * * * mysqldump -u zabbix -p yoursuperhardpasswordfordbaccess zabbix_proxy | gzip > /mnt/data/db_storage/zabbix_proxy_`date +”%Y-%m-%d”`.sql.gz

#Once every 15 minutes I’ll zip all the files into one archive and keep in on the thumb drive. Just because I can.
0 */15 * * * root zip -r /mnt/data/db_storage/db_storage.zip /var/db_storage/

#Another crontab rule – every day at 1:30AM files older than two weeks will be deleted. This is done to save some space.

30 1 * * * find /path/data/db_storage/ -mindepth 1 -mtime +14 -delete
#this solution is better than the -exex rm <> \; it’s less risky in case of a wrong path 😉

Источник

Install and Configure Zabbix Proxy

Video Lecture

Description

I start with a brand-new installation of Raspberry Pi OS Lite. I use the 64 Bit version without the Desktop GUI.

Raspberry Pi OS Lite doesn’t enable SSH by default.

Read Troubleshooting Raspberry Pi OS before continuing since there are potentially breaking changes since April 2022.

If you are installing an older version of Raspberry Pi and you haven’t enabled SSH in the installer, then continue with these instructions.

To enable SSH, plug in an HDMI cable with monitor attached.

Plug in a USB keyboard.

When boot sequence has finished,

Navigate to option 3 Interface Options .

Select I2 SSH and enable.

Go Back to main menu.

You may also want to select 6 Advanced Options and select A1 Expand Filesystem to use all the SD card.

Go Back to main menu and select Finish

I then use my SSH client and log into the Raspberry Pi. Default username is pi and default password is raspberry

You can change the default Raspberry Pi password by using the passwd command.

I install Zabbix Proxy to manage communication between the Server and Agents on my local network.

It is important to know which operating system you intend to use for your proxy. To find which operating system you are using, at the prompt, type one of these commands,

On my raspberry pi, hostnamectl returns Operating System: Debian GNU/Linux 11 (bullseye)

I select Raspberry Pi OS for the OS distribution and 11 Bullseye for the OS version on the Zabbix download page.

My Raspberry Pi is running Raspbian PI OS Lite (64 Bit) (No desktop GUI).

The commands used in this lecture are,

Other database options for Zabbix proxy are MySQL and PostgreSQL.

They can be installed by using

Note that with the sqlite3 version, you won’t need to install the database schema since it will be automatically created if it doesn’t already exist.

If you use MySQL or PostgreSQL then you also need to install the schema.

Edit Proxy Configuration file

Edit the Server, Hostname and DBName parameters.

zabbix_proxy.conf

Key Value Notes
Proxymode 0 0 = Active. This is the default already
Server zabbix.sbcode.net The DNS name of my Zabbix server. You could use IP address if you don’t have a DNS name.
Hostname raspberrypi (see notes below)
DBName /tmp/zabbix_proxy.db I am using the SQLite3 database option

I use the actual network hostname for this value to avoid ambiguity between the several uses of the term Hostname in the Zabbix documentation and UI. I just use the same name as is returned from entering the command hostname on my proxy server. When I enter hostname on my proxy server, it returns raspberrypi

I save, then I enter

To ensure that Zabbix Proxy auto starts after reboot then enter,

Add Proxy to Zabbix Server UI

I then create the proxy in Zabbix Server UI, then after several seconds, I refresh the proxy config screen and it will show that the proxy is now in communication with the server.

Zabbix UI ⇾ Administration ⇾ Proxies

Key Value Notes
Proxy name raspberrypi (see notes below)
Proxy mode Active The is the same as is set on the configuration file on the proxy server.

The Proxy name must be the same name you configured in the Hostname parameter in the proxy configuration file /etc/zabbix/zabbix_proxy.conf on your proxy server. In my example, it doesn’t matter that my Zabbix server is on a different network than the proxy. All messages received on the Zabbix Server from the external Proxy will contain this hostname in the payload, so the Zabbix Server process will reject anything that doesn’t match.

Also note that the Proxy name is the only required parameter on this form. You don’t need anything else to make it work.

For extra security also use PSK encryption, but that is discussed later on the course in the section Enable PSK Encryption. The process is conceptually the same for the Proxy, except, you add your PSK values to the /etc/zabbix/zabbix_proxy.conf on your proxy server, rather than the agent configs /etc/zabbix/zabbix_agentd.conf as discussed in the example. You also configure this on the Zabbix UI in the Administration ⇾ proxies ⇾ [Your proxy] ⇾ Encryption. This method is for communications between the Zabbix server and the Proxy only. I advise doing the Agent example of setting up PSK before trying to do PSK encryption for the Zabbix Server Proxy communications unless you are totally confident you know what you are doing. Make sure all your communications between all your hosts, proxies, server are working before adding encryption to any parts of the communications between any components, since it wil make problem solving much harder. Solve one problem at a time.

Troubleshooting

Proxy Configuration

Check the output of

Check the output of

Also be sure that the name of your proxy in the Zabbix User Interface, Administration ⇾ Proxies is the same as your Hostname setting in the Zabbix proxy config in /etc/zabbix/zabbix_proxy.conf

Raspberry Pi OS

If when logging into a new installation of Raspberry Pi, you get a Acces denied error for the pi user, then it may be that you have installed the latest version of Raspberry Pi OS.

Since April 2022, Raspberry Pi OS no longer contains the default user pi . You need to manually add your own custom user when creating the installation image.

After selecting the operating system Raspberry Pi OS Lite (64 -bit) , press the gear icon,

And then Enable SSH and set a username and password, or use the SSH public key authentication option if you prefer.

PSK Encryption between the Proxy and Server

Later on, you may be tempted to add PSK encryption between your Zabbix server and the Proxy. PSK is discussed more later on in the course.

You may see an error in the Proxy logs, cannot send proxy data to server at «zabbix.your-domain.tld»: connection of type «TLS with PSK» is not allowed for proxy «your-proxy»

When setting up PSK encryption for communications specifically between the Proxy and Server, you should add the PSK Identity and Secret to Administration ⇾ Proxies ⇾ [Your proxy] ⇾ Encryption and also adjust the settings inside the file /etc/zabbix/zabbix_proxy.conf

If you also want Encryption between your Proxy and its local Agent, then create another secret for the agent, set its PSK settings in the Proxy Agents Host configuration at Configuration ⇾ Hosts ⇾ [Your proxy] ⇾ Encryption, and modify the settings in the file /etc/zabbix/zabbix_agentd.conf

Understand that the Proxy process, and the Proxies own Agent process are two different things with their own configurations. The proxies own agent is discussed in the next section.

Источник

Adblock
detector