-
-
Save vncloudsco/781141f27991707ddaf5f19bac4f991c to your computer and use it in GitHub Desktop.
Bash script instalador do Zabbix Agent 2.0.6 para Linux. Para instalação do Zabbix Agent, basta executar esse script com o comando: sudo bash -c "bash <( curl -s -L https://gist.github.com/cdavidnt/5658654/raw/install_zabbix_agentd.sh )"
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 | |
verificaPermissaoUsuario() { | |
ROOT_UID=0 | |
if [ "$UID" -ne "$ROOT_UID" ] ; then | |
echo "É preciso rodar como root" | |
exit 1 | |
fi | |
} | |
iniciaAgent() { | |
echo "Deseja iniciar o serviço 'zabbix-agent' agora? [S|n]" | |
read opt | |
if [ "$opt" != "n" ]; then | |
/sbin/initctl start $zabbix_upstart_job | |
fi | |
} | |
verificaPermissaoUsuario | |
zabbix_tar="" | |
machine_type=$(uname -m) | |
if [ $machine_type == "i686" ] || [ $machine_type == "i386" ]; then | |
zabbix_tar="http://www.zabbix.com/downloads/2.0.6/zabbix_agents_2.0.6.linux2_6_23.i386.tar.gz" | |
elif [ $machine_type == "x86_64" ]; then | |
zabbix_tar="http://www.zabbix.com/downloads/2.0.6/zabbix_agents_2.0.6.linux2_6_23.amd64.tar.gz" | |
else | |
echo "Arquitetura nao encontrada" | |
exit 1 | |
fi | |
zabbix_folder="/opt/zabbix" | |
mkdir -p $zabbix_folder | |
cd $zabbix_folder | |
echo "Baixando Zabbix Agent" | |
curl -L $zabbix_tar | tar xz | |
read -p "Digite o endereço do servidor Zabbix: " zabbix_server | |
zabbix_conf="${zabbix_folder}/conf/zabbix_agent.conf" | |
sed -i "s/Server=127.0.0.1/Server=$zabbix_server/" $zabbix_conf | |
zabbix_daemon="${zabbix_folder}/sbin/zabbix_agentd" | |
zabbix_upstart_job="zabbix-agent" | |
echo "# zabbix-agent - Start zabbix agent | |
description \"Zabbix Agent\" | |
author \"S. CANCHON\" | |
start on runlevel [2345] | |
stop on runlevel [016] | |
respawn | |
expect daemon | |
exec $zabbix_daemon -c $zabbix_conf" > /etc/init/${zabbix_upstart_job}.conf | |
zabbix_user="zabbix" | |
id $zabbix_user | |
zabbix_exists=$? | |
if [ $zabbix_exists -ne 0 ]; then | |
echo "Usuario zabbix não existe. Criando usuário" | |
groupadd $zabbix_user | |
useradd -g $zabbix_user $zabbix_user | |
else | |
echo "Já existe um usuário chamado $zabbix_user" | |
fi | |
iniciaAgent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment