Update zabbix_agent.sh

This commit is contained in:
2018-12-18 13:54:05 -05:00
parent 5f7ba95633
commit 07c33629d0

View File

@@ -8,39 +8,39 @@ if [ "$EUID" -ne 0 ]; then
exit
fi
# create temp directory for downloaded files
DIRECTORY="/tmp/zabbix_install"
mkdir ${DIRECTORY}
# zabbix server
ZABBIX_SERVER="gauntzabbix.home.johnhgaunt.com"
if [ -f /etc/debian_version ]; then
#apt update
#apt install -y snmpd curl
# Install the repository configuration package. This package contains apt (software package manager) configuration files.
wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-2+stretch_all.deb
dpkg -i zabbix-release_4.0-2+stretch_all.deb
# update the cache
apt update
# install the agent
apt install -y zabbix-agent
elif [ -f /etc/redhat-release ]; then
#yum install -y net-snmp net-snmp-utils
#firewall-cmd --zone=public --add-service=snmp --permanent
#firewall-cmd --reload
# Install the repository configuration package. This package contains yum (software package manager) configuration files.
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
# install the zabbix agent
yum install -y zabbix-agent
cat < EOF >> /etc/firewalld/services/zabbix.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>zabbix agent</short>
<description>zabbix agent/description>
<port protocol="tcp" port="10050"/>
<port protocol="udp" port="10050"/>
</service>
EOF
firewall-cmd --add-service=zabbix --permanent
firewall-cmd --reload
else
echo "Unable to determine linux distro"
exit
fi
# download the correct file for the correct OS
FILENAME="zabbix_repo.deb"
DEBIAN_URL="http://repo.zabbix.com/zabbix/3.4/debian/pool/main/z/zabbix-release/zabbix-release_3.4-1+stretch_all.deb"
#CENTOS_URL="http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm"
#UBUNTU_URL="https://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1%2Bbionic_all.deb"
wget --output-document=${DIRECTORY}/${FILENAME} $DEBIAN_URL
# install the repo
dpkg --install ${DIRECTORY}/${FILENAME}
ZABBIX_SERVER="gauntzabbix.home.johnhgaunt.com"
# update the cache
apt update
# install the agent
apt install --assume-yes zabbix-agent
# ask for the hostname
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname