#!/bin/bash # Task to Install Zabbix on Ubuntu (ubuntu::install_zabbix) # Input Variables INSTALL_ZABBIX="${PT_install_zabbix_bool}" # Check if Zabbix installation is requested if [ "$INSTALL_ZABBIX" != "true" ]; then echo '{"status": "skipped", "message": "Zabbix installation not requested, skipping..."}' exit 0 fi # Download the Zabbix release package sudo wget -O /tmp/zabbix-release.deb https://repo.zabbix.com/zabbix/7.2/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.2+ubuntu22.04_all.deb # install the zabbix release package sudo dpkg -i /tmp/zabbix-release.deb # Update the package list sudo apt update # Install the Zabbix agent sudo apt install -y zabbix-agent2 # Configure the Zabbix agent sudo sed -i -e 's/^Server=127\.0\.0\.1/# Server=127.0.0.1/' -e 's/^ServerActive=127\.0\.0\.1/ServerActive=10.44.0.5,zabbix.moeny.ai/' -e 's/^LogFileSize=0/LogFileSize=1/' -e 's/^Hostname=Zabbix server/# Hostname=Zabbix server/' -e 's/^# HostnameItem=system\.hostname/HostnameItem=system.hostname/' /etc/zabbix/zabbix_agent2.conf # Enable the Zabbix agent sudo systemctl enable zabbix-agent2 # Start the Zabbix agent sudo systemctl start zabbix-agent2 # Verify installation if sudo systemctl is-active --quiet zabbix-agent2; then echo "Zabbix agent installed and running successfully" exit 0 else echo "Zabbix agent installation failed or service is not running" exit 1 fi