# This script install and configure zabbix-agent2 on RHEL/Rocky hosts #!/bin/bash if [ "$UID" -ne 0 ]; then echo "Please run as root" exit 1 fi printf "Enter IP adress to zabbix-proxy server: " read zbxproxy printf "Enter Customer ID: " read custid echo "Install package..." rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-latest.el9.noarch.rpm yum install zabbix-agent2 -y echo "Fix configuration..." custid=`echo "$custid" | awk '{print tolower($1)}'` hostname=`hostname` fullhostname=`echo "$hostname.$custid"` printf "Hostname=$fullhostname\nServer=$zbxproxy\nServerActive=$zbxproxy\n" | sudo tee /etc/zabbix/zabbix_agent2.d/customized.conf chmod 0644 /etc/zabbix/zabbix_agent2.d/customized.conf # enable and start agent systemctl enable zabbix-agent2 --now && systemctl restart zabbix-agent2 echo "Installation finished..." echo