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 exit
fi fi
# create temp directory for downloaded files # zabbix server
DIRECTORY="/tmp/zabbix_install" ZABBIX_SERVER="gauntzabbix.home.johnhgaunt.com"
mkdir ${DIRECTORY}
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
#apt update # Install the repository configuration package. This package contains apt (software package manager) configuration files.
#apt install -y snmpd curl 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 elif [ -f /etc/redhat-release ]; then
#yum install -y net-snmp net-snmp-utils # Install the repository configuration package. This package contains yum (software package manager) configuration files.
#firewall-cmd --zone=public --add-service=snmp --permanent rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
#firewall-cmd --reload # 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 else
echo "Unable to determine linux distro" echo "Unable to determine linux distro"
exit exit
fi 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 # ask for the hostname
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname