Zabbix bash script ubuntu 24
#!/bin/bash
set -e
echo "🔧 oude Zabbix repo verwijderen..."
sudo rm -f /etc/apt/sources.list.d/zabbix.list
echo "⬇️ Zabbix 7.0 repository downloaden..."
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu24.04_all.deb
if [ ! -f zabbix-release_7.0-1+ubuntu24.04_all.deb ]; then
echo "❌ download mislukt. Controleer internet of URL."
exit 1
fi
echo "📦 installeren via dpkg..."
sudo dpkg -i zabbix-release_7.0-1+ubuntu24.04_all.deb || { echo "❌ dpkg faalde."; exit 1; }
echo "🔄 apt update..."
sudo apt update
echo "📥 zabbix-agent installeren..."
sudo apt install -y zabbix-agent
echo "⚙️ configuratie aanpassen naar server 167.235.78.173..."
sudo sed -i 's/^Server=127.0.0.1/Server=167.235.78.173/' /etc/zabbix/zabbix_agentd.conf
sudo sed -i 's/^ServerActive=127.0.0.1/ServerActive=167.235.78.173/' /etc/zabbix/zabbix_agentd.conf
sudo sed -i "s/^Hostname=.*/Hostname=$(hostname)/" /etc/zabbix/zabbix_agentd.conf
echo "🚀 agent starten en inschakelen bij boot..."
sudo systemctl restart zabbix-agent
sudo systemctl enable zabbix-agent
sudo ufw allow 10050/tcp
echo "✅ gereed: agent draait en wijst naar 167.235.78.173"