2022-06-30 14:07:34 +02:00
---
title: Zabbix
2022-11-19 15:25:20 +01:00
visible: true
2022-06-30 14:07:34 +02:00
---
2022-06-30 14:07:56 +02:00
[toc]
2023-02-23 14:48:51 +01:00
2022-07-08 15:11:26 +02:00
## Zabbix Server
2023-02-23 14:48:51 +01:00
2022-06-30 14:07:34 +02:00
### Pod
2023-02-23 14:48:51 +01:00
```sh
podman pod create --name zabbix -p 127.0.0.1:8080:8080 -p 10051:10051
2022-06-30 14:07:34 +02:00
```
### Database
2023-02-23 14:48:51 +01:00
```sh
podman run --name zabbix-mysql -t \
2022-06-30 14:07:34 +02:00
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="rootpass" \
-v /mnt/mysql/:/var/lib/mysql/:Z \
--restart=always \
--pod=zabbix \
-d docker.io/mysql:latest \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
```
### Application
2023-02-23 14:48:51 +01:00
2022-06-30 14:07:34 +02:00
Zabbix consists of multiple containers that need to be running.
2023-02-23 14:48:51 +01:00
First is the server itself.
```sh
podman run --name zabbix-server -t \
2022-06-30 14:07:34 +02:00
-e DB_SERVER_HOST="127.0.0.1" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="rootpass" \
--pod=zabbix \
-d docker.io/zabbix/zabbix-server-mysql:latest
```
2023-02-23 14:48:51 +01:00
Next, we need the webserver
```sh
podman run --name zabbix-web -t \
2022-06-30 14:07:34 +02:00
-e ZBX_SERVER_HOST="127.0.0.1" \
-e DB_SERVER_HOST="127.0.0.1" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="rootpass" \
--restart=always \
--pod=zabbix \
-d docker.io/zabbix/zabbix-web-nginx-mysql:latest
```
2023-02-23 14:48:51 +01:00
Finally, we will also install the agent as a container
```sh
podman run --name zabbix-agent \
2022-06-30 14:07:34 +02:00
-e ZBX_SERVER_HOST="127.0.0.1,localhost" \
--restart=always \
--pod=zabbix \
-d docker.io/zabbix/zabbix-agent:latest
```
2023-02-23 14:48:51 +01:00
The default user is `Admin` with password `zabbix`
2022-06-30 14:07:34 +02:00
2022-07-08 15:11:26 +02:00
### Updating Server
2023-02-23 14:48:51 +01:00
2022-07-08 15:11:26 +02:00
Updating the server might fail for various reasons. Those I already encountered will be documented below.
2023-02-23 14:48:51 +01:00
_NOTE: The server and proxy need to run the same version of zabbix to talk with one another_
2022-07-08 15:11:26 +02:00
#### MARIADB: Missing permissions (log_bin_trust_function_creators)
2023-02-23 14:48:51 +01:00
2022-07-08 15:11:26 +02:00
From what I could find this error is thrown, when the specified user lacks super user privileges.
A workaround is enabling `log_bin_trust_function_creators` temporarily.
2023-03-14 19:02:41 +01:00
`# podman exec -it zabbix-mysql bash`
2022-07-08 15:11:26 +02:00
`# mysql -u root -p` and enter the root password
2023-02-23 14:48:51 +01:00
`mysql> set global log_bin_trust_function_creators=1;`
2022-07-08 15:11:26 +02:00
2023-02-23 14:48:51 +01:00
The setting will be reset to default after a restart of the database container.
2022-07-08 15:11:26 +02:00
2022-06-30 14:07:34 +02:00
## Zabbix Proxy
2023-02-23 14:48:51 +01:00
`ZBX_HOSTNAME` has to be the same as the value configured on the zabbix server as the proxy name.
```sh
podman run --name zabbix-proxy \
2022-06-30 14:07:34 +02:00
-p 10051:10051 \
-e ZBX_SERVER_HOST="178.18.243.82" \
-e ZBX_HOSTNAME="he1prx1" \
-e ZBX_TLSCONNECT=psk \
-e ZBX_TLSPSKIDENTITY="PSK Zabbix he1prx1" \
-e ZBX_TLSPSKFILE="/mnt/zabbix/zabbix_agentd.psk" \
-v /mnt/zabbix:/var/lib/zabbix/db_data \
-v /mnt/zabbix:/mnt/zabbix \
-d docker.io/zabbix/zabbix-proxy-sqlite3:latest
```
2022-07-08 15:11:47 +02:00
### Updating Proxy
2023-02-23 14:48:51 +01:00
2022-07-08 15:11:47 +02:00
Updating the proxy will always fail when using the SQLite database, as upgrading is not supported for SQLite.
2023-02-23 14:48:51 +01:00
_NOTE: The server and proxy need to run the same version of zabbix to talk with one another_
2022-07-08 15:11:47 +02:00
Simply deleting/moving the old SQLite database and restarting the proxy is enough.
2023-02-23 14:48:51 +01:00
_NOTE: History stored on the proxy will obviously be lost_
2022-07-08 15:11:47 +02:00
2022-06-30 14:07:34 +02:00
## Zabbix Agent
2023-02-23 14:48:51 +01:00
```sh
podman run --name zabbix-agent \
2022-06-30 14:07:34 +02:00
-p 10050:10050 \
2022-08-05 16:04:52 +02:00
-e ZBX_HOSTNAME="(hostname)" \
-e ZBX_SERVER_HOST="(zabbix server/proxy)" \
2022-06-30 14:07:34 +02:00
-d docker.io/zabbix/zabbix-agent:latest
```
### XCP-ng
2023-02-23 14:48:51 +01:00
2022-06-30 14:07:34 +02:00
Use zabbix package from EPEL.
2022-08-05 16:11:49 +02:00
Zabbix server can handle the older agent fine [See the Documentation on Compatibility ](https://www.zabbix.com/documentation/current/en/manual/appendix/compatibility )
2023-02-23 14:48:51 +01:00
`# yum install zabbix50-agent --enablerepo=epel`
2022-06-30 14:07:34 +02:00
Edit `/etc/zabbix_agentd.conf`
2023-02-23 14:48:51 +01:00
_haven't managed to make encryption work yet_
2022-06-30 14:07:34 +02:00
```
Server=(Zabbix server ip)
ServerActive=(Zabbix server ip)
Hostname=he1xcp1
#TLSConnect=psk
#TLSAccept=psk
#TLSPSKIdentity=he1xcp1
#TLSPSKFile=/mnt/zabbix/zabbix_agentd.psk
```
2023-02-23 14:48:51 +01:00
Create the .psk file. Set the user and group to `zabbix`
2022-06-30 14:07:34 +02:00
2023-02-23 14:48:51 +01:00
Allow 10050/TCP on the firewall
2022-06-30 14:07:34 +02:00
2023-02-23 14:48:51 +01:00
_nope_
`# yum install openssl11 --enablerepo=epel`
2022-06-30 14:07:34 +02:00
## TODO
2023-02-23 14:48:51 +01:00
2022-06-30 14:07:34 +02:00
### Encryption with PSK
2023-02-23 14:48:51 +01:00
2022-08-05 16:10:31 +02:00
> [Official Documentation](https://www.zabbix.com/documentation/6.0/en/manual/encryption/using_pre_shared_keys)
2022-06-30 14:07:34 +02:00
### Force refresh Proxy
2023-02-23 14:48:51 +01:00
2022-08-05 16:10:31 +02:00
> [Zabbix Forum Post](https://www.zabbix.com/forum/zabbix-troubleshooting-and-problems/363196-cannot-send-list-of-active-checks-to-ip-address-host-ip-address-hostnames-match?p=363205#post363205)
2023-03-21 15:48:35 +01:00
## Configuration
### SMART monitoring
Smart monitoring is available using an official template
Requirements:
```
smartmontools > 7.1
```
Additionally, the `zabbix` user needs to have permission for running `smartctl` .
With `sudo` this can be accomplished without the user entering a password.
```
zabbix ALL=(ALL) NOPASSWD:/usr/sbin/smartctl
```
After that, add the `SMART by Zabbix agent 2` template to the host