Contents

Zabbix Agent 6 - Ubuntu Auto Install

Contents

Tired of downloading and setting up the Zabbix Agent package? Here is a script that handles everything from start to finish and all can be done from one line in bash. It will also setup everything to be ready for auto discovery from the server side.

All you have to do is run the following from a command line with a user that has sudo access:

bash <(curl -s https://milo.life/zabbix.sh)
Success
That’s it! Just enter the zabbix server URL when promted and the script handles the rest.

Here is the complete script if you want to have a look at it

#!/bin/bash

ubuntuV=$(lsb_release -rs)

echo "What's your Zabbix Server URL: "
read url

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4+ubuntu$ubuntuV\_all.deb

if [ $? == 0  ]; then
	sudo dpkg -i zabbix-release*
	sudo apt update
	sudo apt install zabbix-agent
	rm zabbix-release*

	sudo sed -i "s/Server=127.0.0.1/Server=$url/g" /etc/zabbix/zabbix_agentd.conf
	sudo sed -i "s/ServerActive=127.0.0.1/ServerActive=$url/g" /etc/zabbix/zabbix_agentd.conf
	sudo sed -i "s/Hostname=Zabbix server/#Hostname=Zabbix server/g" /etc/zabbix/zabbix_agentd.conf
	sudo sed -i "s/# HostMetadataItem=/HostMetadataItem=system.uname/g" /etc/zabbix/zabbix_agentd.conf
	sudo sed -i -e '$aAllowKey=system.run[*]' /etc/zabbix/zabbix_agentd.conf

	sudo systemctl enable zabbix-agent.service
	sudo systemctl restart zabbix-agent.service
fi