Wiki do Tiozão do Linux

Installar Zabbix Agent

O Zabbix Agent se reportando ao Server de Forma Segura

Vizão Geral do Zabbix Agent

Ambiente Utilizado: Ubuntu Nuvem disponível aqui

Instalar o Zabbix-Agent

Requisitos mínimos recomendados: 2 CPUs, 2 GB de RAM, HD >= 50 GB

Instalar Repositório Zabbix

Pode ser num Ubuntu-Server OU num Raspberry-PI. Escolha o repositório correto.

Num Ubuntu 22.04

wget -c https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu22.04_all.deb
dpkg -i zabbix-release_6.0-4+ubuntu22.04_all.deb
apt update

Num Raspberry PI OS

wget https://repo.zabbix.com/zabbix/6.0/raspbian/pool/main/z/zabbix-release/zabbix-release_6.0-5%2Bdebian11_all.deb
dpkg -i zabbix-release_6.0-5+debian11_all.deb
apt update

Instalar zabbix agent

# Instalar agent get e sender
apt -y install zabbix-agent2 zabbix-get zabbix-sender

# Parar o serviço zabbix-agent2
systemctl stop zabbix-agent2.service

# Backup do arquivo de configuração do zabbix-agent2
mv /etc/zabbix/zabbix_agent2.conf /root/

# Configurar serviço zabbix-agent2 alterando o arquivo /etc/zabbix/zabbix_agent2.conf
cat << '_EOF' > /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Timeout=30
Server=127.0.0.1, zabbix.tiozaodolinux.com
ServerActive=zabbix.tiozaodolinux.com
Hostname=xxxx.tiozaodolinux.com
TLSConnect=psk
TLSAccept=unencrypted,psk
TLSPSKIdentity=PSK RASP XXX
TLSPSKFile=/etc/zabbix/zabbix_proxy.psk
AllowKey=system.run[*]
ControlSocket=/run/zabbix/agent.sock
Include=/etc/zabbix/zabbix_agent2.d/*.conf
Include=./zabbix_agent2.d/plugins.d/*.conf
_EOF

Criar o arquivo /etc/zabbix/zabbix_proxy.psk que conterá o HASH que posibilitará a criptografia entre o server e o agent. Sem criptografia, seus dados serão transmitidos em TEXTO CLARO pela internet.

openssl rand -hex 32 > /etc/zabbix/zabbix_proxy.psk

cat /etc/zabbix/zabbix_proxy.psk 
af8ced32dfe8714e548694e2d29e1a14ba6fa13f216cb35c19d0feb1084b0429

Ativar os serviços:

systemctl enable --now zabbix-agent2
systemctl start zabbix-agent2

Testar o zabbix-agent2:

zabbix_get -s 127.0.0.1 -k system.uptime

Observar os logs:

tail -f /var/log/zabbix/zabbix_agent2.log

Observe os logs do zabbix-agent tentando se comunicar com o zabbix-server. Enquanto não for criado o host corretamente na interface https://zabbix.tiozaodolinux.com para que o proxy consiga se comunicar com o server, um erro como abaixo ocorrerá.

87503:20220810:140915.618 Unable to connect to [zabbix.tiozaodolinux.com]:10051 [TCP successful, cannot establish TLS to [[zabbix.tiozaodolinux.com]:10051]: SSL_connect() set result code to SSL_ERROR_SSL: file ssl/record/rec_layer_s3.c line 1544: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure: SSL alert number 40: TLS read fatal alert "handshake failure"]
87827:20220810:141225.145 Will try to reconnect every 1 second(s)

PS: No cadastro do host lembre-se de utilizar o Hostname, o TLSPSKIdentity e o conteúdo do TLSPSKFile informado na configuração do agent2

Hostname=xxxx.tiozaodolinux.com	        <==== Esse é o nome do host a ser cadastrado no zabbix-server
TLSPSKIdentity=PSK RASP XXX							<==== Essa é a identificação do host
TLSPSKFile=/etc/zabbix/zabbix_proxy.psk	<===== o conteúdo desse arquivo é o **HASH** a ser utilizado 

Mais detalhes de como gerar dessa chave: https://www.zabbix.com/documentation/6.0/en/manual/encryption/using_pre_shared_keys

Referências

Monitoramento distribuído - https://www.zabbix.com/documentation/6.0/pt/manual/distributed_monitoring

O Zabbix Proxy - https://www.zabbix.com/documentation/6.0/pt/manual/distributed_monitoring/proxies

Download Oficial do Zabbix - https://www.zabbix.com/download?zabbix=6.0&os_distribution=ubuntu&os_version=22.04&components=proxy&db=sqlite3&ws=