Files
homelab-scripts/zabbix_agent.sh
2018-06-07 10:48:39 -04:00

38 lines
1.2 KiB
Bash

#!/bin/bash
# installs the zabbix agent and configures it
# create temp directory for downloaded files
DIRECTORY="/tmp/zabbix_install"
mkdir ${DIRECTORY}
# download the correct file for the correct OS
FILENAME="zabbix_repo.deb"
DEBIAN_URL="https://repo.zabbix.com/zabbix/3.5/debian/pool/main/z/zabbix-release/zabbix-release_3.5-1%2Bstretch_all.deb"
#CENTOS_URL="https://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm"
#UBUNTU_URL="https://repo.zabbix.com/zabbix/3.5/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.5-1%2Bbionic_all.deb"
wget --output-document=${DIRECTORY}/${FILENAME} $DEBIAN_URL
# install the repo
dpkg -i ${DIRECTORY}/${FILENAME}
ZABBIX_SERVER="gauntzabbix.home.johnhgaunt.com"
# update the cache
apt update
# install the agent
apt install zabbix-agent
# ask for the hostname
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname
sed -i 's/Hostname=Zabbix\ server/Hostname=${hostname}/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/Server=127.0.0.1/Server=${ZABBIX_SERVER}/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=${ZABBIX_SERVER}/' /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent
systemctl enable zabbix-agent