Last active
June 1, 2022 12:07
-
-
Save marcilioramos/421c5bd5cc377c51f6e7128654f4b0f0 to your computer and use it in GitHub Desktop.
instalador do zabbix-agent2 para ubuntu e centos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################################### | |
# Script de instalação do agent2 zabbix versão 6.0 | |
# Autor: Marcilio Ramos | |
# Data: 12.04.22 | |
# | |
# bash <(wget -nv -O - ${https://gist.githubusercontent.com/marcilioramos/421c5bd5cc377c51f6e7128654f4b0f0/raw/987c42011cf22f2842fc8d4a4a29ac487273b625/install_zabbix_agent2.sh}) 10.100.0.55 VM.LINUX.$(hostname) | |
########################################################## | |
function config_zabbixconf (){ | |
mv /etc/zabbix/zabbix_agent2.conf /etc/zabbix/zabbix_agent2.$DATA | |
echo " | |
PidFile=/var/run/zabbix/zabbix_agent2.pid | |
LogFile=/var/log/zabbix/zabbix_agent2.log | |
LogFileSize=0 | |
Server=$SERVER | |
ServerActive=$SERVER | |
Hostname=$HOSTNAME | |
Include=/etc/zabbix/zabbix_agent2.d/*.conf | |
ControlSocket=/tmp/agent.sock | |
" > /etc/zabbix/zabbix_agent2.conf | |
systemctl restart zabbix-agent2 | |
} | |
HOSTNAME=$1 | |
SERVER=$2 | |
DATA=$(date +"%d-%m-%y") | |
clear | |
echo "instalacao do agent2 zabbix" | |
sleep 1 | |
sed -n "3 p" /etc/os-release | egrep -o '[^ID"=]'| xargs | sed 's/ //g' | tr 'A-Z' 'a-z'> tmp.txt | |
DISTRO=$(cat tmp.txt) | |
grep VERSION_ID /etc/os-release | egrep -o '[^VERSION_ID"=]'| xargs | sed 's/ //g' > tmp.txt | |
VERSAO=$(cat tmp.txt) | |
sleep 2 | |
clear | |
echo "Distribuicao: $DISTRO" | |
echo "Versão: $VERSAO" | |
sleep 1 | |
if [ $DISTRO == "ubuntu" ]; then | |
wget https://repo.zabbix.com/zabbix/6.0/$DISTRO/pool/main/z/zabbix/zabbix-agent2_6.0.3-1%2B$DISTRO$VERSAO\_amd64.deb -O instalador_zabbix.deb | |
#rm -rfv /etc/zabbix/zabbix_agent* | |
apt-get remove zabbix_agent* -y ; apt-get purge zabbix_agent* | |
dpkg -i instalador_zabbix.deb | |
apt-get update ; apt-get install zabbix-agent2 -y | |
systemctl stop zabbix-agent2 | |
systemctl enable zabbix-agent2 | |
systemctl start zabbix-agent2 | |
clear | |
echo "==================================" | |
echo "CONFIG /ETC/ZABBIX_AGENT2.CONF" | |
echo "==================================" | |
config_zabbixconf | |
fi | |
if [ $DISTRO == "centos" ]; then | |
wget https://repo.zabbix.com/zabbix/6.0/rhel/$VERSAO/x86_64/zabbix-agent2-6.0.3-1.el$VERSAO\.x86_64.rpm -O instalador_zabbix.rpm | |
#rm -rfv /etc/zabbix/zabbix_agent* | |
#yum remove zabbix_agent* -y ; yum purge zabbix_agent* | |
yum localinstall instalador_zabbix.rpm -y | |
yum update ; yum install zabbix-agent2 -y | |
systemctl stop zabbix-agent2 | |
systemctl enable zabbix-agent2 | |
systemctl start zabbix-agent2 | |
clear | |
echo "==================================" | |
echo "CONFIG /ETC/ZABBIX_AGENT2.CONF" | |
echo "==================================" | |
config_zabbixconf | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment