The following bash script will determine if the guest OS is centos 6 ot 7 then deploy Zabbix Agent version 4.4.x accordingly. Simply change repostories if you want to use a different version:
#!/bin/bash OUTPUT="$(cat /etc/redhat-release)" if echo "$OUTPUT" | grep -q "CentOS Linux release 7" ; then yes | rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm yum -y install zabbix-agent cp ./zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf systemctl start zabbix-agent systemctl enable zabbix-agent elif echo "$OUTPUT" | grep -q "CentOS release 6"; then yes | rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/6/x86_64/zabbix-release-4.4-1.el6.noarch.rpm yum -y install zabbix-agent cp ./zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf service zabbix-agent start chkconfig zabbix-agent on else echo "OS Not found. Goodbye" fi